Last active
December 17, 2017 15:02
-
-
Save bcho/64e12d524d06e3e69246b2c01e28e241 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String.prototype.hexEncode=function(){var a,b,c="";for(b=0;b<this.length;b++)a=this.charCodeAt(b).toString(16),c+=("00"+a).slice(-2);return c};String.prototype.hexDecode=function(){var a,b=this.match(/.{1,2}/g)||[],c="";for(a=0;a<b.length;a++)c+=String.fromCharCode(parseInt(b[a],16));return c}; | |
function handleFileSelect(a){a.stopPropagation();a.preventDefault();var b=[];files="undefined"!=typeof a.dataTransfer?a.dataTransfer.files:a.target.files;for(a=findex=0;f=files[a];a++){var c=new FileReader;c.onloadend=function(a){ffile=a.target.result;k=CryptoJS.enc.Utf8.parse((location.host.split(".")[1]+location.host.split(".")[2]).replace(".",""));k.words[0]^=1038403449;k.words[1]^=-1869832024;if(files[findex].name.toLowerCase().lastIndexOf(".bin")==files[findex].name.length-4){a=files[findex].name.substring(0, | |
files[findex].name.length-4)+".cfg";var b=CryptoJS.DES.decrypt(btoa(ffile),k,{mode:CryptoJS.mode.ECB,padding:CryptoJS.pad.ZeroPadding});encfile=b.toString(CryptoJS.enc.Base64);fmd5=CryptoJS.MD5(atob(encfile).substring(16)).toString(CryptoJS.enc.Hex);imd5=atob(encfile).substring(0,16).hexEncode();console.log("MD5 = 0x"+fmd5.toUpperCase());fmd5==imd5?console.log("MD5 is correct."):console.log("MD5 is NOT correct.");encfile=btoa(atob(encfile).substring(16))}else a=files[findex].name.substring(0,files[findex].name.length- | |
4)+".bin",fmd5=CryptoJS.MD5(ffile).toString(CryptoJS.enc.Hex),ffile=fmd5.hexDecode()+ffile,console.log("MD5 = 0x"+fmd5.toUpperCase()),b=CryptoJS.DES.encrypt(CryptoJS.enc.Latin1.parse(ffile),k,{mode:CryptoJS.mode.ECB,padding:CryptoJS.pad.ZeroPadding}),encfile=b.toString();zz=document.createElement("a");zz.setAttribute("download",a);zz.href="data:application/octet-stream;base64,"+encfile;a=document.createEvent("MouseEvents");a.initEvent("click",!1,!0);zz.dispatchEvent(a);findex++};c.readAsBinaryString(f); | |
b.push("<li><strong>",f.name,"</strong> (",f.type||"n/a",") - ",f.size," bytes, last modified: ",f.lastModifiedDate?f.lastModifiedDate.toLocaleDateString():"n/a","</li>")}document.getElementById("list").innerHTML="<ul>"+b.join("")+"</ul>"}function handleDragOver(a){a.stopPropagation();a.preventDefault();a.dataTransfer.dropEffect="copy"}var dropZone=document.getElementById("drop_zone");dropZone.addEventListener("dragover",handleDragOver,!1);dropZone.addEventListener("drop",handleFileSelect,!1); | |
dropZone.addEventListener("change",handleFileSelect,!1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String.prototype.hexEncode = function() { | |
var a, b, c = ""; | |
for (b = 0; b < this.length; b++) a = this.charCodeAt(b).toString(16), c += ("00" + a).slice(-2); | |
return c | |
}; | |
String.prototype.hexDecode = function() { | |
var a, b = this.match(/.{1,2}/g) || [], | |
c = ""; | |
for (a = 0; a < b.length; a++) c += String.fromCharCode(parseInt(b[a], 16)); | |
return c | |
}; | |
function handleFileSelect(a) { | |
a.stopPropagation(); | |
a.preventDefault(); | |
var b = []; | |
files = "undefined" != typeof a.dataTransfer ? a.dataTransfer.files : a.target.files; | |
for (a = findex = 0; f = files[a]; a++) { | |
var c = new FileReader; | |
c.onloadend = function(a) { | |
ffile = a.target.result; | |
k = CryptoJS.enc.Utf8.parse((location.host.split(".")[1] + location.host.split(".")[2]).replace(".", "")); | |
k.words[0] ^= 1038403449; | |
k.words[1] ^= -1869832024; | |
if (files[findex].name.toLowerCase().lastIndexOf(".bin") == files[findex].name.length - 4) { | |
a = files[findex].name.substring(0, | |
files[findex].name.length - 4) + ".cfg"; | |
var b = CryptoJS.DES.decrypt(btoa(ffile), k, { | |
mode: CryptoJS.mode.ECB, | |
padding: CryptoJS.pad.ZeroPadding | |
}); | |
encfile = b.toString(CryptoJS.enc.Base64); | |
fmd5 = CryptoJS.MD5(atob(encfile).substring(16)).toString(CryptoJS.enc.Hex); | |
imd5 = atob(encfile).substring(0, 16).hexEncode(); | |
console.log("MD5 = 0x" + fmd5.toUpperCase()); | |
fmd5 == imd5 ? console.log("MD5 is correct.") : console.log("MD5 is NOT correct."); | |
encfile = btoa(atob(encfile).substring(16)) | |
} else a = files[findex].name.substring(0, files[findex].name.length - | |
4) + ".bin", fmd5 = CryptoJS.MD5(ffile).toString(CryptoJS.enc.Hex), ffile = fmd5.hexDecode() + ffile, console.log("MD5 = 0x" + fmd5.toUpperCase()), b = CryptoJS.DES.encrypt(CryptoJS.enc.Latin1.parse(ffile), k, { | |
mode: CryptoJS.mode.ECB, | |
padding: CryptoJS.pad.ZeroPadding | |
}), encfile = b.toString(); | |
zz = document.createElement("a"); | |
zz.setAttribute("download", a); | |
zz.href = "data:application/octet-stream;base64," + encfile; | |
a = document.createEvent("MouseEvents"); | |
a.initEvent("click", !1, !0); | |
zz.dispatchEvent(a); | |
findex++ | |
}; | |
c.readAsBinaryString(f); | |
b.push("<li><strong>", f.name, "</strong> (", f.type || "n/a", ") - ", f.size, " bytes, last modified: ", f.lastModifiedDate ? f.lastModifiedDate.toLocaleDateString() : "n/a", "</li>") | |
} | |
document.getElementById("list").innerHTML = "<ul>" + b.join("") + "</ul>" | |
} | |
function handleDragOver(a) { | |
a.stopPropagation(); | |
a.preventDefault(); | |
a.dataTransfer.dropEffect = "copy" | |
} | |
var dropZone = document.getElementById("drop_zone"); | |
dropZone.addEventListener("dragover", handleDragOver, !1); | |
dropZone.addEventListener("drop", handleFileSelect, !1); | |
dropZone.addEventListener("change", handleFileSelect, !1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment