mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-21 07:16:17 -04:00
Fixed spelling errors, syntax errors, and improved the test for script decoding
This commit is contained in:
parent
0fc2a219a7
commit
934ed1af09
4 changed files with 22 additions and 18 deletions
|
@ -66,7 +66,7 @@ const Categories = [
|
||||||
"Encode text",
|
"Encode text",
|
||||||
"Decode text",
|
"Decode text",
|
||||||
"Swap endianness",
|
"Swap endianness",
|
||||||
"Micrsoft Script Decoder",
|
"Microsoft Script Decoder",
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -521,6 +521,7 @@ const OperationConfig = {
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
"To Charcode": {
|
"To Charcode": {
|
||||||
description: "Converts text to its unicode character code equivalent.<br><br>e.g. <code>Γειά σου</code> becomes <code>0393 03b5 03b9 03ac 20 03c3 03bf 03c5</code>",
|
description: "Converts text to its unicode character code equivalent.<br><br>e.g. <code>Γειά σου</code> becomes <code>0393 03b5 03b9 03ac 20 03c3 03bf 03c5</code>",
|
||||||
run: ByteRepr.runToCharcode,
|
run: ByteRepr.runToCharcode,
|
||||||
|
@ -3205,8 +3206,8 @@ const OperationConfig = {
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"Micrsoft Script Decoder": {
|
"Microsoft Script Decoder": {
|
||||||
description: "Decodes Microsoft Encoded Script 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. These are often VBS (Visual Basic Script) files that are encoded and often renamed ".vbe" extention or JS (JScript) files renamed with ".jse" extention.",
|
||||||
run: MS.runDecodeScript,
|
run: MS.runDecodeScript,
|
||||||
inputType: "string",
|
inputType: "string",
|
||||||
outputType: "string",
|
outputType: "string",
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/**
|
/**
|
||||||
* Decodes Microsft Encoded Script files that can be read and executed by cscript.exe/wscript.exe.
|
* Decodes Microsoft 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]
|
||||||
|
@ -215,17 +215,18 @@ const MS = {
|
||||||
],
|
],
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @private
|
||||||
* @param {string} data
|
* @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.replace(/@&/g, String.fromCharCode(10));
|
data = data.replace(/@&/g, String.fromCharCode(10))
|
||||||
data = data.replace(/@#/g, String.fromCharCode(13));
|
.replace(/@#/g, String.fromCharCode(13))
|
||||||
data = data.replace(/@\*/g, ">");
|
.replace(/@\*/g, ">")
|
||||||
data = data.replace(/@!/g, "<");
|
.replace(/@!/g, "<")
|
||||||
data = data.replace(/@\$/g, "@");
|
.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);
|
||||||
|
@ -241,15 +242,17 @@ const MS = {
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Microsoft Script Decoder operation
|
||||||
|
*
|
||||||
* @param {string} input
|
* @param {string} input
|
||||||
* @param {Object[]} args
|
* @param {Object[]} args
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
runDecodeScript: function (input, args) {
|
runDecodeScript: function (input, args) {
|
||||||
let matcher = /#@~\^......==(.+)......==\^#~@/;
|
let matcher = /#@~\^.{6}==(.+).{6}==\^#~@/;
|
||||||
let encodedData = matcher.exec(input);
|
let encodedData = matcher.exec(input);
|
||||||
if (encodedData){
|
if (encodedData){
|
||||||
return MS.decode(encodedData[1]);
|
return MS._decode(encodedData[1]);
|
||||||
} else {
|
} else {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* CharEnc tests.
|
* MS tests.
|
||||||
*
|
*
|
||||||
* @author tlwr [toby@toby.codes]
|
* @author bwhitn [brian.m.whitney@outlook.com]
|
||||||
* @copyright Crown Copyright 2017
|
* @copyright Crown Copyright 2017
|
||||||
* @license Apache-2.0
|
* @license Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
@ -9,12 +9,12 @@ import TestRegister from "../../TestRegister.js";
|
||||||
|
|
||||||
TestRegister.addTests([
|
TestRegister.addTests([
|
||||||
{
|
{
|
||||||
name: "Micrsoft Script Decoder",
|
name: "Microsoft Script Decoder",
|
||||||
input: "##@~^DgAAAA==\\ko$K6,JCV^GJqAQAAA==^#~@",
|
input: "#@~^RQAAAA==-mD~sX|:/TP{~J:+dYbxL~@!F@*@!+@*@!&@*eEI@#@&@#@&\x7fjm.raY 214Wv:zms/obI0xEAAA==^#~@",
|
||||||
expectedOutput: "MsgBox \"Hello\"",
|
expectedOutput: "var my_msg = \"Testing <1><2><3>!\";\r\n\r\nWScript.Echo(my_msg);",
|
||||||
recipeConfig: [
|
recipeConfig: [
|
||||||
{
|
{
|
||||||
"op": "Micrsoft Script Decoder",
|
"op": "Microsoft Script Decoder",
|
||||||
"args": []
|
"args": []
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue