ESM: Added portOperation.mjs script. Added To and From Hexdump operations.

This commit is contained in:
n1474335 2018-05-06 12:24:01 +01:00
parent a8aa1bc5e8
commit 1f877817f4
13 changed files with 7208 additions and 6713 deletions

View File

@ -22,7 +22,7 @@ module.exports = function (grunt) {
// Tasks
grunt.registerTask("dev",
"A persistent task which creates a development build whenever source files are modified.",
["clean:dev", "webpack-dev-server:start"]);
["clean:dev", "concurrent:dev"]);
grunt.registerTask("node",
"Compiles CyberChef into a single NodeJS module.",
@ -61,9 +61,11 @@ module.exports = function (grunt) {
grunt.loadNpmTasks("grunt-jsdoc");
grunt.loadNpmTasks("grunt-contrib-clean");
grunt.loadNpmTasks("grunt-contrib-copy");
grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks("grunt-chmod");
grunt.loadNpmTasks("grunt-exec");
grunt.loadNpmTasks("grunt-accessibility");
grunt.loadNpmTasks("grunt-concurrent");
// Project configuration
@ -348,6 +350,18 @@ module.exports = function (grunt) {
src: ["docs/**/*", "docs/"]
}
},
watch: {
config: {
files: ["src/core/operations/**/*", "!src/core/operations/index.mjs"],
tasks: ["exec:generateConfig"]
}
},
concurrent: {
dev: ["watch:config", "webpack-dev-server:start"],
options: {
logConcurrentOutput: true
}
},
exec: {
repoSize: {
command: [
@ -364,9 +378,10 @@ module.exports = function (grunt) {
},
generateConfig: {
command: [
"echo '\n--- Regenerating config files. ---'",
"node --experimental-modules src/core/config/scripts/generateOpsIndex.mjs",
"node --experimental-modules src/core/config/scripts/generateConfig.mjs",
"echo ---\nConfig scripts finished.\n---\n"
"echo '--- Config scripts finished. ---\n'"
].join(";")
},
tests: {

4510
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -41,8 +41,10 @@
"grunt": ">=1.0.2",
"grunt-accessibility": "~6.0.0",
"grunt-chmod": "~1.1.1",
"grunt-concurrent": "^2.3.1",
"grunt-contrib-clean": "~1.1.0",
"grunt-contrib-copy": "~1.0.0",
"grunt-contrib-watch": "^1.0.1",
"grunt-eslint": "^20.1.0",
"grunt-exec": "~3.0.0",
"grunt-jsdoc": "^2.2.1",

View File

@ -1,366 +0,0 @@
/**
* Type definition for a CatConf.
*
* @typedef {Object} CatConf
* @property {string} name - The display name for the category
* @property {string[]} ops - A list of the operations to be included in this category
*/
/**
* Categories of operations.
*
* @author n1474335 [n1474335@gmail.com]
* @copyright Crown Copyright 2016
* @license Apache-2.0
*
* @constant
* @type {CatConf[]}
*/
const Categories = [
{
name: "Favourites",
ops: []
},
{
name: "Data format",
ops: [
// "To Hexdump",
// "From Hexdump",
"To Hex",
"From Hex",
// "To Charcode",
// "From Charcode",
// "To Decimal",
// "From Decimal",
// "To Binary",
// "From Binary",
// "To Octal",
// "From Octal",
"To Base64",
"From Base64",
"Show Base64 offsets",
"To Base32",
"From Base32",
// "To Base58",
// "From Base58",
// "To Base",
// "From Base",
// "To BCD",
// "From BCD",
// "To HTML Entity",
// "From HTML Entity",
// "URL Encode",
// "URL Decode",
// "Escape Unicode Characters",
// "Unescape Unicode Characters",
// "To Quoted Printable",
// "From Quoted Printable",
// "To Punycode",
// "From Punycode",
// "To Hex Content",
// "From Hex Content",
// "PEM to Hex",
// "Hex to PEM",
// "Parse ASN.1 hex string",
// "Change IP format",
// "Encode text",
// "Decode text",
// "Swap endianness",
// ]
// },
// {
// name: "Encryption / Encoding",
// ops: [
// "AES Encrypt",
// "AES Decrypt",
// "Blowfish Encrypt",
// "Blowfish Decrypt",
// "DES Encrypt",
// "DES Decrypt",
// "Triple DES Encrypt",
// "Triple DES Decrypt",
// "RC2 Encrypt",
// "RC2 Decrypt",
// "RC4",
// "RC4 Drop",
"ROT13",
"ROT47",
// "XOR",
// "XOR Brute Force",
// "Vigenère Encode",
// "Vigenère Decode",
// "To Morse Code",
// "From Morse Code",
// "Bifid Cipher Encode",
// "Bifid Cipher Decode",
// "Affine Cipher Encode",
// "Affine Cipher Decode",
// "Atbash Cipher",
// "Substitute",
// "Derive PBKDF2 key",
// "Derive EVP key",
// "Bcrypt",
// "Scrypt",
// "Pseudo-Random Number Generator",
]
},
// {
// name: "Public Key",
// ops: [
// "Parse X.509 certificate",
// "Parse ASN.1 hex string",
// "PEM to Hex",
// "Hex to PEM",
// "Hex to Object Identifier",
// "Object Identifier to Hex",
// ]
// },
{
name: "Arithmetic / Logic",
ops: [
"Set Union",
"Set Intersection",
"Set Difference",
"Symmetric Difference",
"Cartesian Product",
"Power Set",
// "XOR",
// "XOR Brute Force",
// "OR",
// "NOT",
// "AND",
// "ADD",
// "SUB",
// "Sum",
// "Subtract",
// "Multiply",
// "Divide",
// "Mean",
// "Median",
// "Standard Deviation",
// "Bit shift left",
// "Bit shift right",
"Rotate left",
"Rotate right",
"ROT13"
]
},
// {
// name: "Networking",
// ops: [
// "HTTP request",
// "Strip HTTP headers",
// "Parse User Agent",
// "Parse IP range",
// "Parse IPv6 address",
// "Parse IPv4 header",
// "Parse URI",
// "URL Encode",
// "URL Decode",
// "Format MAC addresses",
// "Change IP format",
// "Group IP addresses",
// "Encode NetBIOS Name",
// "Decode NetBIOS Name",
// ]
// },
// {
// name: "Language",
// ops: [
// "Encode text",
// "Decode text",
// "Unescape Unicode Characters",
// ]
// },
// {
// name: "Utils",
// ops: [
// "Diff",
// "Remove whitespace",
// "Remove null bytes",
// "To Upper case",
// "To Lower case",
// "Add line numbers",
// "Remove line numbers",
// "Reverse",
// "Sort",
// "Unique",
// "Split",
// "Filter",
// "Head",
// "Tail",
// "Count occurrences",
// "Expand alphabet range",
// "Drop bytes",
// "Take bytes",
// "Pad lines",
// "Find / Replace",
// "Regular expression",
// "Offset checker",
// "Hamming Distance",
// "Convert distance",
// "Convert area",
// "Convert mass",
// "Convert speed",
// "Convert data units",
// "Parse UNIX file permissions",
// "Swap endianness",
// "Parse colour code",
// "Escape string",
// "Unescape string",
// "Pseudo-Random Number Generator",
// "Sleep",
// ]
// },
// {
// name: "Date / Time",
// ops: [
// "Parse DateTime",
// "Translate DateTime Format",
// "From UNIX Timestamp",
// "To UNIX Timestamp",
// "Windows Filetime to UNIX Timestamp",
// "UNIX Timestamp to Windows Filetime",
// "Extract dates",
// "Sleep",
// ]
// },
// {
// name: "Extractors",
// ops: [
// "Strings",
// "Extract IP addresses",
// "Extract email addresses",
// "Extract MAC addresses",
// "Extract URLs",
// "Extract domains",
// "Extract file paths",
// "Extract dates",
// "Regular expression",
// "XPath expression",
// "JPath expression",
// "CSS selector",
// "Extract EXIF",
// ]
// },
{
name: "Compression",
ops: [
"Raw Deflate",
"Raw Inflate",
"Zlib Deflate",
"Zlib Inflate",
"Gzip",
"Gunzip",
"Zip",
"Unzip",
// "Bzip2 Decompress",
// "Tar",
// "Untar",
]
},
// {
// name: "Hashing",
// ops: [
// "Analyse hash",
// "Generate all hashes",
// "MD2",
// "MD4",
// "MD5",
// "MD6",
// "SHA0",
// "SHA1",
// "SHA2",
// "SHA3",
// "Keccak",
// "Shake",
// "RIPEMD",
// "HAS-160",
// "Whirlpool",
// "Snefru",
// "SSDEEP",
// "CTPH",
// "Compare SSDEEP hashes",
// "Compare CTPH hashes",
// "HMAC",
// "Bcrypt",
// "Bcrypt compare",
// "Bcrypt parse",
// "Scrypt",
// "Fletcher-8 Checksum",
// "Fletcher-16 Checksum",
// "Fletcher-32 Checksum",
// "Fletcher-64 Checksum",
// "Adler-32 Checksum",
// "CRC-16 Checksum",
// "CRC-32 Checksum",
// "TCP/IP Checksum",
// ]
// },
// {
// name: "Code tidy",
// ops: [
// "Syntax highlighter",
// "Generic Code Beautify",
// "JavaScript Parser",
// "JavaScript Beautify",
// "JavaScript Minify",
// "JSON Beautify",
// "JSON Minify",
// "XML Beautify",
// "XML Minify",
// "SQL Beautify",
// "SQL Minify",
// "CSS Beautify",
// "CSS Minify",
// "XPath expression",
// "JPath expression",
// "CSS selector",
// "PHP Deserialize",
// "Microsoft Script Decoder",
// "Strip HTML tags",
// "Diff",
// "To Snake case",
// "To Camel case",
// "To Kebab case",
// "BSON serialise",
// "BSON deserialise",
// ]
// },
// {
// name: "Other",
// ops: [
// "Entropy",
// "Frequency distribution",
// "Chi Square",
// "Detect File Type",
// "Scan for Embedded Files",
// "Disassemble x86",
// "Pseudo-Random Number Generator",
// "Generate UUID",
// "Generate TOTP",
// "Generate HOTP",
// "Render Image",
// "Remove EXIF",
// "Extract EXIF",
// "Numberwang",
// "XKCD Random Number",
// ]
// },
// {
// name: "Flow control",
// ops: [
// "Fork",
// "Merge",
// "Register",
// "Label",
// "Jump",
// "Conditional Jump",
// "Return",
// "Comment"
// ]
// },
];
export default Categories;

345
src/core/config/Categories.json Executable file
View File

@ -0,0 +1,345 @@
[
{
"name": "Favourites",
"ops": []
},
{
"name": "Data format",
"ops": [
"To Hexdump",
"From Hexdump",
"To Hex",
"From Hex",
"To Charcode",
"From Charcode",
"To Decimal",
"From Decimal",
"To Binary",
"From Binary",
"To Octal",
"From Octal",
"To Base64",
"From Base64",
"Show Base64 offsets",
"To Base32",
"From Base32",
"To Base58",
"From Base58",
"To Base",
"From Base",
"To BCD",
"From BCD",
"To HTML Entity",
"From HTML Entity",
"URL Encode",
"URL Decode",
"Escape Unicode Characters",
"Unescape Unicode Characters",
"To Quoted Printable",
"From Quoted Printable",
"To Punycode",
"From Punycode",
"To Hex Content",
"From Hex Content",
"PEM to Hex",
"Hex to PEM",
"Parse ASN.1 hex string",
"Change IP format",
"Encode text",
"Decode text",
"Swap endianness"
]
},
{
"name": "Encryption / Encoding",
"ops": [
"AES Encrypt",
"AES Decrypt",
"Blowfish Encrypt",
"Blowfish Decrypt",
"DES Encrypt",
"DES Decrypt",
"Triple DES Encrypt",
"Triple DES Decrypt",
"RC2 Encrypt",
"RC2 Decrypt",
"RC4",
"RC4 Drop",
"ROT13",
"ROT47",
"XOR",
"XOR Brute Force",
"Vigenère Encode",
"Vigenère Decode",
"To Morse Code",
"From Morse Code",
"Bifid Cipher Encode",
"Bifid Cipher Decode",
"Affine Cipher Encode",
"Affine Cipher Decode",
"Atbash Cipher",
"Substitute",
"Derive PBKDF2 key",
"Derive EVP key",
"Bcrypt",
"Scrypt",
"Pseudo-Random Number Generator"
]
},
{
"name": "Public Key",
"ops": [
"Parse X.509 certificate",
"Parse ASN.1 hex string",
"PEM to Hex",
"Hex to PEM",
"Hex to Object Identifier",
"Object Identifier to Hex"
]
},
{
"name": "Arithmetic / Logic",
"ops": [
"Set Union",
"Set Intersection",
"Set Difference",
"Symmetric Difference",
"Cartesian Product",
"Power Set",
"XOR",
"XOR Brute Force",
"OR",
"NOT",
"AND",
"ADD",
"SUB",
"Sum",
"Subtract",
"Multiply",
"Divide",
"Mean",
"Median",
"Standard Deviation",
"Bit shift left",
"Bit shift right",
"Rotate left",
"Rotate right",
"ROT13"
]
},
{
"name": "Networking",
"ops": [
"HTTP request",
"Strip HTTP headers",
"Parse User Agent",
"Parse IP range",
"Parse IPv6 address",
"Parse IPv4 header",
"Parse URI",
"URL Encode",
"URL Decode",
"Format MAC addresses",
"Change IP format",
"Group IP addresses",
"Encode NetBIOS Name",
"Decode NetBIOS Name"
]
},
{
"name": "Language",
"ops": [
"Encode text",
"Decode text",
"Unescape Unicode Characters"
]
},
{
"name": "Utils",
"ops": [
"Diff",
"Remove whitespace",
"Remove null bytes",
"To Upper case",
"To Lower case",
"Add line numbers",
"Remove line numbers",
"Reverse",
"Sort",
"Unique",
"Split",
"Filter",
"Head",
"Tail",
"Count occurrences",
"Expand alphabet range",
"Drop bytes",
"Take bytes",
"Pad lines",
"Find / Replace",
"Regular expression",
"Offset checker",
"Hamming Distance",
"Convert distance",
"Convert area",
"Convert mass",
"Convert speed",
"Convert data units",
"Parse UNIX file permissions",
"Swap endianness",
"Parse colour code",
"Escape string",
"Unescape string",
"Pseudo-Random Number Generator",
"Sleep"
]
},
{
"name": "Date / Time",
"ops": [
"Parse DateTime",
"Translate DateTime Format",
"From UNIX Timestamp",
"To UNIX Timestamp",
"Windows Filetime to UNIX Timestamp",
"UNIX Timestamp to Windows Filetime",
"Extract dates",
"Sleep"
]
},
{
"name": "Extractors",
"ops": [
"Strings",
"Extract IP addresses",
"Extract email addresses",
"Extract MAC addresses",
"Extract URLs",
"Extract domains",
"Extract file paths",
"Extract dates",
"Regular expression",
"XPath expression",
"JPath expression",
"CSS selector",
"Extract EXIF"
]
},
{
"name": "Compression",
"ops": [
"Raw Deflate",
"Raw Inflate",
"Zlib Deflate",
"Zlib Inflate",
"Gzip",
"Gunzip",
"Zip",
"Unzip",
"Bzip2 Decompress",
"Tar",
"Untar"
]
},
{
"name": "Hashing",
"ops": [
"Analyse hash",
"Generate all hashes",
"MD2",
"MD4",
"MD5",
"MD6",
"SHA0",
"SHA1",
"SHA2",
"SHA3",
"Keccak",
"Shake",
"RIPEMD",
"HAS-160",
"Whirlpool",
"Snefru",
"SSDEEP",
"CTPH",
"Compare SSDEEP hashes",
"Compare CTPH hashes",
"HMAC",
"Bcrypt",
"Bcrypt compare",
"Bcrypt parse",
"Scrypt",
"Fletcher-8 Checksum",
"Fletcher-16 Checksum",
"Fletcher-32 Checksum",
"Fletcher-64 Checksum",
"Adler-32 Checksum",
"CRC-16 Checksum",
"CRC-32 Checksum",
"TCP/IP Checksum"
]
},
{
"name": "Code tidy",
"ops": [
"Syntax highlighter",
"Generic Code Beautify",
"JavaScript Parser",
"JavaScript Beautify",
"JavaScript Minify",
"JSON Beautify",
"JSON Minify",
"XML Beautify",
"XML Minify",
"SQL Beautify",
"SQL Minify",
"CSS Beautify",
"CSS Minify",
"XPath expression",
"JPath expression",
"CSS selector",
"PHP Deserialize",
"Microsoft Script Decoder",
"Strip HTML tags",
"Diff",
"To Snake case",
"To Camel case",
"To Kebab case",
"BSON serialise",
"BSON deserialise"
]
},
{
"name": "Other",
"ops": [
"Entropy",
"Frequency distribution",
"Chi Square",
"Detect File Type",
"Scan for Embedded Files",
"Disassemble x86",
"Pseudo-Random Number Generator",
"Generate UUID",
"Generate TOTP",
"Generate HOTP",
"Render Image",
"Remove EXIF",
"Extract EXIF",
"Numberwang",
"XKCD Random Number"
]
},
{
"name": "Flow control",
"ops": [
"Fork",
"Merge",
"Register",
"Label",
"Jump",
"Conditional Jump",
"Return",
"Comment"
]
}
]

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,156 @@
/**
* @author n1474335 [n1474335@gmail.com]
* @copyright Crown Copyright 2016
* @license Apache-2.0
*/
import Operation from "../Operation";
import {fromHex} from "../lib/Hex";
/**
* From Hexdump operation
*/
class FromHexdump extends Operation {
/**
* FromHexdump constructor
*/
constructor() {
super();
this.name = "From Hexdump";
this.module = "Default";
this.description = "Attempts to convert a hexdump back into raw data. This operation supports many different hexdump variations, but probably not all. Make sure you verify that the data it gives you is correct before continuing analysis.";
this.inputType = "string";
this.outputType = "byteArray";
this.args = [];
}
/**
* @param {string} input
* @param {Object[]} args
* @returns {byteArray}
*/
run(input, args) {
const output = [],
regex = /^\s*(?:[\dA-F]{4,16}h?:?)?\s*((?:[\dA-F]{2}\s){1,8}(?:\s|[\dA-F]{2}-)(?:[\dA-F]{2}\s){1,8}|(?:[\dA-F]{2}\s|[\dA-F]{4}\s)+)/igm;
let block, line;
while ((block = regex.exec(input))) {
line = fromHex(block[1].replace(/-/g, " "));
for (let i = 0; i < line.length; i++) {
output.push(line[i]);
}
}
// Is this a CyberChef hexdump or is it from a different tool?
const width = input.indexOf("\n");
const w = (width - 13) / 4;
// w should be the specified width of the hexdump and therefore a round number
if (Math.floor(w) !== w || input.indexOf("\r") !== -1 || output.indexOf(13) !== -1) {
if (ENVIRONMENT_IS_WORKER()) self.setOption("attemptHighlight", false);
}
return output;
}
/**
* Highlight From Hexdump
*
* @param {Object[]} pos
* @param {number} pos[].start
* @param {number} pos[].end
* @param {Object[]} args
* @returns {Object[]} pos
*/
highlight(pos, args) {
const w = args[0] || 16;
const width = 14 + (w*4);
let line = Math.floor(pos[0].start / width);
let offset = pos[0].start % width;
if (offset < 10) { // In line number section
pos[0].start = line*w;
} else if (offset > 10+(w*3)) { // In ASCII section
pos[0].start = (line+1)*w;
} else { // In byte section
pos[0].start = line*w + Math.floor((offset-10)/3);
}
line = Math.floor(pos[0].end / width);
offset = pos[0].end % width;
if (offset < 10) { // In line number section
pos[0].end = line*w;
} else if (offset > 10+(w*3)) { // In ASCII section
pos[0].end = (line+1)*w;
} else { // In byte section
pos[0].end = line*w + Math.ceil((offset-10)/3);
}
return pos;
}
/**
* Highlight From Hexdump in reverse
*
* @param {Object[]} pos
* @param {number} pos[].start
* @param {number} pos[].end
* @param {Object[]} args
* @returns {Object[]} pos
*/
highlightReverse(pos, args) {
// Calculate overall selection
const w = args[0] || 16,
width = 14 + (w*4);
let line = Math.floor(pos[0].start / w),
offset = pos[0].start % w,
start = 0,
end = 0;
pos[0].start = line*width + 10 + offset*3;
line = Math.floor(pos[0].end / w);
offset = pos[0].end % w;
if (offset === 0) {
line--;
offset = w;
}
pos[0].end = line*width + 10 + offset*3 - 1;
// Set up multiple selections for bytes
let startLineNum = Math.floor(pos[0].start / width);
const endLineNum = Math.floor(pos[0].end / width);
if (startLineNum === endLineNum) {
pos.push(pos[0]);
} else {
start = pos[0].start;
end = (startLineNum+1) * width - w - 5;
pos.push({ start: start, end: end });
while (end < pos[0].end) {
startLineNum++;
start = startLineNum * width + 10;
end = (startLineNum+1) * width - w - 5;
if (end > pos[0].end) end = pos[0].end;
pos.push({ start: start, end: end });
}
}
// Set up multiple selections for ASCII
const len = pos.length;
let lineNum = 0;
start = 0;
end = 0;
for (let i = 1; i < len; i++) {
lineNum = Math.floor(pos[i].start / width);
start = (((pos[i].start - (lineNum * width)) - 10) / 3) + (width - w -2) + (lineNum * width);
end = (((pos[i].end + 1 - (lineNum * width)) - 10) / 3) + (width - w -2) + (lineNum * width);
pos.push({ start: start, end: end });
}
return pos;
}
}
export default FromHexdump;

View File

@ -0,0 +1,183 @@
/**
* @author n1474335 [n1474335@gmail.com]
* @copyright Crown Copyright 2016
* @license Apache-2.0
*/
import Operation from "../Operation";
import Utils from "../Utils";
/**
* To Hexdump operation
*/
class ToHexdump extends Operation {
/**
* ToHexdump constructor
*/
constructor() {
super();
this.name = "To Hexdump";
this.module = "Default";
this.description = "Creates a hexdump of the input data, displaying both the hexadecimal values of each byte and an ASCII representation alongside.";
this.inputType = "ArrayBuffer";
this.outputType = "string";
this.args = [
{
"name": "Width",
"type": "number",
"value": 16
},
{
"name": "Upper case hex",
"type": "boolean",
"value": false
},
{
"name": "Include final length",
"type": "boolean",
"value": false
}
];
}
/**
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {string}
*/
run(input, args) {
const data = new Uint8Array(input);
const [length, upperCase, includeFinalLength] = args;
const padding = 2;
let output = "";
for (let i = 0; i < data.length; i += length) {
const buff = data.slice(i, i+length);
let hexa = "";
for (let j = 0; j < buff.length; j++) {
hexa += Utils.hex(buff[j], padding) + " ";
}
let lineNo = Utils.hex(i, 8);
if (upperCase) {
hexa = hexa.toUpperCase();
lineNo = lineNo.toUpperCase();
}
output += lineNo + " " +
hexa.padEnd(length*(padding+1), " ") +
" |" + Utils.printable(Utils.byteArrayToChars(buff)).padEnd(buff.length, " ") + "|\n";
if (includeFinalLength && i+buff.length === data.length) {
output += Utils.hex(i+buff.length, 8) + "\n";
}
}
return output.slice(0, -1);
}
/**
* Highlight To Hexdump
*
* @param {Object[]} pos
* @param {number} pos[].start
* @param {number} pos[].end
* @param {Object[]} args
* @returns {Object[]} pos
*/
highlight(pos, args) {
// Calculate overall selection
const w = args[0] || 16,
width = 14 + (w*4);
let line = Math.floor(pos[0].start / w),
offset = pos[0].start % w,
start = 0,
end = 0;
pos[0].start = line*width + 10 + offset*3;
line = Math.floor(pos[0].end / w);
offset = pos[0].end % w;
if (offset === 0) {
line--;
offset = w;
}
pos[0].end = line*width + 10 + offset*3 - 1;
// Set up multiple selections for bytes
let startLineNum = Math.floor(pos[0].start / width);
const endLineNum = Math.floor(pos[0].end / width);
if (startLineNum === endLineNum) {
pos.push(pos[0]);
} else {
start = pos[0].start;
end = (startLineNum+1) * width - w - 5;
pos.push({ start: start, end: end });
while (end < pos[0].end) {
startLineNum++;
start = startLineNum * width + 10;
end = (startLineNum+1) * width - w - 5;
if (end > pos[0].end) end = pos[0].end;
pos.push({ start: start, end: end });
}
}
// Set up multiple selections for ASCII
const len = pos.length;
let lineNum = 0;
start = 0;
end = 0;
for (let i = 1; i < len; i++) {
lineNum = Math.floor(pos[i].start / width);
start = (((pos[i].start - (lineNum * width)) - 10) / 3) + (width - w -2) + (lineNum * width);
end = (((pos[i].end + 1 - (lineNum * width)) - 10) / 3) + (width - w -2) + (lineNum * width);
pos.push({ start: start, end: end });
}
return pos;
}
/**
* Highlight To Hexdump in reverse
*
* @param {Object[]} pos
* @param {number} pos[].start
* @param {number} pos[].end
* @param {Object[]} args
* @returns {Object[]} pos
*/
highlightReverse(pos, args) {
const w = args[0] || 16;
const width = 14 + (w*4);
let line = Math.floor(pos[0].start / width);
let offset = pos[0].start % width;
if (offset < 10) { // In line number section
pos[0].start = line*w;
} else if (offset > 10+(w*3)) { // In ASCII section
pos[0].start = (line+1)*w;
} else { // In byte section
pos[0].start = line*w + Math.floor((offset-10)/3);
}
line = Math.floor(pos[0].end / width);
offset = pos[0].end % width;
if (offset < 10) { // In line number section
pos[0].end = line*w;
} else if (offset > 10+(w*3)) { // In ASCII section
pos[0].end = (line+1)*w;
} else { // In byte section
pos[0].end = line*w + Math.ceil((offset-10)/3);
}
return pos;
}
}
export default ToHexdump;

View File

@ -199,8 +199,13 @@ App.prototype.populateOperationsList = function() {
cat = new HTMLCategory(catConf.name, selected);
for (let j = 0; j < catConf.ops.length; j++) {
const opName = catConf.ops[j],
op = new HTMLOperation(opName, this.operations[opName], this, this.manager);
const opName = catConf.ops[j];
if (!this.operations.hasOwnProperty(opName)) {
log.warn(`${opName} could not be found.`);
continue;
}
const op = new HTMLOperation(opName, this.operations[opName], this, this.manager);
cat.addOperation(op);
}

View File

@ -17,7 +17,7 @@ import CanvasComponents from "../core/vendor/canvascomponents.js";
// CyberChef
import App from "./App.js";
import Categories from "../core/config/Categories.js";
import Categories from "../core/config/Categories.json";
import OperationConfig from "../core/config/OperationConfig.json";

View File

@ -47,9 +47,10 @@ module.exports = {
new WebpackSyncShellPlugin({
onBuildStart: {
scripts: [
"echo \n--- Generating config files. ---",
"node --experimental-modules src/core/config/scripts/generateOpsIndex.mjs",
"node --experimental-modules src/core/config/scripts/generateConfig.mjs",
"echo ---\nConfig scripts finished.\n---\n"
"echo --- Config scripts finished. ---\n"
],
blocking: true,
parallel: false