• Login
  • login to access premium content (it's free).
 <<
 expand file="/system/clearimage/DLL.lib" /expand

 ###
 ### This script will upload any binary file by first converting it to the HTML/OS binary format
 ### null characters are replaced with ^n and carets are replaced with ^d (delimiter)
 #/#


 if getenv('REQUEST_METHOD')='POST' then
  TEXTTOBIN(sysstdin,'/playground/test/upload/upload-binary.png')
  goto forensics('')
 /if

 >>
 <!DOCTYPE html>
 <html>
 <head>
   <meta charset="UTF-8">
   <title>Binary-Safe File Transformer & Uploader</title>
 </head>
 <body>
   <h2>Upload and Transform a File</h2>
   <form id="uploadForm">
     <label>
       Upload URL:
       <input type="text" id="uploadUrl" placeholder="https://example.com/upload" size="50" required>
     </label>
     <br><br>
     <input type="file" id="fileInput" required />
     <br><br>
     <button type="submit">Upload Transformed File</button>
   </form>
   <pre id="output" style="white-space: pre-wrap; border: 1px solid #ccc; padding: 10px; max-height: 200px; overflow: auto;"></pre>
   <script>
     document.getElementById('uploadForm').addEventListener('submit', function (event) {
       event.preventDefault();
       const file = document.getElementById('fileInput').files[0];
       const uploadUrl = document.getElementById('uploadUrl').value;
       if (!file || !uploadUrl) return;
       const reader = new FileReader();
       reader.onload = function (e) {
    const bytes = new Uint8Array(e.target.result);
    let bytelist=[];
    for (let i = 0; i < bytes.length; i++) {
      const byte = bytes[i];
      if (byte === 0x00) {
        bytelist.push('^'.charCodeAt(0));
        bytelist.push('n'.charCodeAt(0));   // null byte
      } else if (byte === 0x5E) {
        bytelist.push('^'.charCodeAt(0));
        bytelist.push('d'.charCodeAt(0));   // caret
      } else {
        bytelist.push(byte);
      }
    }
    const transformed=new Uint8Array(bytelist);
    document.getElementById('output').textContent = transformed;
    fetch(uploadUrl, {
      method: 'POST',
      headers: {
        'Content-Type': 'text/x.escaped-binary'
      },
      body: transformed
    })
    .then(response => response.text())
    .then(result => {
      alert("Upload successful!");
      document.getElementById('output').innerHTML = result;
    })
    .catch(error => {
      alert("Upload failed: " + error.message);
    });
  };
  reader.readAsArrayBuffer(file);
 });
 </script>
 </body>
 </html>