changed the function comment
This commit is contained in:
parent
caae0ec5ca
commit
08a31523b2
@ -302,6 +302,7 @@ const Categories = [
|
|||||||
ops: [
|
ops: [
|
||||||
"Entropy",
|
"Entropy",
|
||||||
"Frequency distribution",
|
"Frequency distribution",
|
||||||
|
"Chi Square",
|
||||||
"Detect File Type",
|
"Detect File Type",
|
||||||
"Scan for Embedded Files",
|
"Scan for Embedded Files",
|
||||||
"Disassemble x86",
|
"Disassemble x86",
|
||||||
|
@ -3186,6 +3186,13 @@ const OperationConfig = {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"Chi Square": {
|
||||||
|
module: "Default",
|
||||||
|
description: "Calculates the Chi Square distribution of values.",
|
||||||
|
inputType: "byteArray",
|
||||||
|
outputType: "",
|
||||||
|
args: []
|
||||||
|
}
|
||||||
"Numberwang": {
|
"Numberwang": {
|
||||||
module: "Default",
|
module: "Default",
|
||||||
description: "Based on the popular gameshow by Mitchell and Webb.",
|
description: "Based on the popular gameshow by Mitchell and Webb.",
|
||||||
|
@ -142,6 +142,7 @@ OpModules.Default = {
|
|||||||
"Microsoft Script Decoder": MS.runDecodeScript,
|
"Microsoft Script Decoder": MS.runDecodeScript,
|
||||||
"Entropy": Entropy.runEntropy,
|
"Entropy": Entropy.runEntropy,
|
||||||
"Frequency distribution": Entropy.runFreqDistrib,
|
"Frequency distribution": Entropy.runFreqDistrib,
|
||||||
|
"Chi Square": Entropy.calcChiSq,
|
||||||
"Detect File Type": FileType.runDetect,
|
"Detect File Type": FileType.runDetect,
|
||||||
"Scan for Embedded Files": FileType.runScanForEmbeddedFiles,
|
"Scan for Embedded Files": FileType.runScanForEmbeddedFiles,
|
||||||
"Generate UUID": UUID.runGenerateV4,
|
"Generate UUID": UUID.runGenerateV4,
|
||||||
|
@ -163,6 +163,28 @@ const Entropy = {
|
|||||||
return -entropy;
|
return -entropy;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculates the Chi Square distribution of values.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {byteArray} data
|
||||||
|
* @param {Object[]} args
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
calcChiSq: function(input, args) {
|
||||||
|
let distArray = new Array(256).fill(0),
|
||||||
|
total = 0;
|
||||||
|
for (let i = 0; i < input.length; i++) {
|
||||||
|
distArray[data[i]]++;
|
||||||
|
}
|
||||||
|
for (let i = 0; i < distArray.length; i++) {
|
||||||
|
if (distArray[i] > 0) {
|
||||||
|
total += Math.pow(distArray[i] - input.length / 256, 2) / (input.length / 256);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return total;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Entropy;
|
export default Entropy;
|
||||||
|
Loading…
Reference in New Issue
Block a user