mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-23 00:06:17 -04:00
CC-1225 jswhat
This commit is contained in:
parent
1bc88728f0
commit
a6eb62deec
4 changed files with 116 additions and 1 deletions
14
package-lock.json
generated
14
package-lock.json
generated
|
@ -53,6 +53,7 @@
|
|||
"jsonwebtoken": "8.5.1",
|
||||
"jsqr": "^1.4.0",
|
||||
"jsrsasign": "^10.6.1",
|
||||
"jswhat": "^2.0.1",
|
||||
"kbpgp": "2.1.15",
|
||||
"libbzip2-wasm": "0.0.4",
|
||||
"libyara-wasm": "^1.2.1",
|
||||
|
@ -8866,6 +8867,14 @@
|
|||
"url": "https://github.com/kjur/jsrsasign#donations"
|
||||
}
|
||||
},
|
||||
"node_modules/jswhat": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/jswhat/-/jswhat-2.0.1.tgz",
|
||||
"integrity": "sha512-hG4KZxhTaTSxn03Vr44OAnMUR6pYYWMylcnvkXAaB9qqpjOVKWJZRjN2iFuFa4jbqiyKIBj5t+SL/kpHbk7j5A==",
|
||||
"bin": {
|
||||
"what": "dist/what.js"
|
||||
}
|
||||
},
|
||||
"node_modules/jszip": {
|
||||
"version": "2.7.0",
|
||||
"resolved": "https://registry.npmjs.org/jszip/-/jszip-2.7.0.tgz",
|
||||
|
@ -19819,6 +19828,11 @@
|
|||
"resolved": "https://registry.npmjs.org/jsrsasign/-/jsrsasign-10.6.1.tgz",
|
||||
"integrity": "sha512-emiQ05haY9CRj1Ho/LiuCqr/+8RgJuWdiHYNglIg2Qjfz0n+pnUq9I2QHplXuOMO2EnAW1oCGC1++aU5VoWSlw=="
|
||||
},
|
||||
"jswhat": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/jswhat/-/jswhat-2.0.1.tgz",
|
||||
"integrity": "sha512-hG4KZxhTaTSxn03Vr44OAnMUR6pYYWMylcnvkXAaB9qqpjOVKWJZRjN2iFuFa4jbqiyKIBj5t+SL/kpHbk7j5A=="
|
||||
},
|
||||
"jszip": {
|
||||
"version": "2.7.0",
|
||||
"resolved": "https://registry.npmjs.org/jszip/-/jszip-2.7.0.tgz",
|
||||
|
|
|
@ -135,6 +135,7 @@
|
|||
"jsonwebtoken": "8.5.1",
|
||||
"jsqr": "^1.4.0",
|
||||
"jsrsasign": "^10.6.1",
|
||||
"jswhat": "^2.0.1",
|
||||
"kbpgp": "2.1.15",
|
||||
"libbzip2-wasm": "0.0.4",
|
||||
"libyara-wasm": "^1.2.1",
|
||||
|
|
|
@ -444,7 +444,8 @@
|
|||
"View Bit Plane",
|
||||
"Randomize Colour Palette",
|
||||
"Extract LSB",
|
||||
"ELF Info"
|
||||
"ELF Info",
|
||||
"What Is It"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
99
src/core/operations/WhatIsIt.mjs
Normal file
99
src/core/operations/WhatIsIt.mjs
Normal file
|
@ -0,0 +1,99 @@
|
|||
/**
|
||||
* @author depperm [epper.marshall@gmail.com]
|
||||
* @copyright Crown Copyright 2023
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation.mjs";
|
||||
import what from 'jswhat';
|
||||
|
||||
/**
|
||||
* WhatIsIt operation
|
||||
*/
|
||||
class WhatIsIt extends Operation {
|
||||
|
||||
/**
|
||||
* WhatIsIt constructor
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.name = "What Is It";
|
||||
this.module = "Default";
|
||||
this.description = "Implements JsWhat, a PyWhat port, to guess what a string is.";
|
||||
this.infoURL = "https://github.com/apteryxxyz/jswhat";
|
||||
this.inputType = "string";
|
||||
this.outputType = "JSON";
|
||||
this.presentType = "html";
|
||||
this.args = [
|
||||
{
|
||||
name: "Search",
|
||||
type: "boolean",
|
||||
value: false
|
||||
},
|
||||
{
|
||||
name: "Filter",
|
||||
type: "string",
|
||||
value: ""
|
||||
},
|
||||
{
|
||||
name: "Exclude",
|
||||
type: "string",
|
||||
value: ""
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {JSON}
|
||||
*/
|
||||
run(input, args) {
|
||||
const [search, filter, exclude] = args;
|
||||
let fOptions = { search };
|
||||
if (filter.length) {
|
||||
fOptions.filter = filter.split(/,\s?/);
|
||||
}
|
||||
if (exclude.length) {
|
||||
fOptions.exclude = exclude.split(/,\s?/);
|
||||
}
|
||||
console.log(fOptions)
|
||||
return what.is(input, fOptions);
|
||||
}
|
||||
/**
|
||||
* Displays WhatIsIt results in HTML for web apps.
|
||||
*
|
||||
* @param {JSON} options
|
||||
* @returns {html}
|
||||
*/
|
||||
present(options) {
|
||||
let output = `<table
|
||||
class='table table-hover table-sm table-bordered'
|
||||
style='table-layout: fixed;'>
|
||||
<tr>
|
||||
<th>Identified as</th>
|
||||
<th>Matched Text</th>
|
||||
<th>Description</th>
|
||||
</tr>`;
|
||||
|
||||
options.forEach(option => {
|
||||
output += `<tr>
|
||||
<td>${option.name}</td>
|
||||
<td>${option.matched}</td>
|
||||
<td>${option.description}(${option.tags.join(', ')})</td>
|
||||
</tr>`;
|
||||
});
|
||||
|
||||
output += "</table><script type='application/javascript'>$('[data-toggle=\"tooltip\"]').tooltip()</script>";
|
||||
|
||||
if (!options.length) {
|
||||
output = "Nothing of interest could be detected about the input data.\nHave you tried modifying the operation arguments?";
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default WhatIsIt;
|
Loading…
Add table
Add a link
Reference in a new issue