mirror of
https://github.com/gchq/CyberChef.git
synced 2025-05-08 15:25:01 -04:00
refactor and rename 'Gootkit' to 'Gootloader' & added Gootloader Code Parser operator
This commit is contained in:
parent
ef3e8eb3b0
commit
c166e0b6a9
3 changed files with 57 additions and 6 deletions
|
@ -501,7 +501,8 @@
|
||||||
"Generate Lorem Ipsum",
|
"Generate Lorem Ipsum",
|
||||||
"Numberwang",
|
"Numberwang",
|
||||||
"XKCD Random Number",
|
"XKCD Random Number",
|
||||||
"GootLoader Decode"
|
"Gootloader Decode",
|
||||||
|
"Gootloader Code Parser"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,15 +7,15 @@ import Operation from "../Operation.mjs";
|
||||||
/**
|
/**
|
||||||
* Gootloader decode operation
|
* Gootloader decode operation
|
||||||
*/
|
*/
|
||||||
class GootLoaderDecode extends Operation {
|
class GootloaderDecode extends Operation {
|
||||||
/**
|
/**
|
||||||
* GootLoader constructor
|
* Gootloader constructor
|
||||||
*/
|
*/
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
this.name = "GootLoader Decode";
|
this.name = "Gootloader Decode";
|
||||||
this.module = "Code";
|
this.module = "Code";
|
||||||
this.description = "Decodes GootLoader JScript code block obfuscation";
|
this.description = "Decodes Gootloader JScript code block obfuscation";
|
||||||
this.inputType = "string";
|
this.inputType = "string";
|
||||||
this.outputType = "string";
|
this.outputType = "string";
|
||||||
this.args = [];
|
this.args = [];
|
||||||
|
@ -41,4 +41,4 @@ class GootLoaderDecode extends Operation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default GootLoaderDecode;
|
export default GootloaderDecode;
|
||||||
|
|
50
src/core/operations/GootloaderCodeParser.mjs
Normal file
50
src/core/operations/GootloaderCodeParser.mjs
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
/**
|
||||||
|
* @copyright Crown Copyright 2016
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
import Operation from "../Operation.mjs";
|
||||||
|
/**
|
||||||
|
* Gootloader code parser operation
|
||||||
|
*/
|
||||||
|
class GootloaderCodeParser extends Operation {
|
||||||
|
/**
|
||||||
|
* GootLoader constructor
|
||||||
|
*/
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
this.name = "Gootloader Code Parser";
|
||||||
|
this.module = "Code";
|
||||||
|
this.description = "Parse the actual code of Gootloader from JS";
|
||||||
|
this.inputType = "string";
|
||||||
|
this.outputType = "string";
|
||||||
|
this.args = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} input
|
||||||
|
* @param {Object[]} args
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
run(input, args) {
|
||||||
|
if (!input) return "";
|
||||||
|
input = input.split("\n");
|
||||||
|
|
||||||
|
const mainRegex = /^[a-z0-9]+\(/;
|
||||||
|
const variableRegex = /^[a-z0-9]+\s*=\s*/;
|
||||||
|
const functionRegex = /^function [a-z]/;
|
||||||
|
|
||||||
|
const main = input.filter(line => mainRegex.test(line));
|
||||||
|
const variables = input.filter(line => variableRegex.test(line));
|
||||||
|
const functionIndices = input
|
||||||
|
.map((line, index) => (functionRegex.test(line) ? index : -1))
|
||||||
|
.filter(index => index !== -1);
|
||||||
|
const functions = functionIndices.map(fStart => {
|
||||||
|
const fEnd = input.slice(fStart).findIndex(line => line === "}");
|
||||||
|
return input.slice(fStart, fStart + fEnd + 1).join("");
|
||||||
|
});
|
||||||
|
|
||||||
|
return variables.join("\n") + "\n\n" + functions.join("\n") + "\n\n" + main.join("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default GootloaderCodeParser;
|
Loading…
Add table
Add a link
Reference in a new issue