Changed the name. Small logic change. Changed from split join to regex replace.

This commit is contained in:
bwhitn 2017-08-28 17:55:54 -04:00
parent aa5939c051
commit 0fc2a219a7
5 changed files with 26 additions and 21 deletions

View file

@ -66,7 +66,7 @@ const Categories = [
"Encode text", "Encode text",
"Decode text", "Decode text",
"Swap endianness", "Swap endianness",
"Decode VBE", "Micrsoft Script Decoder",
] ]
}, },
{ {

View file

@ -25,6 +25,7 @@ import IP from "../operations/IP.js";
import JS from "../operations/JS.js"; import JS from "../operations/JS.js";
import MAC from "../operations/MAC.js"; import MAC from "../operations/MAC.js";
import MorseCode from "../operations/MorseCode.js"; import MorseCode from "../operations/MorseCode.js";
import MS from "../operations/MS.js";
import NetBIOS from "../operations/NetBIOS.js"; import NetBIOS from "../operations/NetBIOS.js";
import Numberwang from "../operations/Numberwang.js"; import Numberwang from "../operations/Numberwang.js";
import OS from "../operations/OS.js"; import OS from "../operations/OS.js";
@ -38,7 +39,7 @@ import Tidy from "../operations/Tidy.js";
import Unicode from "../operations/Unicode.js"; import Unicode from "../operations/Unicode.js";
import URL_ from "../operations/URL.js"; import URL_ from "../operations/URL.js";
import UUID from "../operations/UUID.js"; import UUID from "../operations/UUID.js";
import VBE from "../operations/VBE.js";
/** /**
* Type definition for an OpConf. * Type definition for an OpConf.
@ -3204,9 +3205,9 @@ const OperationConfig = {
} }
] ]
}, },
"Decode VBE": { "Micrsoft Script Decoder": {
description: "Decodes Microsoft VBE files that have been encoded with Microsoft's custom encoding.", description: "Decodes Microsoft Encoded Script files that have been encoded with Microsoft's custom encoding.",
run: VBE.runDecodeVBE, run: MS.runDecodeScript,
inputType: "string", inputType: "string",
outputType: "string", outputType: "string",
args: [] args: []

View file

@ -1,12 +1,12 @@
/** /**
* Decodes Microsft Encoded VBS files that can be read and executed by cscript.exe/wscript.exe. * Decodes Microsft Encoded Script files that can be read and executed by cscript.exe/wscript.exe.
* This is a conversion of a Python script that was originally created by Didier Stevens (https://DidierStevens.com). * This is a conversion of a Python script that was originally created by Didier Stevens (https://DidierStevens.com).
* *
* @author bmwhitn [brian.m.whitney@outlook.com] * @author bmwhitn [brian.m.whitney@outlook.com]
* *
* @namespace * @namespace
*/ */
const VBE = { const MS = {
/** /**
* @constant * @constant
@ -215,17 +215,17 @@ const VBE = {
], ],
/** /**
* @param {string} input * @param {string} data
* @returns {string} * @returns {string}
*/ */
decode: function (data) { decode: function (data) {
let result = []; let result = [];
let index = -1; let index = -1;
data = data.split("@&").join(String.fromCharCode(10)); data = data.replace(/@&/g, String.fromCharCode(10));
data = data.split("@#").join(String.fromCharCode(13)); data = data.replace(/@#/g, String.fromCharCode(13));
data = data.split("@*").join(">"); data = data.replace(/@\*/g, ">");
data = data.split("@!").join("<"); data = data.replace(/@!/g, "<");
data = data.split("@$").join("@"); data = data.replace(/@\$/g, "@");
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
let byte = data.charCodeAt(i); let byte = data.charCodeAt(i);
let char = data.charAt(i); let char = data.charAt(i);
@ -233,7 +233,7 @@ const VBE = {
index++; index++;
} }
if ((byte === 9 || byte > 31 && byte < 128) && byte !== 60 && byte !== 62 && byte !== 64) { if ((byte === 9 || byte > 31 && byte < 128) && byte !== 60 && byte !== 62 && byte !== 64) {
char = VBE.D_DECODE[byte].charAt([VBE.D_COMBINATION[index % 64]]); char = MS.D_DECODE[byte].charAt(MS.D_COMBINATION[index % 64]);
} }
result.push(char); result.push(char);
} }
@ -245,11 +245,15 @@ const VBE = {
* @param {Object[]} args * @param {Object[]} args
* @returns {string} * @returns {string}
*/ */
runDecodeVBE: function (data, args) { runDecodeScript: function (input, args) {
let matcher = /#@~\^......==(.+)......==\^#~@/; let matcher = /#@~\^......==(.+)......==\^#~@/;
let encodedData = matcher.exec(data); let encodedData = matcher.exec(input);
return VBE.decode(encodedData[1]); if (encodedData){
return MS.decode(encodedData[1]);
} else {
return "";
}
}, },
}; };
export default VBE; export default MS;

View file

@ -22,9 +22,9 @@ import "./tests/operations/DateTime.js";
import "./tests/operations/FlowControl.js"; import "./tests/operations/FlowControl.js";
import "./tests/operations/Image.js"; import "./tests/operations/Image.js";
import "./tests/operations/MorseCode.js"; import "./tests/operations/MorseCode.js";
import "./tests/operations/MS.js";
import "./tests/operations/StrUtils.js"; import "./tests/operations/StrUtils.js";
import "./tests/operations/SeqUtils.js"; import "./tests/operations/SeqUtils.js";
import "./tests/operations/VBE.js";
let allTestsPassing = true; let allTestsPassing = true;

View file

@ -9,12 +9,12 @@ import TestRegister from "../../TestRegister.js";
TestRegister.addTests([ TestRegister.addTests([
{ {
name: "VBE Decode", name: "Micrsoft Script Decoder",
input: "##@~^DgAAAA==\\ko$K6,JCV^GJqAQAAA==^#~@", input: "##@~^DgAAAA==\\ko$K6,JCV^GJqAQAAA==^#~@",
expectedOutput: "MsgBox \"Hello\"", expectedOutput: "MsgBox \"Hello\"",
recipeConfig: [ recipeConfig: [
{ {
"op": "Decode VBE", "op": "Micrsoft Script Decoder",
"args": [] "args": []
}, },
], ],