mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-21 15:26:16 -04:00
Merge branch 'master' into io-overhaul
This commit is contained in:
commit
2785459257
38 changed files with 1703 additions and 29 deletions
61
src/core/operations/CaesarBoxCipher.mjs
Normal file
61
src/core/operations/CaesarBoxCipher.mjs
Normal file
|
@ -0,0 +1,61 @@
|
|||
/**
|
||||
* @author n1073645 [n1073645@gmail.com]
|
||||
* @copyright Crown Copyright 2020
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation.mjs";
|
||||
|
||||
/**
|
||||
* Caesar Box Cipher operation
|
||||
*/
|
||||
class CaesarBoxCipher extends Operation {
|
||||
|
||||
/**
|
||||
* CaesarBoxCipher constructor
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.name = "Caesar Box Cipher";
|
||||
this.module = "Ciphers";
|
||||
this.description = "Caesar Box is a transposition cipher used in the Roman Empire, in which letters of the message are written in rows in a square (or a rectangle) and then, read by column.";
|
||||
this.infoURL = "https://www.dcode.fr/caesar-box-cipher";
|
||||
this.inputType = "string";
|
||||
this.outputType = "string";
|
||||
this.args = [
|
||||
{
|
||||
name: "Box Height",
|
||||
type: "number",
|
||||
value: 1
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
run(input, args) {
|
||||
const tableHeight = args[0];
|
||||
const tableWidth = Math.ceil(input.length / tableHeight);
|
||||
while (input.indexOf(" ") !== -1)
|
||||
input = input.replace(" ", "");
|
||||
for (let i = 0; i < (tableHeight * tableWidth) - input.length; i++) {
|
||||
input += "\x00";
|
||||
}
|
||||
let result = "";
|
||||
for (let i = 0; i < tableHeight; i++) {
|
||||
for (let j = i; j < input.length; j += tableHeight) {
|
||||
if (input.charAt(j) !== "\x00") {
|
||||
result += input.charAt(j);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default CaesarBoxCipher;
|
63
src/core/operations/CetaceanCipherDecode.mjs
Normal file
63
src/core/operations/CetaceanCipherDecode.mjs
Normal file
|
@ -0,0 +1,63 @@
|
|||
/**
|
||||
* @author dolphinOnKeys [robin@weird.io]
|
||||
* @copyright Crown Copyright 2022
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation.mjs";
|
||||
|
||||
/**
|
||||
* Cetacean Cipher Decode operation
|
||||
*/
|
||||
class CetaceanCipherDecode extends Operation {
|
||||
|
||||
/**
|
||||
* CetaceanCipherDecode constructor
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.name = "Cetacean Cipher Decode";
|
||||
this.module = "Ciphers";
|
||||
this.description = "Decode Cetacean Cipher input. <br/><br/>e.g. <code>EEEEEEEEEeeEeEEEEEEEEEEEEeeEeEEe</code> becomes <code>hi</code>";
|
||||
this.infoURL = "https://hitchhikers.fandom.com/wiki/Dolphins";
|
||||
this.inputType = "string";
|
||||
this.outputType = "string";
|
||||
|
||||
this.checks = [
|
||||
{
|
||||
pattern: "^(?:[eE]{16,})(?: [eE]{16,})*$",
|
||||
flags: "",
|
||||
args: []
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
run(input, args) {
|
||||
const binaryArray = [];
|
||||
for (const char of input) {
|
||||
if (char === " ") {
|
||||
binaryArray.push(...[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]);
|
||||
} else {
|
||||
binaryArray.push(char === "e" ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
const byteArray = [];
|
||||
|
||||
for (let i = 0; i < binaryArray.length; i += 16) {
|
||||
byteArray.push(binaryArray.slice(i, i + 16).join(""));
|
||||
}
|
||||
|
||||
return byteArray.map(byte =>
|
||||
String.fromCharCode(parseInt(byte, 2))
|
||||
).join("");
|
||||
}
|
||||
}
|
||||
|
||||
export default CetaceanCipherDecode;
|
51
src/core/operations/CetaceanCipherEncode.mjs
Normal file
51
src/core/operations/CetaceanCipherEncode.mjs
Normal file
|
@ -0,0 +1,51 @@
|
|||
/**
|
||||
* @author dolphinOnKeys [robin@weird.io]
|
||||
* @copyright Crown Copyright 2022
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation.mjs";
|
||||
import {toBinary} from "../lib/Binary.mjs";
|
||||
|
||||
/**
|
||||
* Cetacean Cipher Encode operation
|
||||
*/
|
||||
class CetaceanCipherEncode extends Operation {
|
||||
|
||||
/**
|
||||
* CetaceanCipherEncode constructor
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.name = "Cetacean Cipher Encode";
|
||||
this.module = "Ciphers";
|
||||
this.description = "Converts any input into Cetacean Cipher. <br/><br/>e.g. <code>hi</code> becomes <code>EEEEEEEEEeeEeEEEEEEEEEEEEeeEeEEe</code>";
|
||||
this.infoURL = "https://hitchhikers.fandom.com/wiki/Dolphins";
|
||||
this.inputType = "string";
|
||||
this.outputType = "string";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
run(input, args) {
|
||||
const result = [];
|
||||
const charArray = input.split("");
|
||||
|
||||
charArray.map(character => {
|
||||
if (character === " ") {
|
||||
result.push(character);
|
||||
} else {
|
||||
const binaryArray = toBinary(character.charCodeAt(0), "None", 16).split("");
|
||||
result.push(binaryArray.map(str => str === "1" ? "e" : "E").join(""));
|
||||
}
|
||||
});
|
||||
|
||||
return result.join("");
|
||||
}
|
||||
}
|
||||
|
||||
export default CetaceanCipherEncode;
|
|
@ -38,7 +38,7 @@ class ExtractFiles extends Operation {
|
|||
<li>
|
||||
${supportedExts.join("</li><li>")}
|
||||
</li>
|
||||
</ul>`;
|
||||
</ul>Minimum File Size can be used to prune small false positives.`;
|
||||
this.infoURL = "https://forensicswiki.xyz/wiki/index.php?title=File_Carving";
|
||||
this.inputType = "ArrayBuffer";
|
||||
this.outputType = "List<File>";
|
||||
|
@ -54,6 +54,11 @@ class ExtractFiles extends Operation {
|
|||
name: "Ignore failed extractions",
|
||||
type: "boolean",
|
||||
value: true
|
||||
},
|
||||
{
|
||||
name: "Minimum File Size",
|
||||
type: "number",
|
||||
value: 100
|
||||
}
|
||||
]);
|
||||
}
|
||||
|
@ -66,6 +71,7 @@ class ExtractFiles extends Operation {
|
|||
run(input, args) {
|
||||
const bytes = new Uint8Array(input),
|
||||
categories = [],
|
||||
minSize = args.pop(1),
|
||||
ignoreFailedExtractions = args.pop(1);
|
||||
|
||||
args.forEach((cat, i) => {
|
||||
|
@ -80,7 +86,9 @@ class ExtractFiles extends Operation {
|
|||
const errors = [];
|
||||
detectedFiles.forEach(detectedFile => {
|
||||
try {
|
||||
files.push(extractFile(bytes, detectedFile.fileDetails, detectedFile.offset));
|
||||
const file = extractFile(bytes, detectedFile.fileDetails, detectedFile.offset);
|
||||
if (file.size >= minSize)
|
||||
files.push(file);
|
||||
} catch (err) {
|
||||
if (!ignoreFailedExtractions && err.message.indexOf("No extraction algorithm available") < 0) {
|
||||
errors.push(
|
||||
|
|
|
@ -65,12 +65,21 @@ class Fork extends Operation {
|
|||
if (input)
|
||||
inputs = input.split(splitDelim);
|
||||
|
||||
// Set to 1 as if we are here, then there is one, the current one.
|
||||
let numOp = 1;
|
||||
// Create subOpList for each tranche to operate on
|
||||
// (all remaining operations unless we encounter a Merge)
|
||||
// all remaining operations unless we encounter a Merge
|
||||
for (i = state.progress + 1; i < opList.length; i++) {
|
||||
if (opList[i].name === "Merge" && !opList[i].disabled) {
|
||||
break;
|
||||
numOp--;
|
||||
if (numOp === 0 || opList[i].ingValues[0])
|
||||
break;
|
||||
else
|
||||
// Not this Fork's Merge.
|
||||
subOpList.push(opList[i]);
|
||||
} else {
|
||||
if (opList[i].name === "Fork" || opList[i].name === "Subsection")
|
||||
numOp++;
|
||||
subOpList.push(opList[i]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,12 @@ class FromBase45 extends Operation {
|
|||
name: "Alphabet",
|
||||
type: "string",
|
||||
value: ALPHABET
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "Remove non-alphabet chars",
|
||||
type: "boolean",
|
||||
value: true
|
||||
},
|
||||
];
|
||||
|
||||
this.highlight = highlightFromBase45;
|
||||
|
@ -46,10 +51,17 @@ class FromBase45 extends Operation {
|
|||
*/
|
||||
run(input, args) {
|
||||
if (!input) return [];
|
||||
const alphabet = Utils.expandAlphRange(args[0]);
|
||||
const alphabet = Utils.expandAlphRange(args[0]).join("");
|
||||
const removeNonAlphChars = args[1];
|
||||
|
||||
const res = [];
|
||||
|
||||
// Remove non-alphabet characters
|
||||
if (removeNonAlphChars) {
|
||||
const re = new RegExp("[^" + alphabet.replace(/[[\]\\\-^$]/g, "\\$&") + "]", "g");
|
||||
input = input.replace(re, "");
|
||||
}
|
||||
|
||||
for (const triple of Utils.chunked(input, 3)) {
|
||||
triple.reverse();
|
||||
let b = 0;
|
||||
|
|
|
@ -32,6 +32,40 @@ class FromBase85 extends Operation {
|
|||
type: "editableOption",
|
||||
value: ALPHABET_OPTIONS
|
||||
},
|
||||
{
|
||||
name: "Remove non-alphabet chars",
|
||||
type: "boolean",
|
||||
value: true
|
||||
},
|
||||
];
|
||||
this.checks = [
|
||||
{
|
||||
pattern:
|
||||
"^\\s*(?:<~)?" + // Optional whitespace and starting marker
|
||||
"[\\s!-uz]*" + // Any amount of base85 characters and whitespace
|
||||
"[!-uz]{15}" + // At least 15 continoues base85 characters without whitespace
|
||||
"[\\s!-uz]*" + // Any amount of base85 characters and whitespace
|
||||
"(?:~>)?\\s*$", // Optional ending marker and whitespace
|
||||
args: ["!-u"],
|
||||
},
|
||||
{
|
||||
pattern:
|
||||
"^" +
|
||||
"[\\s0-9a-zA-Z.\\-:+=^!/*?&<>()[\\]{}@%$#]*" +
|
||||
"[0-9a-zA-Z.\\-:+=^!/*?&<>()[\\]{}@%$#]{15}" + // At least 15 continoues base85 characters without whitespace
|
||||
"[\\s0-9a-zA-Z.\\-:+=^!/*?&<>()[\\]{}@%$#]*" +
|
||||
"$",
|
||||
args: ["0-9a-zA-Z.\\-:+=^!/*?&<>()[]{}@%$#"],
|
||||
},
|
||||
{
|
||||
pattern:
|
||||
"^" +
|
||||
"[\\s0-9A-Za-z!#$%&()*+\\-;<=>?@^_`{|}~]*" +
|
||||
"[0-9A-Za-z!#$%&()*+\\-;<=>?@^_`{|}~]{15}" + // At least 15 continoues base85 characters without whitespace
|
||||
"[\\s0-9A-Za-z!#$%&()*+\\-;<=>?@^_`{|}~]*" +
|
||||
"$",
|
||||
args: ["0-9A-Za-z!#$%&()*+\\-;<=>?@^_`{|}~"],
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -43,6 +77,7 @@ class FromBase85 extends Operation {
|
|||
run(input, args) {
|
||||
const alphabet = Utils.expandAlphRange(args[0]).join(""),
|
||||
encoding = alphabetName(alphabet),
|
||||
removeNonAlphChars = args[1],
|
||||
result = [];
|
||||
|
||||
if (alphabet.length !== 85 ||
|
||||
|
@ -50,11 +85,18 @@ class FromBase85 extends Operation {
|
|||
throw new OperationError("Alphabet must be of length 85");
|
||||
}
|
||||
|
||||
if (input.length === 0) return [];
|
||||
|
||||
const matches = input.match(/<~(.+?)~>/);
|
||||
// Remove delimiters if present
|
||||
const matches = input.match(/^<~(.+?)~>$/);
|
||||
if (matches !== null) input = matches[1];
|
||||
|
||||
// Remove non-alphabet characters
|
||||
if (removeNonAlphChars) {
|
||||
const re = new RegExp("[^" + alphabet.replace(/[[\]\\\-^$]/g, "\\$&") + "]", "g");
|
||||
input = input.replace(re, "");
|
||||
}
|
||||
|
||||
if (input.length === 0) return [];
|
||||
|
||||
let i = 0;
|
||||
let block, blockBytes;
|
||||
while (i < input.length) {
|
||||
|
@ -69,7 +111,7 @@ class FromBase85 extends Operation {
|
|||
.map((chr, idx) => {
|
||||
const digit = alphabet.indexOf(chr);
|
||||
if (digit < 0 || digit > 84) {
|
||||
throw `Invalid character '${chr}' at index ${idx}`;
|
||||
throw `Invalid character '${chr}' at index ${i + idx}`;
|
||||
}
|
||||
return digit;
|
||||
});
|
||||
|
|
57
src/core/operations/LS47Decrypt.mjs
Normal file
57
src/core/operations/LS47Decrypt.mjs
Normal file
|
@ -0,0 +1,57 @@
|
|||
/**
|
||||
* @author n1073645 [n1073645@gmail.com]
|
||||
* @copyright Crown Copyright 2020
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation.mjs";
|
||||
import * as LS47 from "../lib/LS47.mjs";
|
||||
|
||||
/**
|
||||
* LS47 Decrypt operation
|
||||
*/
|
||||
class LS47Decrypt extends Operation {
|
||||
|
||||
/**
|
||||
* LS47Decrypt constructor
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.name = "LS47 Decrypt";
|
||||
this.module = "Crypto";
|
||||
this.description = "This is a slight improvement of the ElsieFour cipher as described by Alan Kaminsky. We use 7x7 characters instead of original (barely fitting) 6x6, to be able to encrypt some structured information. We also describe a simple key-expansion algorithm, because remembering passwords is popular. Similar security considerations as with ElsieFour hold.<br>The LS47 alphabet consists of following characters: <code>_abcdefghijklmnopqrstuvwxyz.0123456789,-+*/:?!'()</code><br>An LS47 key is a permutation of the alphabet that is then represented in a 7x7 grid used for the encryption or decryption.";
|
||||
this.infoURL = "https://github.com/exaexa/ls47";
|
||||
this.inputType = "string";
|
||||
this.outputType = "string";
|
||||
this.args = [
|
||||
{
|
||||
name: "Password",
|
||||
type: "string",
|
||||
value: ""
|
||||
},
|
||||
{
|
||||
name: "Padding",
|
||||
type: "number",
|
||||
value: 10
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
run(input, args) {
|
||||
this.paddingSize = parseInt(args[1], 10);
|
||||
|
||||
LS47.initTiles();
|
||||
|
||||
const key = LS47.deriveKey(args[0]);
|
||||
return LS47.decryptPad(key, input, this.paddingSize);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default LS47Decrypt;
|
62
src/core/operations/LS47Encrypt.mjs
Normal file
62
src/core/operations/LS47Encrypt.mjs
Normal file
|
@ -0,0 +1,62 @@
|
|||
/**
|
||||
* @author n1073645 [n1073645@gmail.com]
|
||||
* @copyright Crown Copyright 2020
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation.mjs";
|
||||
import * as LS47 from "../lib/LS47.mjs";
|
||||
|
||||
/**
|
||||
* LS47 Encrypt operation
|
||||
*/
|
||||
class LS47Encrypt extends Operation {
|
||||
|
||||
/**
|
||||
* LS47Encrypt constructor
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.name = "LS47 Encrypt";
|
||||
this.module = "Crypto";
|
||||
this.description = "This is a slight improvement of the ElsieFour cipher as described by Alan Kaminsky. We use 7x7 characters instead of original (barely fitting) 6x6, to be able to encrypt some structured information. We also describe a simple key-expansion algorithm, because remembering passwords is popular. Similar security considerations as with ElsieFour hold.<br>The LS47 alphabet consists of following characters: <code>_abcdefghijklmnopqrstuvwxyz.0123456789,-+*/:?!'()</code><br>A LS47 key is a permutation of the alphabet that is then represented in a 7x7 grid used for the encryption or decryption.";
|
||||
this.infoURL = "https://github.com/exaexa/ls47";
|
||||
this.inputType = "string";
|
||||
this.outputType = "string";
|
||||
this.args = [
|
||||
{
|
||||
name: "Password",
|
||||
type: "string",
|
||||
value: ""
|
||||
},
|
||||
{
|
||||
name: "Padding",
|
||||
type: "number",
|
||||
value: 10
|
||||
},
|
||||
{
|
||||
name: "Signature",
|
||||
type: "string",
|
||||
value: ""
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
run(input, args) {
|
||||
this.paddingSize = parseInt(args[1], 10);
|
||||
|
||||
LS47.initTiles();
|
||||
|
||||
const key = LS47.deriveKey(args[0]);
|
||||
return LS47.encryptPad(key, input, args[2], this.paddingSize);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default LS47Encrypt;
|
55
src/core/operations/LZStringCompress.mjs
Normal file
55
src/core/operations/LZStringCompress.mjs
Normal file
|
@ -0,0 +1,55 @@
|
|||
/**
|
||||
* @author crespyl [peter@crespyl.net]
|
||||
* @copyright Peter Jacobs 2021
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation.mjs";
|
||||
import OperationError from "../errors/OperationError.mjs";
|
||||
|
||||
import {COMPRESSION_OUTPUT_FORMATS, COMPRESSION_FUNCTIONS} from "../lib/LZString.mjs";
|
||||
|
||||
/**
|
||||
* LZString Compress operation
|
||||
*/
|
||||
class LZStringCompress extends Operation {
|
||||
|
||||
/**
|
||||
* LZStringCompress constructor
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.name = "LZString Compress";
|
||||
this.module = "Compression";
|
||||
this.description = "Compress the input with lz-string.";
|
||||
this.infoURL = "https://pieroxy.net/blog/pages/lz-string/index.html";
|
||||
this.inputType = "string";
|
||||
this.outputType = "string";
|
||||
this.args = [
|
||||
{
|
||||
name: "Compression Format",
|
||||
type: "option",
|
||||
defaultIndex: 0,
|
||||
value: COMPRESSION_OUTPUT_FORMATS
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
run(input, args) {
|
||||
const compress = COMPRESSION_FUNCTIONS[args[0]];
|
||||
if (compress) {
|
||||
return compress(input);
|
||||
} else {
|
||||
throw new OperationError("Unable to find compression function");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default LZStringCompress;
|
56
src/core/operations/LZStringDecompress.mjs
Normal file
56
src/core/operations/LZStringDecompress.mjs
Normal file
|
@ -0,0 +1,56 @@
|
|||
/**
|
||||
* @author crespyl [peter@crespyl.net]
|
||||
* @copyright Peter Jacobs 2021
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation.mjs";
|
||||
import OperationError from "../errors/OperationError.mjs";
|
||||
|
||||
import {COMPRESSION_OUTPUT_FORMATS, DECOMPRESSION_FUNCTIONS} from "../lib/LZString.mjs";
|
||||
|
||||
/**
|
||||
* LZString Decompress operation
|
||||
*/
|
||||
class LZStringDecompress extends Operation {
|
||||
|
||||
/**
|
||||
* LZStringDecompress constructor
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.name = "LZString Decompress";
|
||||
this.module = "Compression";
|
||||
this.description = "Decompresses data that was compressed with lz-string.";
|
||||
this.infoURL = "https://pieroxy.net/blog/pages/lz-string/index.html";
|
||||
this.inputType = "string";
|
||||
this.outputType = "string";
|
||||
this.args = [
|
||||
{
|
||||
name: "Compression Format",
|
||||
type: "option",
|
||||
defaultIndex: 0,
|
||||
value: COMPRESSION_OUTPUT_FORMATS
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
run(input, args) {
|
||||
const decompress = DECOMPRESSION_FUNCTIONS[args[0]];
|
||||
if (decompress) {
|
||||
return decompress(input);
|
||||
} else {
|
||||
throw new OperationError("Unable to find decompression function");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
export default LZStringDecompress;
|
|
@ -20,10 +20,16 @@ class Merge extends Operation {
|
|||
this.name = "Merge";
|
||||
this.flowControl = true;
|
||||
this.module = "Default";
|
||||
this.description = "Consolidate all branches back into a single trunk. The opposite of Fork.";
|
||||
this.description = "Consolidate all branches back into a single trunk. The opposite of Fork. Unticking the Merge All checkbox will only consolidate all branches up to the nearest Fork/Subsection.";
|
||||
this.inputType = "string";
|
||||
this.outputType = "string";
|
||||
this.args = [];
|
||||
this.args = [
|
||||
{
|
||||
name: "Merge All",
|
||||
type: "boolean",
|
||||
value: true,
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
133
src/core/operations/PLISTViewer.mjs
Normal file
133
src/core/operations/PLISTViewer.mjs
Normal file
|
@ -0,0 +1,133 @@
|
|||
/**
|
||||
* @author n1073645 [n1073645@gmail.com]
|
||||
* @copyright Crown Copyright 2019
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation.mjs";
|
||||
|
||||
/**
|
||||
* P-list Viewer operation
|
||||
*/
|
||||
class PlistViewer extends Operation {
|
||||
|
||||
/**
|
||||
* PlistViewer constructor
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.name = "P-list Viewer";
|
||||
this.module = "Default";
|
||||
this.description = "In the macOS, iOS, NeXTSTEP, and GNUstep programming frameworks, property list files are files that store serialized objects. Property list files use the filename extension .plist, and thus are often referred to as p-list files.<br><br>This operation displays plist files in a human readable format.";
|
||||
this.infoURL = "https://wikipedia.org/wiki/Property_list";
|
||||
this.inputType = "string";
|
||||
this.outputType = "string";
|
||||
this.args = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
run(input, args) {
|
||||
|
||||
// Regexes are designed to transform the xml format into a more readable string format.
|
||||
input = input.slice(input.indexOf("<plist"))
|
||||
.replace(/<plist.+>/g, "plist => ")
|
||||
.replace(/<dict>/g, "{")
|
||||
.replace(/<\/dict>/g, "}")
|
||||
.replace(/<array>/g, "[")
|
||||
.replace(/<\/array>/g, "]")
|
||||
.replace(/<key>.+<\/key>/g, m => `${m.slice(5, m.indexOf(/<\/key>/g)-5)}\t=> `)
|
||||
.replace(/<real>.+<\/real>/g, m => `${m.slice(6, m.indexOf(/<\/real>/g)-6)}\n`)
|
||||
.replace(/<string>.+<\/string>/g, m => `"${m.slice(8, m.indexOf(/<\/string>/g)-8)}"\n`)
|
||||
.replace(/<integer>.+<\/integer>/g, m => `${m.slice(9, m.indexOf(/<\/integer>/g)-9)}\n`)
|
||||
.replace(/<false\/>/g, m => "false")
|
||||
.replace(/<true\/>/g, m => "true")
|
||||
.replace(/<\/plist>/g, "/plist")
|
||||
.replace(/<date>.+<\/date>/g, m => `${m.slice(6, m.indexOf(/<\/integer>/g)-6)}`)
|
||||
.replace(/<data>(\s|.)+?<\/data>/g, m => `${m.slice(6, m.indexOf(/<\/data>/g)-6)}`)
|
||||
.replace(/[ \t\r\f\v]/g, "");
|
||||
|
||||
/**
|
||||
* Depending on the type of brace, it will increment the depth and amount of arrays accordingly.
|
||||
*
|
||||
* @param {string} elem
|
||||
* @param {array} vals
|
||||
* @param {number} offset
|
||||
*/
|
||||
function braces(elem, vals, offset) {
|
||||
const temp = vals.indexOf(elem);
|
||||
if (temp !== -1) {
|
||||
depthCount += offset;
|
||||
if (temp === 1)
|
||||
arrCount += offset;
|
||||
}
|
||||
}
|
||||
|
||||
let result = "";
|
||||
let arrCount = 0;
|
||||
let depthCount = 0;
|
||||
|
||||
/**
|
||||
* Formats the input after the regex has replaced all of the relevant parts.
|
||||
*
|
||||
* @param {array} input
|
||||
* @param {number} index
|
||||
*/
|
||||
function printIt(input, index) {
|
||||
if (!(input.length))
|
||||
return;
|
||||
|
||||
let temp = "";
|
||||
const origArr = arrCount;
|
||||
let currElem = input[0];
|
||||
|
||||
// If the current position points at a larger dynamic structure.
|
||||
if (currElem.indexOf("=>") !== -1) {
|
||||
|
||||
// If the LHS also points at a larger structure (nested plists in a dictionary).
|
||||
if (input[1].indexOf("=>") !== -1)
|
||||
temp = currElem.slice(0, -2) + " => " + input[1].slice(0, -2) + " =>\n";
|
||||
else
|
||||
temp = currElem.slice(0, -2) + " => " + input[1] + "\n";
|
||||
|
||||
input = input.slice(1);
|
||||
} else {
|
||||
// Controls the tab depth for how many closing braces there have been.
|
||||
|
||||
braces(currElem, ["}", "]"], -1);
|
||||
|
||||
// Has to be here since the formatting breaks otherwise.
|
||||
temp = currElem + "\n";
|
||||
}
|
||||
|
||||
currElem = input[0];
|
||||
|
||||
// Tab out to the correct distance.
|
||||
result += ("\t".repeat(depthCount));
|
||||
|
||||
// If it is enclosed in an array show index.
|
||||
if (arrCount > 0 && currElem !== "]")
|
||||
result += index.toString() + " => ";
|
||||
|
||||
result += temp;
|
||||
|
||||
// Controls the tab depth for how many opening braces there have been.
|
||||
braces(currElem, ["{", "["], 1);
|
||||
|
||||
// If there has been a new array then reset index.
|
||||
if (arrCount > origArr)
|
||||
return printIt(input.slice(1), 0);
|
||||
return printIt(input.slice(1), ++index);
|
||||
}
|
||||
|
||||
input = input.split("\n").filter(e => e !== "");
|
||||
printIt(input, 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
export default PlistViewer;
|
102
src/core/operations/ROT13BruteForce.mjs
Normal file
102
src/core/operations/ROT13BruteForce.mjs
Normal file
|
@ -0,0 +1,102 @@
|
|||
/**
|
||||
* @author MikeCAT
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation.mjs";
|
||||
import Utils from "../Utils.mjs";
|
||||
|
||||
/**
|
||||
* ROT13 Brute Force operation.
|
||||
*/
|
||||
class ROT13BruteForce extends Operation {
|
||||
|
||||
/**
|
||||
* ROT13BruteForce constructor
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.name = "ROT13 Brute Force";
|
||||
this.module = "Default";
|
||||
this.description = "Try all meaningful amounts for ROT13.<br><br>Optionally you can enter your known plaintext (crib) to filter the result.";
|
||||
this.infoURL = "https://wikipedia.org/wiki/ROT13";
|
||||
this.inputType = "byteArray";
|
||||
this.outputType = "string";
|
||||
this.args = [
|
||||
{
|
||||
name: "Rotate lower case chars",
|
||||
type: "boolean",
|
||||
value: true
|
||||
},
|
||||
{
|
||||
name: "Rotate upper case chars",
|
||||
type: "boolean",
|
||||
value: true
|
||||
},
|
||||
{
|
||||
name: "Rotate numbers",
|
||||
type: "boolean",
|
||||
value: false
|
||||
},
|
||||
{
|
||||
name: "Sample length",
|
||||
type: "number",
|
||||
value: 100
|
||||
},
|
||||
{
|
||||
name: "Sample offset",
|
||||
type: "number",
|
||||
value: 0
|
||||
},
|
||||
{
|
||||
name: "Print amount",
|
||||
type: "boolean",
|
||||
value: true
|
||||
},
|
||||
{
|
||||
name: "Crib (known plaintext string)",
|
||||
type: "string",
|
||||
value: ""
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {byteArray} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
run(input, args) {
|
||||
const [rotateLower, rotateUpper, rotateNum, sampleLength, sampleOffset, printAmount, crib] = args;
|
||||
const sample = input.slice(sampleOffset, sampleOffset + sampleLength);
|
||||
const cribLower = crib.toLowerCase();
|
||||
const lowerStart = "a".charCodeAt(0), upperStart = "A".charCodeAt(0), numStart = "0".charCodeAt(0);
|
||||
const result = [];
|
||||
for (let amount = 1; amount < 26; amount++) {
|
||||
const rotated = sample.slice();
|
||||
for (let i = 0; i < rotated.length; i++) {
|
||||
if (rotateLower && lowerStart <= rotated[i] && rotated[i] < lowerStart + 26) {
|
||||
rotated[i] = (rotated[i] - lowerStart + amount) % 26 + lowerStart;
|
||||
} else if (rotateUpper && upperStart <= rotated[i] && rotated[i] < upperStart + 26) {
|
||||
rotated[i] = (rotated[i] - upperStart + amount) % 26 + upperStart;
|
||||
} else if (rotateNum && numStart <= rotated[i] && rotated[i] < numStart + 10) {
|
||||
rotated[i] = (rotated[i] - numStart + amount) % 10 + numStart;
|
||||
}
|
||||
}
|
||||
const rotatedString = Utils.byteArrayToUtf8(rotated);
|
||||
if (rotatedString.toLowerCase().indexOf(cribLower) >= 0) {
|
||||
const rotatedStringPrintable = Utils.printable(rotatedString, false);
|
||||
if (printAmount) {
|
||||
const amountStr = "Amount = " + (" " + amount).slice(-2) + ": ";
|
||||
result.push(amountStr + rotatedStringPrintable);
|
||||
} else {
|
||||
result.push(rotatedStringPrintable);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.join("\n");
|
||||
}
|
||||
}
|
||||
|
||||
export default ROT13BruteForce;
|
82
src/core/operations/ROT47BruteForce.mjs
Normal file
82
src/core/operations/ROT47BruteForce.mjs
Normal file
|
@ -0,0 +1,82 @@
|
|||
/**
|
||||
* @author MikeCAT
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation.mjs";
|
||||
import Utils from "../Utils.mjs";
|
||||
|
||||
/**
|
||||
* ROT47 Brute Force operation.
|
||||
*/
|
||||
class ROT47BruteForce extends Operation {
|
||||
|
||||
/**
|
||||
* ROT47BruteForce constructor
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.name = "ROT47 Brute Force";
|
||||
this.module = "Default";
|
||||
this.description = "Try all meaningful amounts for ROT47.<br><br>Optionally you can enter your known plaintext (crib) to filter the result.";
|
||||
this.infoURL = "https://wikipedia.org/wiki/ROT13#Variants";
|
||||
this.inputType = "byteArray";
|
||||
this.outputType = "string";
|
||||
this.args = [
|
||||
{
|
||||
name: "Sample length",
|
||||
type: "number",
|
||||
value: 100
|
||||
},
|
||||
{
|
||||
name: "Sample offset",
|
||||
type: "number",
|
||||
value: 0
|
||||
},
|
||||
{
|
||||
name: "Print amount",
|
||||
type: "boolean",
|
||||
value: true
|
||||
},
|
||||
{
|
||||
name: "Crib (known plaintext string)",
|
||||
type: "string",
|
||||
value: ""
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {byteArray} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
run(input, args) {
|
||||
const [sampleLength, sampleOffset, printAmount, crib] = args;
|
||||
const sample = input.slice(sampleOffset, sampleOffset + sampleLength);
|
||||
const cribLower = crib.toLowerCase();
|
||||
const result = [];
|
||||
for (let amount = 1; amount < 94; amount++) {
|
||||
const rotated = sample.slice();
|
||||
for (let i = 0; i < rotated.length; i++) {
|
||||
if (33 <= rotated[i] && rotated[i] <= 126) {
|
||||
rotated[i] = (rotated[i] - 33 + amount) % 94 + 33;
|
||||
}
|
||||
}
|
||||
const rotatedString = Utils.byteArrayToUtf8(rotated);
|
||||
if (rotatedString.toLowerCase().indexOf(cribLower) >= 0) {
|
||||
const rotatedStringPrintable = Utils.printable(rotatedString, false);
|
||||
if (printAmount) {
|
||||
const amountStr = "Amount = " + (" " + amount).slice(-2) + ": ";
|
||||
result.push(amountStr + rotatedStringPrintable);
|
||||
} else {
|
||||
result.push(rotatedStringPrintable);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.join("\n");
|
||||
}
|
||||
}
|
||||
|
||||
export default ROT47BruteForce;
|
123
src/core/operations/ROT8000.mjs
Normal file
123
src/core/operations/ROT8000.mjs
Normal file
|
@ -0,0 +1,123 @@
|
|||
/**
|
||||
* @author Daniel Temkin [http://danieltemkin.com]
|
||||
* @author Thomas Leplus [https://www.leplus.org]
|
||||
* @copyright Crown Copyright 2021
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation.mjs";
|
||||
|
||||
/**
|
||||
* ROT8000 operation.
|
||||
*/
|
||||
class ROT8000 extends Operation {
|
||||
|
||||
/**
|
||||
* ROT8000 constructor
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
this.name = "ROT8000";
|
||||
this.module = "Default";
|
||||
this.description = "The simple Caesar-cypher encryption that replaces each Unicode character with the one 0x8000 places forward or back along the alphabet.";
|
||||
this.infoURL = "https://rot8000.com/info";
|
||||
this.inputType = "string";
|
||||
this.outputType = "string";
|
||||
this.args = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {byteArray} input
|
||||
* @param {Object[]} args
|
||||
* @returns {byteArray}
|
||||
*/
|
||||
run(input, args) {
|
||||
// Inspired from https://github.com/rottytooth/rot8000/blob/main/rot8000.js
|
||||
// these come from the valid-code-point-transitions.json file generated from the c# proj
|
||||
// this is done bc: 1) don't trust JS's understanging of surrogate pairs and 2) consistency with original rot8000
|
||||
const validCodePoints = {
|
||||
"33": true,
|
||||
"127": false,
|
||||
"161": true,
|
||||
"5760": false,
|
||||
"5761": true,
|
||||
"8192": false,
|
||||
"8203": true,
|
||||
"8232": false,
|
||||
"8234": true,
|
||||
"8239": false,
|
||||
"8240": true,
|
||||
"8287": false,
|
||||
"8288": true,
|
||||
"12288": false,
|
||||
"12289": true,
|
||||
"55296": false,
|
||||
"57344": true
|
||||
};
|
||||
const bmpSize = 0x10000;
|
||||
const rotList = {}; // the mapping of char to rotated char
|
||||
const hiddenBlocks = [];
|
||||
let startBlock = 0;
|
||||
for (const key in validCodePoints) {
|
||||
if (Object.prototype.hasOwnProperty.call(validCodePoints, key)) {
|
||||
if (validCodePoints[key] === true)
|
||||
hiddenBlocks.push({ start: startBlock, end: parseInt(key, 10) - 1 });
|
||||
else
|
||||
startBlock = parseInt(key, 10);
|
||||
}
|
||||
}
|
||||
const validIntList = []; // list of all valid chars
|
||||
let currValid = false;
|
||||
for (let i = 0; i < bmpSize; i++) {
|
||||
if (validCodePoints[i] !== undefined) {
|
||||
currValid = validCodePoints[i];
|
||||
}
|
||||
if (currValid) validIntList.push(i);
|
||||
}
|
||||
const rotateNum = Object.keys(validIntList).length / 2;
|
||||
// go through every valid char and find its match
|
||||
for (let i = 0; i < validIntList.length; i++) {
|
||||
rotList[String.fromCharCode(validIntList[i])] =
|
||||
String.fromCharCode(validIntList[(i + rotateNum) % (rotateNum * 2)]);
|
||||
}
|
||||
let output = "";
|
||||
for (let count = 0; count < input.length; count++) {
|
||||
// if it is not in the mappings list, just add it directly (no rotation)
|
||||
if (rotList[input[count]] === undefined) {
|
||||
output += input[count];
|
||||
continue;
|
||||
}
|
||||
// otherwise, rotate it and add it to the string
|
||||
output += rotList[input[count]];
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Highlight ROT8000
|
||||
*
|
||||
* @param {Object[]} pos
|
||||
* @param {number} pos[].start
|
||||
* @param {number} pos[].end
|
||||
* @param {Object[]} args
|
||||
* @returns {Object[]} pos
|
||||
*/
|
||||
highlight(pos, args) {
|
||||
return pos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Highlight ROT8000 in reverse
|
||||
*
|
||||
* @param {Object[]} pos
|
||||
* @param {number} pos[].start
|
||||
* @param {number} pos[].end
|
||||
* @param {Object[]} args
|
||||
* @returns {Object[]} pos
|
||||
*/
|
||||
highlightReverse(pos, args) {
|
||||
return pos;
|
||||
}
|
||||
}
|
||||
|
||||
export default ROT8000;
|
|
@ -22,7 +22,7 @@ class Subsection extends Operation {
|
|||
this.name = "Subsection";
|
||||
this.flowControl = true;
|
||||
this.module = "Default";
|
||||
this.description = "Select a part of the input data using a regular expression (regex), and run all subsequent operations on each match separately.<br><br>You can use up to one capture group, where the recipe will only be run on the data in the capture group. If there's more than one capture group, only the first one will be operated on.";
|
||||
this.description = "Select a part of the input data using a regular expression (regex), and run all subsequent operations on each match separately.<br><br>You can use up to one capture group, where the recipe will only be run on the data in the capture group. If there's more than one capture group, only the first one will be operated on.<br><br>Use the Merge operation to reset the effects of subsection.";
|
||||
this.infoURL = "";
|
||||
this.inputType = "string";
|
||||
this.outputType = "string";
|
||||
|
@ -67,12 +67,21 @@ class Subsection extends Operation {
|
|||
subOpList = [];
|
||||
|
||||
if (input && section !== "") {
|
||||
// Set to 1 as if we are here, then there is one, the current one.
|
||||
let numOp = 1;
|
||||
// Create subOpList for each tranche to operate on
|
||||
// all remaining operations unless we encounter a Merge
|
||||
for (let i = state.progress + 1; i < opList.length; i++) {
|
||||
if (opList[i].name === "Merge" && !opList[i].disabled) {
|
||||
break;
|
||||
numOp--;
|
||||
if (numOp === 0 || opList[i].ingValues[0])
|
||||
break;
|
||||
else
|
||||
// Not this subsection's Merge.
|
||||
subOpList.push(opList[i]);
|
||||
} else {
|
||||
if (opList[i].name === "Fork" || opList[i].name === "Subsection")
|
||||
numOp++;
|
||||
subOpList.push(opList[i]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue