Created
September 3, 2011 16:08
-
-
Save iron9light/1191402 to your computer and use it in GitHub Desktop.
Windows jscript base64 decoder. Decode all oo.xx.exe to oo.xx. Just double click.
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
foForReading = 1 // Open base 64 code file for reading | |
foAsASCII = 0 // Open base 64 code file as ASCII file | |
adSaveCreateOverWrite = 2 // Mode for ADODB.Stream | |
adTypeBinary = 1 // Binary file is encoded | |
function decode(from, to) { | |
var fileSystemObj = WScript.CreateObject("Scripting.FileSystemObject"); | |
var file = fileSystemObj.GetFile(from) | |
var inputStream = file.OpenAsTextStream(foForReading, foAsASCII); | |
var xmlObj = WScript.CreateObject("MSXml2.DOMDocument"); | |
var docElement = xmlObj.createElement("Base64Data"); | |
docElement.dataType = "bin.base64"; | |
docElement.text = inputStream.ReadAll(); | |
var outputStream = WScript.CreateObject("ADODB.Stream"); | |
outputStream.Type = adTypeBinary; | |
outputStream.Open(); | |
outputStream.Write(docElement.nodeTypedValue); | |
outputStream.SaveToFile(to, adSaveCreateOverWrite); | |
inputStream.Close(); | |
outputStream.Close(); | |
} | |
function getDataName(txtName) { | |
return txtName.substring(0, txtName.length - ".txt".length); | |
} | |
function getFileNames() { | |
var fileSystem = WScript.CreateObject("Scripting.FileSystemObject"); | |
var files = new Enumerator(fileSystem.GetFolder(".").files); | |
var result = []; | |
for (; !files.atEnd(); files.moveNext()) { | |
var file = files.item(); | |
if(file.Name.match(/\.txt/)) { | |
result.push(file.Name); | |
} | |
} | |
return result; | |
} | |
function main() { | |
var files = getFileNames(); | |
for (i in files) { | |
decode(files[i], getDataName(files[i])); | |
} | |
} | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment