mirror of
https://github.com/gchq/CyberChef.git
synced 2025-05-14 10:06:58 -04:00
Modifications made.
This commit is contained in:
parent
4247ddb0ce
commit
6373ad0bc3
6 changed files with 13 additions and 60 deletions
|
@ -25,7 +25,6 @@ class Operation {
|
|||
this._flowControl = false;
|
||||
this._manualBake = false;
|
||||
this._ingList = [];
|
||||
// this._checks = [];
|
||||
this._inputRegexes = [];
|
||||
this._outputRegexes = [];
|
||||
|
||||
|
|
|
@ -246,19 +246,6 @@ class Magic {
|
|||
return results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the mime value of the data compared to the specified type.
|
||||
*
|
||||
* @param {ArrayBuffer} data
|
||||
* @param {string} type
|
||||
* @returns {boolean}
|
||||
*/
|
||||
async checkMime (data, type) {
|
||||
if (isType(type, data)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses the checks to validate the input/output of potential operations.
|
||||
|
@ -296,7 +283,7 @@ class Magic {
|
|||
|
||||
const mime = OperationConfig[op.op].mimeCheck;
|
||||
if (mime)
|
||||
if (await this.checkMime(output, mime.type))
|
||||
if (!isType(output, mime.type))
|
||||
return;
|
||||
|
||||
// If the recipe returned an empty buffer, do not continue
|
||||
|
@ -390,7 +377,7 @@ class Magic {
|
|||
const prevOp = recipeConfig[recipeConfig.length - 1];
|
||||
|
||||
results = results.concat(await this.regexesTests("Input", matchingOps, prevOp, depth, extLang, intensive, recipeConfig, crib, inputEntropy));
|
||||
results = results.concat(await this.regexesTests("Output", this.opPatterns.getOutputRegexes(), prevOp, depth, extLang, intensive, recipeConfig, crib, inputEntropy));
|
||||
results = results.concat(await this.regexesTests("Output", this.opPatterns.OutputRegexes, prevOp, depth, extLang, intensive, recipeConfig, crib, inputEntropy));
|
||||
|
||||
if (intensive) {
|
||||
// Run brute forcing of various types on the data and create a new branch for each option
|
||||
|
@ -488,7 +475,6 @@ class Magic {
|
|||
* @returns {number[]}
|
||||
*/
|
||||
_freqDist(data=this.inputBuffer) {
|
||||
// if (this.freqDist) return this.freqDist;
|
||||
|
||||
const len = data.length;
|
||||
let i = len;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import OperationConfig from "../config/OperationConfig.json";
|
||||
/**
|
||||
* An object used by magic to store the input/output criteria for valid operation results.
|
||||
*
|
||||
|
@ -5,8 +6,6 @@
|
|||
* @copyright Crown Copyright 2020
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
import OperationConfig from "../config/OperationConfig.json";
|
||||
|
||||
class potentialOps {
|
||||
|
||||
/**
|
||||
|
@ -19,8 +18,8 @@ class potentialOps {
|
|||
this.inputRegexes = this.generateInputOpPatterns();
|
||||
this.outputRegexes = this.generateOutputOpPatterns();
|
||||
} else {
|
||||
this.inputRegexes = prevOp.getInputRegexes();
|
||||
this.outputRegexes = prevOp.getOutputRegexes();
|
||||
this.inputRegexes = prevOp.InputRegexes;
|
||||
this.outputRegexes = prevOp.OutputRegexes;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -131,4 +130,5 @@ class potentialOps {
|
|||
return opPatterns;
|
||||
}
|
||||
|
||||
} export default potentialOps;
|
||||
}
|
||||
export default potentialOps;
|
||||
|
|
|
@ -37,28 +37,6 @@ class ChangeIPFormat extends Operation {
|
|||
"value": ["Dotted Decimal", "Decimal", "Octal", "Hex"]
|
||||
}
|
||||
];
|
||||
this.checks =
|
||||
{
|
||||
inRegexes: [
|
||||
{
|
||||
match: "^\\s*([0-9]{1,3}\\.){3}[0-9]{1,3}$",
|
||||
flags: "",
|
||||
magic: false,
|
||||
args: ["Dotted Decimal", "Decimal"]
|
||||
},
|
||||
{
|
||||
match: "^\\s*([0-9]{1,3}\\.){3}[0-9]{1,3}$",
|
||||
flags: "",
|
||||
magic: false,
|
||||
args: ["Dotted Decimal", "Octal"]
|
||||
},
|
||||
{
|
||||
match: "^\\s*([0-9]{1,3}\\.){3}[0-9]{1,3}$",
|
||||
flags: "",
|
||||
magic: false,
|
||||
args: ["Dotted Decimal", "Hex"]
|
||||
}]
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -55,16 +55,6 @@ class FormatMACAddresses extends Operation {
|
|||
"value": false
|
||||
}
|
||||
];
|
||||
this.checks =
|
||||
{
|
||||
inRegexes: [
|
||||
{
|
||||
match: "^\\s*([0-9a-f]{2}:){5}[0-9a-f]{2}$",
|
||||
flags: "i",
|
||||
magic: false,
|
||||
args: ["Both", true, true, true, true, true]
|
||||
}]
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue