Added Bcrypt, Scrypt, BSON and string operations along with many new tests.

This commit is contained in:
n1474335 2018-03-26 22:25:36 +01:00
parent 2f5b0533d8
commit 715ca1c292
28 changed files with 1290 additions and 84 deletions

View file

@ -131,7 +131,7 @@ module.exports = function (grunt) {
grunt.initConfig({
clean: {
dev: ["build/dev/*", "src/core/config/MetaConfig.js"],
dev: ["build/dev/*"],
prod: ["build/prod/*", "src/core/config/MetaConfig.js"],
test: ["build/test/*", "src/core/config/MetaConfig.js"],
node: ["build/node/*", "src/core/config/MetaConfig.js"],

30
package-lock.json generated
View file

@ -519,6 +519,14 @@
"lodash": "4.17.5",
"source-map": "0.5.7",
"trim-right": "1.0.1"
},
"dependencies": {
"jsesc": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/jsesc/-/jsesc-1.3.0.tgz",
"integrity": "sha1-RsP+yMGJKxKwgz25vHYiF226s0s=",
"dev": true
}
}
},
"babel-helper-builder-binary-assignment-operator-visitor": {
@ -1161,6 +1169,11 @@
"tweetnacl": "0.14.5"
}
},
"bcryptjs": {
"version": "2.4.3",
"resolved": "https://registry.npmjs.org/bcryptjs/-/bcryptjs-2.4.3.tgz",
"integrity": "sha1-mrVie5PmBiH/fNrF2pczAn3x0Ms="
},
"big.js": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/big.js/-/big.js-3.2.0.tgz",
@ -1440,6 +1453,11 @@
}
}
},
"bson": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/bson/-/bson-2.0.4.tgz",
"integrity": "sha512-e/GPy6CE0xL7MOYYRMIEwPGKF21WNaQdPIpV0YvaQDoR7oc47KUZ8c2P/TlRJVQP8RZ4CEsArGBC1NbkCRvl1w=="
},
"buffer": {
"version": "4.9.1",
"resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz",
@ -6877,10 +6895,9 @@
}
},
"jsesc": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/jsesc/-/jsesc-1.3.0.tgz",
"integrity": "sha1-RsP+yMGJKxKwgz25vHYiF226s0s=",
"dev": true
"version": "2.5.1",
"resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.1.tgz",
"integrity": "sha1-5CGiqOINawgZ3yiQj3glJrlt0f4="
},
"jshint": {
"version": "2.9.5",
@ -10473,6 +10490,11 @@
"ajv": "5.2.3"
}
},
"scryptsy": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/scryptsy/-/scryptsy-2.0.0.tgz",
"integrity": "sha1-Jiw28CMc+nZU4jY/o5TNLexm83g="
},
"select-hose": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/select-hose/-/select-hose-2.0.0.tgz",

View file

@ -70,10 +70,12 @@
},
"dependencies": {
"babel-polyfill": "^6.26.0",
"bcryptjs": "^2.4.3",
"bignumber.js": "^6.0.0",
"bootstrap": "^3.3.7",
"bootstrap-colorpicker": "^2.5.2",
"bootstrap-switch": "^3.3.4",
"bson": "^2.0.4",
"crypto-api": "^0.8.0",
"crypto-js": "^3.1.9-1",
"ctph.js": "0.0.5",
@ -88,6 +90,7 @@
"js-crc": "^0.2.0",
"js-sha3": "^0.7.0",
"jsbn": "^1.1.0",
"jsesc": "^2.5.1",
"jsonpath": "^1.0.0",
"jsrsasign": "8.0.6",
"lodash": "^4.17.5",
@ -99,6 +102,7 @@
"node-md6": "^0.1.0",
"nwmatcher": "^1.4.3",
"otp": "^0.1.3",
"scryptsy": "^2.0.0",
"sladex-blowfish": "^0.8.1",
"sortablejs": "^1.7.0",
"split.js": "^1.3.5",

View file

@ -1,4 +1,5 @@
import utf8 from "utf8";
import moment from "moment-timezone";
/**
@ -201,21 +202,34 @@ const Utils = {
* Utils.parseEscapedChars("\\n");
*/
parseEscapedChars: function(str) {
return str.replace(/(\\)?\\([nrtbf]|x[\da-fA-F]{2})/g, function(m, a, b) {
return str.replace(/(\\)?\\([bfnrtv0'"]|x[\da-fA-F]{2}|u[\da-fA-F]{4}|u\{[\da-fA-F]{1,6}\})/g, function(m, a, b) {
if (a === "\\") return "\\"+b;
switch (b[0]) {
case "n":
return "\n";
case "r":
return "\r";
case "t":
return "\t";
case "0":
return "\0";
case "b":
return "\b";
case "t":
return "\t";
case "n":
return "\n";
case "v":
return "\v";
case "f":
return "\f";
case "r":
return "\r";
case '"':
return '"';
case "'":
return "'";
case "x":
return Utils.chr(parseInt(b.substr(1), 16));
return String.fromCharCode(parseInt(b.substr(1), 16));
case "u":
if (b[1] === "{")
return String.fromCodePoint(parseInt(b.slice(2, -1), 16));
else
return String.fromCharCode(parseInt(b.substr(1), 16));
}
});
},
@ -322,14 +336,14 @@ const Utils = {
* @returns {string}
*
* @example
* // returns [208, 159, 209, 128, 208, 184, 208, 178, 208, 181, 209, 130]
* Utils.convertToByteArray("Привет", "utf8");
* // returns "Привет"
* Utils.convertToByteString("Привет", "utf8");
*
* // returns [208, 159, 209, 128, 208, 184, 208, 178, 208, 181, 209, 130]
* Utils.convertToByteArray("d097d0b4d180d0b0d0b2d181d182d0b2d183d0b9d182d0b5", "hex");
* // returns "Здравствуйте"
* Utils.convertToByteString("d097d0b4d180d0b0d0b2d181d182d0b2d183d0b9d182d0b5", "hex");
*
* // returns [208, 159, 209, 128, 208, 184, 208, 178, 208, 181, 209, 130]
* Utils.convertToByteArray("0JfQtNGA0LDQstGB0YLQstGD0LnRgtC1", "base64");
* // returns "Здравствуйте"
* Utils.convertToByteString("0JfQtNGA0LDQstGB0YLQstGD0LnRgtC1", "base64");
*/
convertToByteString: function(str, type) {
switch (type.toLowerCase()) {

View file

@ -52,6 +52,7 @@ const Categories = [
"From HTML Entity",
"URL Encode",
"URL Decode",
"Escape Unicode Characters",
"Unescape Unicode Characters",
"To Quoted Printable",
"From Quoted Printable",
@ -99,6 +100,8 @@ const Categories = [
"Substitute",
"Derive PBKDF2 key",
"Derive EVP key",
"Bcrypt",
"Scrypt",
"Pseudo-Random Number Generator",
]
},
@ -275,6 +278,10 @@ const Categories = [
"Compare SSDEEP hashes",
"Compare CTPH hashes",
"HMAC",
"Bcrypt",
"Bcrypt compare",
"Bcrypt parse",
"Scrypt",
"Fletcher-8 Checksum",
"Fletcher-16 Checksum",
"Fletcher-32 Checksum",
@ -311,6 +318,8 @@ const Categories = [
"To Snake case",
"To Camel case",
"To Kebab case",
"BSON serialise",
"BSON deserialise",
]
},
{

View file

@ -912,6 +912,34 @@ const OperationConfig = {
}
]
},
"Escape Unicode Characters": {
module: "Default",
description: "Converts characters to their unicode-escaped notations.<br><br>Supports the prefixes:<ul><li><code>\\u</code></li><li><code>%u</code></li><li><code>U+</code></li></ul>e.g. <code>σου</code> becomes <code>\\u03C3\\u03BF\\u03C5</code>",
inputType: "string",
outputType: "string",
args: [
{
name: "Prefix",
type: "option",
value: Unicode.PREFIXES
},
{
name: "Encode all chars",
type: "boolean",
value: false
},
{
name: "Padding",
type: "number",
value: 4
},
{
name: "Uppercase hex",
type: "boolean",
value: true
}
]
},
"From Quoted Printable": {
module: "Default",
description: "Converts QP-encoded text back to standard text.",
@ -2417,7 +2445,7 @@ const OperationConfig = {
},
"From UNIX Timestamp": {
module: "Default",
description: "Converts a UNIX timestamp to a datetime string.<br><br>e.g. <code>978346800</code> becomes <code>Mon 1 January 2001 11:00:00 UTC</code><br><br>A UNIX timestamp is a 32-bit value representing the number of seconds since January 1, 1970 UTC (the UNIX epoch).<br><br>Note that this operation supports various date formats including the US 'MM/DD/YYYY' format, but not the international 'DD/MM/YYYY' format. For dates in this format, use the 'Translate DateTime format' operation instead.",
description: "Converts a UNIX timestamp to a datetime string.<br><br>e.g. <code>978346800</code> becomes <code>Mon 1 January 2001 11:00:00 UTC</code><br><br>A UNIX timestamp is a 32-bit value representing the number of seconds since January 1, 1970 UTC (the UNIX epoch).",
inputType: "number",
outputType: "string",
args: [
@ -2432,7 +2460,7 @@ const OperationConfig = {
module: "Default",
description: "Parses a datetime string in UTC and returns the corresponding UNIX timestamp.<br><br>e.g. <code>Mon 1 January 2001 11:00:00</code> becomes <code>978346800</code><br><br>A UNIX timestamp is a 32-bit value representing the number of seconds since January 1, 1970 UTC (the UNIX epoch).",
inputType: "string",
outputType: "number",
outputType: "string",
args: [
{
name: "Units",
@ -2443,6 +2471,11 @@ const OperationConfig = {
name: "Treat as UTC",
type: "boolean",
value: DateTime.TREAT_AS_UTC
},
{
name: "Show parsed datetime",
type: "boolean",
value: true
}
]
},
@ -3554,14 +3587,40 @@ const OperationConfig = {
},
"Escape string": {
module: "Default",
description: "Escapes special characters in a string so that they do not cause conflicts. For example, <code>Don't stop me now</code> becomes <code>Don\\'t stop me now</code>.<br><br>Supports the following escape sequences:<ul><li><code>\\n</code> (Line feed/newline)</li><li><code>\\r</code> (Carriage return)</li><li><code>\\t</code> (Horizontal tab)</li><li><code>\\b</code> (Backspace)</li><li><code>\\f</code> (Form feed)</li><li><code>\\xnn</code> (Hex, where n is 0-f)</li><li><code>\\\\</code> (Backslash)</li><li><code>\\'</code> (Single quote)</li><li><code>\\&quot;</code> (Double quote)</li></ul>",
description: "Escapes special characters in a string so that they do not cause conflicts. For example, <code>Don't stop me now</code> becomes <code>Don\\'t stop me now</code>.<br><br>Supports the following escape sequences:<ul><li><code>\\n</code> (Line feed/newline)</li><li><code>\\r</code> (Carriage return)</li><li><code>\\t</code> (Horizontal tab)</li><li><code>\\b</code> (Backspace)</li><li><code>\\f</code> (Form feed)</li><li><code>\\xnn</code> (Hex, where n is 0-f)</li><li><code>\\\\</code> (Backslash)</li><li><code>\\'</code> (Single quote)</li><li><code>\\&quot;</code> (Double quote)</li><li><code>\\unnnn</code> (Unicode character)</li><li><code>\\u{nnnnnn}</code> (Unicode code point)</li></ul>",
inputType: "string",
outputType: "string",
args: []
args: [
{
name: "Escape level",
type: "option",
value: StrUtils.ESCAPE_LEVEL
},
{
name: "Escape quote",
type: "option",
value: StrUtils.QUOTE_TYPES
},
{
name: "JSON compatible",
type: "boolean",
value: false
},
{
name: "ES6 compatible",
type: "boolean",
value: true
},
{
name: "Uppercase hex",
type: "boolean",
value: false
}
]
},
"Unescape string": {
module: "Default",
description: "Unescapes characters in a string that have been escaped. For example, <code>Don\\'t stop me now</code> becomes <code>Don't stop me now</code>.<br><br>Supports the following escape sequences:<ul><li><code>\\n</code> (Line feed/newline)</li><li><code>\\r</code> (Carriage return)</li><li><code>\\t</code> (Horizontal tab)</li><li><code>\\b</code> (Backspace)</li><li><code>\\f</code> (Form feed)</li><li><code>\\xnn</code> (Hex, where n is 0-f)</li><li><code>\\\\</code> (Backslash)</li><li><code>\\'</code> (Single quote)</li><li><code>\\&quot;</code> (Double quote)</li></ul>",
description: "Unescapes characters in a string that have been escaped. For example, <code>Don\\'t stop me now</code> becomes <code>Don't stop me now</code>.<br><br>Supports the following escape sequences:<ul><li><code>\\n</code> (Line feed/newline)</li><li><code>\\r</code> (Carriage return)</li><li><code>\\t</code> (Horizontal tab)</li><li><code>\\b</code> (Backspace)</li><li><code>\\f</code> (Form feed)</li><li><code>\\xnn</code> (Hex, where n is 0-f)</li><li><code>\\\\</code> (Backslash)</li><li><code>\\'</code> (Single quote)</li><li><code>\\&quot;</code> (Double quote)</li><li><code>\\unnnn</code> (Unicode character)</li><li><code>\\u{nnnnnn}</code> (Unicode code point)</li></ul>",
inputType: "string",
outputType: "string",
args: []
@ -4018,7 +4077,88 @@ const OperationConfig = {
inputType: "string",
outputType: "number",
args: []
}
},
"Bcrypt": {
module: "Hashing",
description: "bcrypt is a password hashing function designed by Niels Provos and David Mazières, based on the Blowfish cipher, and presented at USENIX in 1999. Besides incorporating a salt to protect against rainbow table attacks, bcrypt is an adaptive function: over time, the iteration count (rounds) can be increased to make it slower, so it remains resistant to brute-force search attacks even with increasing computation power.<br><br>Enter the password in the input to generate its hash.",
inputType: "string",
outputType: "string",
args: [
{
name: "Rounds",
type: "number",
value: Hash.BCRYPT_ROUNDS
}
]
},
"Bcrypt compare": {
module: "Hashing",
description: "Tests whether the input matches the given bcrypt hash. To test multiple possible passwords, use the 'Fork' operation.",
inputType: "string",
outputType: "string",
args: [
{
name: "Hash",
type: "string",
value: ""
}
]
},
"Bcrypt parse": {
module: "Hashing",
description: "Parses a bcrypt hash to determine the number of rounds used, the salt, and the password hash.",
inputType: "string",
outputType: "string",
args: []
},
"Scrypt": {
module: "Hashing",
description: "scrypt is a password-based key derivation function (PBKDF) created by Colin Percival. The algorithm was specifically designed to make it costly to perform large-scale custom hardware attacks by requiring large amounts of memory. In 2016, the scrypt algorithm was published by IETF as RFC 7914.<br><br>Enter the password in the input to generate its hash.",
inputType: "string",
outputType: "string",
args: [
{
name: "Salt",
type: "toggleString",
value: "",
toggleValues: Hash.KEY_FORMAT
},
{
name: "Iterations (N)",
type: "number",
value: Hash.SCRYPT_ITERATIONS
},
{
name: "Memory factor (r)",
type: "number",
value: Hash.SCRYPT_MEM_FACTOR
},
{
name: "Parallelization factor (p)",
type: "number",
value: Hash.SCRYPT_PARALLEL_FACTOR
},
{
name: "Key length",
type: "number",
value: Hash.SCRYPT_KEY_LENGTH
},
]
},
"BSON serialise": {
module: "BSON",
description: "BSON is a computer data interchange format used mainly as a data storage and network transfer format in the MongoDB database. It is a binary form for representing simple data structures, associative arrays (called objects or documents in MongoDB), and various data types of specific interest to MongoDB. The name 'BSON' is based on the term JSON and stands for 'Binary JSON'.<br><br>Input data should be valid JSON.",
inputType: "string",
outputType: "ArrayBuffer",
args: []
},
"BSON deserialise": {
module: "BSON",
description: "BSON is a computer data interchange format used mainly as a data storage and network transfer format in the MongoDB database. It is a binary form for representing simple data structures, associative arrays (called objects or documents in MongoDB), and various data types of specific interest to MongoDB. The name 'BSON' is based on the term JSON and stands for 'Binary JSON'.<br><br>Input data should be in a raw bytes format.",
inputType: "ArrayBuffer",
outputType: "string",
args: []
},
};

View file

@ -0,0 +1,22 @@
import BSON from "../../operations/BSON.js";
/**
* BSON module.
*
* Libraries:
* - bson
* - buffer
*
* @author n1474335 [n1474335@gmail.com]
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
let OpModules = typeof self === "undefined" ? {} : self.OpModules || {};
OpModules.BSON = {
"BSON serialise": BSON.runBSONSerialise,
"BSON deserialise": BSON.runBSONDeserialise,
};
export default OpModules;

View file

@ -43,6 +43,7 @@ import XKCD from "../../operations/XKCD.js";
* - otp
* - crypto
* - bignumber.js
* - jsesc
*
* @author n1474335 [n1474335@gmail.com]
* @copyright Crown Copyright 2017
@ -81,6 +82,7 @@ OpModules.Default = {
"Strip HTML tags": HTML.runStripTags,
"Parse colour code": HTML.runParseColourCode,
"Unescape Unicode Characters": Unicode.runUnescape,
"Escape Unicode Characters": Unicode.runEscape,
"To Quoted Printable": QuotedPrintable.runTo,
"From Quoted Printable": QuotedPrintable.runFrom,
"Swap endianness": Endian.runSwapEndianness,

View file

@ -39,6 +39,10 @@ OpModules.Hashing = {
"Compare CTPH hashes": Hash.runCompareCTPH,
"Compare SSDEEP hashes": Hash.runCompareSSDEEP,
"HMAC": Hash.runHMAC,
"Bcrypt": Hash.runBcrypt,
"Bcrypt compare": Hash.runBcryptCompare,
"Bcrypt parse": Hash.runBcryptParse,
"Scrypt": Hash.runScrypt,
"Fletcher-8 Checksum": Checksum.runFletcher8,
"Fletcher-16 Checksum": Checksum.runFletcher16,
"Fletcher-32 Checksum": Checksum.runFletcher32,

View file

@ -7,6 +7,7 @@
*/
import OpModules from "./Default.js";
import BSONModule from "./BSON.js";
import CharEncModule from "./CharEnc.js";
import CipherModule from "./Ciphers.js";
import CodeModule from "./Code.js";
@ -24,6 +25,7 @@ import URLModule from "./URL.js";
Object.assign(
OpModules,
BSONModule,
CharEncModule,
CipherModule,
CodeModule,

View file

@ -0,0 +1,59 @@
import bsonjs from "bson";
import {Buffer} from "buffer";
/**
* BSON operations.
*
* @author n1474335 [n1474335@gmail.com]
* @copyright Crown Copyright 2018
* @license Apache-2.0
*
* @namespace
*/
const BSON = {
/**
* BSON serialise operation.
*
* @param {string} input
* @param {Object[]} args
* @returns {ArrayBuffer}
*/
runBSONSerialise(input, args) {
if (!input) return new ArrayBuffer();
const bson = new bsonjs();
try {
const data = JSON.parse(input);
return bson.serialize(data).buffer;
} catch (err) {
return err.toString();
}
},
/**
* BSON deserialise operation.
*
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {string}
*
*/
runBSONDeserialise(input, args) {
if (!input.byteLength) return "";
const bson = new bsonjs();
try {
const data = bson.deserialize(new Buffer(input));
return JSON.stringify(data, null, 2);
} catch (err) {
return err.toString();
}
},
};
export default BSON;

View file

@ -148,6 +148,10 @@ const ByteRepr = {
throw "Error: Base argument must be between 2 and 36";
}
if (input.length === 0) {
return [];
}
if (base !== 16 && ENVIRONMENT_IS_WORKER()) self.setOption("attemptHighlight", false);
// Split into groups of 2 if the whole string is concatenated and

View file

@ -483,12 +483,11 @@ const Code = {
/**
* Converts to snake_case.
* To Snake Case operation.
*
* @param {string} input
* @param {Object[]} args
* @returns {string}
*
*/
runToSnakeCase(input, args) {
const smart = args[0];
@ -502,12 +501,11 @@ const Code = {
/**
* Converts to camelCase.
* To Camel Case operation.
*
* @param {string} input
* @param {Object[]} args
* @returns {string}
*
*/
runToCamelCase(input, args) {
const smart = args[0];
@ -521,12 +519,11 @@ const Code = {
/**
* Converts to kebab-case.
* To Kebab Case operation.
*
* @param {string} input
* @param {Object[]} args
* @returns {string}
*
*/
runToKebabCase(input, args) {
const smart = args[0];
@ -537,6 +534,7 @@ const Code = {
return kebabCase(input);
}
},
};
export default Code;

View file

@ -1,3 +1,6 @@
import moment from "moment-timezone";
/**
* Date and time operations.
*
@ -57,24 +60,29 @@ const DateTime = {
*
* @param {string} input
* @param {Object[]} args
* @returns {number}
* @returns {string}
*/
runToUnixTimestamp: function(input, args) {
let units = args[0],
const units = args[0],
treatAsUTC = args[1],
showDateTime = args[2],
d = treatAsUTC ? moment.utc(input) : moment(input);
let result = "";
if (units === "Seconds (s)") {
return d.unix();
result = d.unix();
} else if (units === "Milliseconds (ms)") {
return d.valueOf();
result = d.valueOf();
} else if (units === "Microseconds (μs)") {
return d.valueOf() * 1000;
result = d.valueOf() * 1000;
} else if (units === "Nanoseconds (ns)") {
return d.valueOf() * 1000000;
result = d.valueOf() * 1000000;
} else {
throw "Unrecognised unit";
}
return showDateTime ? `${result} (${d.tz("UTC").format("ddd D MMMM YYYY HH:mm:ss")} UTC)` : result.toString();
},

View file

@ -5,6 +5,8 @@ import * as SHA3 from "js-sha3";
import Checksum from "./Checksum.js";
import ctph from "ctph.js";
import ssdeep from "ssdeep.js";
import bcrypt from "bcryptjs";
import scrypt from "scryptsy";
/**
@ -449,6 +451,127 @@ const Hash = {
},
/**
* @constant
* @default
*/
BCRYPT_ROUNDS: 10,
/**
* Bcrypt operation.
*
* @param {string} input
* @param {Object[]} args
* @returns {string}
*/
runBcrypt: async function (input, args) {
const rounds = args[0];
const salt = await bcrypt.genSalt(rounds);
return await bcrypt.hash(input, salt, null, p => {
// Progress callback
if (ENVIRONMENT_IS_WORKER())
self.sendStatusMessage(`Progress: ${(p * 100).toFixed(0)}%`);
});
},
/**
* Bcrypt compare operation.
*
* @param {string} input
* @param {Object[]} args
* @returns {string}
*/
runBcryptCompare: async function (input, args) {
const hash = args[0];
const match = await bcrypt.compare(input, hash, null, p => {
// Progress callback
if (ENVIRONMENT_IS_WORKER())
self.sendStatusMessage(`Progress: ${(p * 100).toFixed(0)}%`);
});
return match ? "Match: " + input : "No match";
},
/**
* Bcrypt parse operation.
*
* @param {string} input
* @param {Object[]} args
* @returns {string}
*/
runBcryptParse: async function (input, args) {
try {
return `Rounds: ${bcrypt.getRounds(input)}
Salt: ${bcrypt.getSalt(input)}
Password hash: ${input.split(bcrypt.getSalt(input))[1]}
Full hash: ${input}`;
} catch (err) {
return "Error: " + err.toString();
}
},
/**
* @constant
* @default
*/
KEY_FORMAT: ["Hex", "Base64", "UTF8", "Latin1"],
/**
* @constant
* @default
*/
SCRYPT_ITERATIONS: 16384,
/**
* @constant
* @default
*/
SCRYPT_MEM_FACTOR: 8,
/**
* @constant
* @default
*/
SCRYPT_PARALLEL_FACTOR: 1,
/**
* @constant
* @default
*/
SCRYPT_KEY_LENGTH: 64,
/**
* Scrypt operation.
*
* @param {string} input
* @param {Object[]} args
* @returns {string}
*/
runScrypt: function (input, args) {
const salt = Utils.convertToByteString(args[0].string || "", args[0].option),
iterations = args[1],
memFactor = args[2],
parallelFactor = args[3],
keyLength = args[4];
try {
const data = scrypt(
input, salt, iterations, memFactor, parallelFactor, keyLength,
p => {
// Progress callback
if (ENVIRONMENT_IS_WORKER())
self.sendStatusMessage(`Progress: ${p.percent.toFixed(0)}%`);
}
);
return data.toString("hex");
} catch (err) {
return "Error: " + err.toString();
}
},
/**
* Generate all hashes operation.
*

View file

@ -78,7 +78,7 @@ const Hexdump = {
*/
runFrom: function(input, args) {
let output = [],
regex = /^\s*(?:[\dA-F]{4,16}:?)?\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,
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,
block, line;
while ((block = regex.exec(input))) {

View file

@ -1,4 +1,5 @@
import Utils from "../Utils.js";
import jsesc from "jsesc";
/**
@ -219,35 +220,45 @@ const StrUtils = {
* @constant
* @default
*/
ESCAPE_REPLACEMENTS: [
{"escaped": "\\\\", "unescaped": "\\"}, // Must be first
{"escaped": "\\'", "unescaped": "'"},
{"escaped": "\\\"", "unescaped": "\""},
{"escaped": "\\n", "unescaped": "\n"},
{"escaped": "\\r", "unescaped": "\r"},
{"escaped": "\\t", "unescaped": "\t"},
{"escaped": "\\b", "unescaped": "\b"},
{"escaped": "\\f", "unescaped": "\f"},
],
QUOTE_TYPES: ["Single", "Double", "Backtick"],
/**
* @constant
* @default
*/
ESCAPE_LEVEL: ["Special chars", "Everything", "Minimal"],
/**
* Escape string operation.
*
* @author Vel0x [dalemy@microsoft.com]
* @author n1474335 [n1474335@gmail.com]
*
* @param {string} input
* @param {Object[]} args
* @returns {string}
*
* @example
* StrUtils.runUnescape("Don't do that", [])
* StrUtils.runEscape("Don't do that", [])
* > "Don\'t do that"
* StrUtils.runUnescape(`Hello
* StrUtils.runEscape(`Hello
* World`, [])
* > "Hello\nWorld"
*/
runEscape: function(input, args) {
return StrUtils._replaceByKeys(input, "unescaped", "escaped");
const level = args[0],
quotes = args[1],
jsonCompat = args[2],
es6Compat = args[3],
lowercaseHex = !args[4];
return jsesc(input, {
quotes: quotes.toLowerCase(),
es6: es6Compat,
escapeEverything: level === "Everything",
minimal: level === "Minimal",
json: jsonCompat,
lowercaseHex: lowercaseHex,
});
},
@ -255,6 +266,7 @@ const StrUtils = {
* Unescape string operation.
*
* @author Vel0x [dalemy@microsoft.com]
* @author n1474335 [n1474335@gmail.com]
*
* @param {string} input
* @param {Object[]} args
@ -268,32 +280,7 @@ const StrUtils = {
* World`
*/
runUnescape: function(input, args) {
return StrUtils._replaceByKeys(input, "escaped", "unescaped");
},
/**
* Replaces all matching tokens in ESCAPE_REPLACEMENTS with the correction. The
* ordering is determined by the patternKey and the replacementKey.
*
* @author Vel0x [dalemy@microsoft.com]
* @author Matt C [matt@artemisbot.uk]
*
* @param {string} input
* @param {string} pattern_key
* @param {string} replacement_key
* @returns {string}
*/
_replaceByKeys: function(input, patternKey, replacementKey) {
let output = input;
// Catch the \\x encoded characters
if (patternKey === "escaped") output = Utils.parseEscapedChars(input);
StrUtils.ESCAPE_REPLACEMENTS.forEach(replacement => {
output = output.split(replacement[patternKey]).join(replacement[replacementKey]);
});
return output;
return Utils.parseEscapedChars(input);
},

View file

@ -50,6 +50,40 @@ const Unicode = {
},
/**
* Escape Unicode Characters operation.
*
* @param {string} input
* @param {Object[]} args
* @returns {string}
*/
runEscape: function(input, args) {
const regexWhitelist = /[ -~]/i,
prefix = args[0],
encodeAll = args[1],
padding = args[2],
uppercaseHex = args[3];
let output = "",
character = "";
for (let i = 0; i < input.length; i++) {
character = input[i];
if (!encodeAll && regexWhitelist.test(character)) {
// Its a printable ASCII character so dont escape it.
output += character;
continue;
}
let cp = character.codePointAt(0).toString(16);
if (uppercaseHex) cp = cp.toUpperCase();
output += prefix + cp.padStart(padding, "0");
}
return output;
},
/**
* Lookup table to add prefixes to unicode delimiters so that they can be used in a regex.
*

View file

@ -12,6 +12,7 @@ import "babel-polyfill";
import "bootstrap";
import "bootstrap-switch";
import "bootstrap-colorpicker";
import moment from "moment-timezone";
import CanvasComponents from "../core/lib/canvascomponents.js";
// CyberChef

View file

@ -14,8 +14,10 @@ import "babel-polyfill";
import TestRegister from "./TestRegister.js";
import "./tests/operations/Base58.js";
import "./tests/operations/Base64.js";
import "./tests/operations/BCD.js";
import "./tests/operations/BitwiseOp.js";
import "./tests/operations/BSON.js";
import "./tests/operations/ByteRepr.js";
import "./tests/operations/CharEnc.js";
import "./tests/operations/Cipher.js";
@ -24,6 +26,7 @@ import "./tests/operations/Compress.js";
import "./tests/operations/DateTime.js";
import "./tests/operations/FlowControl.js";
import "./tests/operations/Hash.js";
import "./tests/operations/Hexdump.js";
import "./tests/operations/Image.js";
import "./tests/operations/MorseCode.js";
import "./tests/operations/MS.js";

56
test/tests/operations/BSON.js Executable file
View file

@ -0,0 +1,56 @@
/**
* BSON tests.
*
* @author n1474335 [n1474335@gmail.com]
*
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import TestRegister from "../../TestRegister.js";
TestRegister.addTests([
{
name: "BSON serialise: nothing",
input: "",
expectedOutput: "",
recipeConfig: [
{
op: "BSON serialise",
args: [],
},
],
},
{
name: "BSON serialise: basic",
input: "{\"hello\":\"world\"}",
expectedOutput: "\x16\x00\x00\x00\x02hello\x00\x06\x00\x00\x00world\x00\x00",
recipeConfig: [
{
op: "BSON serialise",
args: [],
},
],
},
{
name: "BSON deserialise: nothing",
input: "",
expectedOutput: "",
recipeConfig: [
{
op: "BSON deserialise",
args: [],
},
],
},
{
name: "BSON deserialise: basic",
input: "\x16\x00\x00\x00\x02hello\x00\x06\x00\x00\x00world\x00\x00",
expectedOutput: "{\n \"hello\": \"world\"\n}",
recipeConfig: [
{
op: "BSON deserialise",
args: [],
},
],
},
]);

View file

@ -0,0 +1,119 @@
/**
* Base64 tests.
*
* @author n1474335 [n1474335@gmail.com]
*
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import TestRegister from "../../TestRegister.js";
const ALL_BYTES = [
"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
"\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f",
"\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f",
"\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f",
"\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f",
"\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f",
"\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f",
"\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f",
"\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f",
"\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf",
"\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf",
"\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf",
"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf",
"\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef",
"\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
].join("");
TestRegister.addTests([
{
name: "To Base64: nothing",
input: "",
expectedOutput: "",
recipeConfig: [
{
op: "To Base64",
args: ["A-Za-z0-9+/="],
},
],
},
{
name: "To Base64: Hello, World!",
input: "Hello, World!",
expectedOutput: "SGVsbG8sIFdvcmxkIQ==",
recipeConfig: [
{
op: "To Base64",
args: ["A-Za-z0-9+/="],
},
],
},
{
name: "To Base64: UTF-8",
input: "ნუ პანიკას",
expectedOutput: "4YOc4YOjIOGDnuGDkOGDnOGDmOGDmeGDkOGDoQ==",
recipeConfig: [
{
op: "To Base64",
args: ["A-Za-z0-9+/="],
},
],
},
{
name: "To Base64: All bytes",
input: ALL_BYTES,
expectedOutput: "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w==",
recipeConfig: [
{
op: "To Base64",
args: ["A-Za-z0-9+/="],
},
],
},
{
name: "From Base64: nothing",
input: "",
expectedOutput: "",
recipeConfig: [
{
op: "From Base64",
args: ["A-Za-z0-9+/=", true],
},
],
},
{
name: "From Base64: Hello, World!",
input: "SGVsbG8sIFdvcmxkIQ==",
expectedOutput: "Hello, World!",
recipeConfig: [
{
op: "From Base64",
args: ["A-Za-z0-9+/=", true],
},
],
},
{
name: "From Base64: UTF-8",
input: "4YOc4YOjIOGDnuGDkOGDnOGDmOGDmeGDkOGDoQ==",
expectedOutput: "ნუ პანიკას",
recipeConfig: [
{
op: "From Base64",
args: ["A-Za-z0-9+/=", true],
},
],
},
{
name: "From Base64: All bytes",
input: "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w==",
expectedOutput: ALL_BYTES,
recipeConfig: [
{
op: "From Base64",
args: ["A-Za-z0-9+/=", true],
},
],
},
]);

151
test/tests/operations/ByteRepr.js Normal file → Executable file
View file

@ -7,6 +7,25 @@
*/
import TestRegister from "../../TestRegister.js";
const ALL_BYTES = [
"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
"\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f",
"\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f",
"\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f",
"\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f",
"\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f",
"\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f",
"\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f",
"\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f",
"\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf",
"\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf",
"\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf",
"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf",
"\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef",
"\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
].join("");
TestRegister.addTests([
{
name: "To Octal: nothing",
@ -74,4 +93,136 @@ TestRegister.addTests([
}
]
},
{
name: "To Hex: nothing",
input: "",
expectedOutput: "",
recipeConfig: [
{
op: "To Hex",
args: ["Space"]
},
]
},
{
name: "To Hex: All bytes",
input: ALL_BYTES,
expectedOutput: "00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff",
recipeConfig: [
{
op: "To Hex",
args: ["Space"]
},
]
},
{
name: "To Hex: UTF-8",
input: "ნუ პანიკას",
expectedOutput: "e1839ce183a320e1839ee18390e1839ce18398e18399e18390e183a1",
recipeConfig: [
{
op: "To Hex",
args: ["None"]
},
]
},
{
name: "From Hex: nothing",
input: "",
expectedOutput: "",
recipeConfig: [
{
op: "From Hex",
args: ["Space"]
}
]
},
{
name: "From Hex: All bytes",
input: "00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff",
expectedOutput: ALL_BYTES,
recipeConfig: [
{
op: "From Hex",
args: ["Space"]
}
]
},
{
name: "From Hex: UTF-8",
input: "e1839ce183a320e1839ee18390e1839ce18398e18399e18390e183a1",
expectedOutput: "ნუ პანიკას",
recipeConfig: [
{
op: "From Hex",
args: ["None"]
}
]
},
{
name: "To Charcode: nothing",
input: "",
expectedOutput: "",
recipeConfig: [
{
op: "To Charcode",
args: ["Space", 16]
},
]
},
{
name: "To Charcode: All bytes",
input: ALL_BYTES,
expectedOutput: "00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff",
recipeConfig: [
{
op: "To Charcode",
args: ["Space", 16]
},
]
},
{
name: "To Charcode: UTF-8",
input: "ნუ პანიკას",
expectedOutput: "10dc 10e3 20 10de 10d0 10dc 10d8 10d9 10d0 10e1",
recipeConfig: [
{
op: "To Charcode",
args: ["Space", 16]
},
]
},
{
name: "From Charcode: nothing",
input: "",
expectedOutput: "",
recipeConfig: [
{
op: "From Charcode",
args: ["Space", 16]
}
]
},
{
name: "From Charcode: All bytes",
input: "00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff",
expectedOutput: ALL_BYTES,
recipeConfig: [
{
op: "From Charcode",
args: ["Space", 16]
}
]
},
{
name: "From Charcode: UTF-8",
input: "10dc 10e3 20 10de 10d0 10dc 10d8 10d9 10d0 10e1",
expectedOutput: "ნუ პანიკას",
recipeConfig: [
{
op: "From Charcode",
args: ["Space", 16]
}
]
},
]);

100
test/tests/operations/FlowControl.js Normal file → Executable file
View file

@ -8,6 +8,25 @@
*/
import TestRegister from "../../TestRegister.js";
const ALL_BYTES = [
"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
"\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f",
"\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f",
"\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f",
"\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f",
"\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f",
"\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f",
"\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f",
"\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f",
"\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf",
"\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf",
"\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf",
"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf",
"\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef",
"\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
].join("");
TestRegister.addTests([
{
name: "Fork: nothing",
@ -251,7 +270,7 @@ TestRegister.addTests([
],
},
{
name: "Conditional Jump: Skips negatively",
name: "Conditional Jump: Skips backwards",
input: [
"match",
].join("\n"),
@ -290,4 +309,83 @@ TestRegister.addTests([
},
],
},
{
name: "Register: RC4 key",
input: "http://malwarez.biz/beacon.php?key=0e932a5c&data=8db7d5ebe38663a54ecbb334e3db11",
expectedOutput: "All the secrets",
recipeConfig: [
{
op: "Register",
args: ["key=([\\da-f]*)", true, false]
},
{
op: "Find / Replace",
args: [
{
"option": "Regex",
"string": ".*data=(.*)"
}, "$1", true, false, true
]
},
{
op: "RC4",
args: [
{
"option": "Hex",
"string": "$R0"
}, "Hex", "Latin1"
]
}
]
},
{
name: "Register: AES key",
input: "51e201d463698ef5f717f71f5b4712af20be674b3bff53d38546396ee61daac4908e319ca3fcf7089bfb6b38ea99e781d26e577ba9dd6f311a39420b8978e93014b042d44726caedf5436eaf652429c0df94b521676c7c2ce812097c277273c7c72cd89aec8d9fb4a27586ccf6aa0aee224c34ba3bfdf7aeb1ddd477622b91e72c9e709ab60f8daf731ec0cc85ce0f746ff1554a5a3ec291ca40f9e629a872592d988fdd834534aba79c1ad1676769a7c010bf04739ecdb65d95302371d629d9e37e7b4a361da468f1ed5358922d2ea752dd11c366f3017b14aa011d2af03c44f95579098a15e3cf9b4486f8ffe9c239f34de7151f6ca6500fe4b850c3f1c02e801caf3a24464614e42801615b8ffaa07ac8251493ffda7de5ddf3368880c2b95b030f41f8f15066add071a66cf60e5f46f3a230d397b652963a21a53f",
expectedOutput: `"You know," said Arthur, "it's at times like this, when I'm trapped in a Vogon airlock with a man from Betelgeuse, and about to die of asphyxiation in deep space that I really wish I'd listened to what my mother told me when I was young."
"Why, what did she tell you?"
"I don't know, I didn't listen."`,
recipeConfig: [
{
op: "Register",
args: ["(.{32})", true, false]
},
{
op: "Drop bytes",
args: [0, 32, false]
},
{
op: "AES Decrypt",
args: [
{
"option": "Hex",
"string": "1748e7179bd56570d51fa4ba287cc3e5"
},
{
"option": "Hex",
"string": "$R0"
},
"CTR", "Hex", "Raw",
{
"option": "Hex",
"string": ""
}
]
}
]
},
{
name: "Label, Comment: Complex content",
input: ALL_BYTES,
expectedOutput: ALL_BYTES,
recipeConfig: [
{
op: "Label",
args: [""]
},
{
op: "Comment",
args: [""]
}
]
},
]);

79
test/tests/operations/Hash.js Normal file → Executable file
View file

@ -675,4 +675,83 @@ TestRegister.addTests([
}
]
},
{
name: "Bcrypt compare: dolphin",
input: "dolphin",
expectedOutput: "Match: dolphin",
recipeConfig: [
{
op: "Bcrypt compare",
args: ["$2a$10$qyon0LQCmMxpFFjwWH6Qh.dDdhqntQh./IN0RXCc3XIMILuOYZKgK"]
}
]
},
{
name: "Scrypt: RFC test vector 1",
input: "",
expectedOutput: "77d6576238657b203b19ca42c18a0497f16b4844e3074ae8dfdffa3fede21442fcd0069ded0948f8326a753a0fc81f17e8d3e0fb2e0d3628cf35e20c38d18906",
recipeConfig: [
{
op: "Scrypt",
args: [
{
"option": "Latin1",
"string": ""
},
16, 1, 1, 64
]
}
]
},
{
name: "Scrypt: RFC test vector 2",
input: "password",
expectedOutput: "fdbabe1c9d3472007856e7190d01e9fe7c6ad7cbc8237830e77376634b3731622eaf30d92e22a3886ff109279d9830dac727afb94a83ee6d8360cbdfa2cc0640",
recipeConfig: [
{
op: "Scrypt",
args: [
{
"option": "Latin1",
"string": "NaCl"
},
1024, 8, 16, 64
]
}
]
},
{
name: "Scrypt: RFC test vector 3",
input: "pleaseletmein",
expectedOutput: "7023bdcb3afd7348461c06cd81fd38ebfda8fbba904f8e3ea9b543f6545da1f2d5432955613f0fcf62d49705242a9af9e61e85dc0d651e40dfcf017b45575887",
recipeConfig: [
{
op: "Scrypt",
args: [
{
"option": "Latin1",
"string": "SodiumChloride"
},
16384, 8, 1, 64
]
}
]
},
/*{ // This takes a LONG time to run (over a minute usually).
name: "Scrypt: RFC test vector 4",
input: "pleaseletmein",
expectedOutput: "2101cb9b6a511aaeaddbbe09cf70f881ec568d574a2ffd4dabe5ee9820adaa478e56fd8f4ba5d09ffa1c6d927c40f4c337304049e8a952fbcbf45c6fa77a41a4",
recipeConfig: [
{
op: "Scrypt",
args: [
{
"option": "Latin1",
"string": "SodiumChloride"
},
1048576, 8, 1, 64
]
}
]
},*/
]);

235
test/tests/operations/Hexdump.js Executable file
View file

@ -0,0 +1,235 @@
/**
* Hexdump tests.
*
* @author n1474335 [n1474335@gmail.com]
*
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import TestRegister from "../../TestRegister.js";
const ALL_BYTES = [
"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
"\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f",
"\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f",
"\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f",
"\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f",
"\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f",
"\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f",
"\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f",
"\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f",
"\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf",
"\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf",
"\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf",
"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf",
"\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef",
"\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
].join("");
TestRegister.addTests([
{
name: "Hexdump: nothing",
input: "",
expectedOutput: "",
recipeConfig: [
{
op: "To Hexdump",
args: [16, false, false]
},
{
op: "From Hexdump",
args: []
}
],
},
{
name: "Hexdump: Hello, World!",
input: "Hello, World!",
expectedOutput: "Hello, World!",
recipeConfig: [
{
op: "To Hexdump",
args: [16, false, false]
},
{
op: "From Hexdump",
args: []
}
],
},
{
name: "Hexdump: UTF-8",
input: "ნუ პანიკას",
expectedOutput: "ნუ პანიკას",
recipeConfig: [
{
op: "To Hexdump",
args: [16, false, false]
},
{
op: "From Hexdump",
args: []
}
],
},
{
name: "Hexdump: All bytes",
input: ALL_BYTES,
expectedOutput: ALL_BYTES,
recipeConfig: [
{
op: "To Hexdump",
args: [16, false, false]
},
{
op: "From Hexdump",
args: []
}
],
},
{
name: "To Hexdump: UTF-8",
input: "ნუ პანიკას",
expectedOutput: `00000000 e1 83 9c e1 83 a3 20 e1 83 9e e1 83 90 e1 83 9c |á..á.£ á..á..á..|
00000010 e1 83 98 e1 83 99 e1 83 90 e1 83 a1 |á..á..á..á.¡|`,
recipeConfig: [
{
op: "To Hexdump",
args: [16, false, false]
}
],
},
{
name: "To Hexdump: All bytes",
input: ALL_BYTES,
expectedOutput: `00000000 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f |................|
00000010 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f |................|
00000020 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f | !"#$%&'()*+,-./|
00000030 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f |0123456789:;<=>?|
00000040 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f |@ABCDEFGHIJKLMNO|
00000050 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f |PQRSTUVWXYZ[\\]^_|
00000060 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f |\`abcdefghijklmno|
00000070 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f |pqrstuvwxyz{|}~.|
00000080 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f |................|
00000090 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f |................|
000000a0 a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af |\xa0¡¢£¤¥¦§¨©ª«¬.®¯|
000000b0 b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf |°±²³´µ·¸¹º»¼½¾¿|
000000c0 c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf |ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏ|
000000d0 d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df |ÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞß|
000000e0 e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef |àáâãäåæçèéêëìíîï|
000000f0 f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff |ðñòóôõö÷øùúûüýþÿ|`,
recipeConfig: [
{
op: "To Hexdump",
args: [16, false, false]
}
],
},
{
name: "From Hexdump: xxd",
input: `00000000: 0001 0203 0405 0607 0809 0a0b 0c0d 0e0f ................
00000010: 1011 1213 1415 1617 1819 1a1b 1c1d 1e1f ................
00000020: 2021 2223 2425 2627 2829 2a2b 2c2d 2e2f !"#$%&'()*+,-./
00000030: 3031 3233 3435 3637 3839 3a3b 3c3d 3e3f 0123456789:;<=>?
00000040: 4041 4243 4445 4647 4849 4a4b 4c4d 4e4f @ABCDEFGHIJKLMNO
00000050: 5051 5253 5455 5657 5859 5a5b 5c5d 5e5f PQRSTUVWXYZ[\\]^_
00000060: 6061 6263 6465 6667 6869 6a6b 6c6d 6e6f \`abcdefghijklmno
00000070: 7071 7273 7475 7677 7879 7a7b 7c7d 7e7f pqrstuvwxyz{|}~.
00000080: 8081 8283 8485 8687 8889 8a8b 8c8d 8e8f ................
00000090: 9091 9293 9495 9697 9899 9a9b 9c9d 9e9f ................
000000a0: a0a1 a2a3 a4a5 a6a7 a8a9 aaab acad aeaf ................
000000b0: b0b1 b2b3 b4b5 b6b7 b8b9 babb bcbd bebf ................
000000c0: c0c1 c2c3 c4c5 c6c7 c8c9 cacb cccd cecf ................
000000d0: d0d1 d2d3 d4d5 d6d7 d8d9 dadb dcdd dedf ................
000000e0: e0e1 e2e3 e4e5 e6e7 e8e9 eaeb eced eeef ................
000000f0: f0f1 f2f3 f4f5 f6f7 f8f9 fafb fcfd feff ................`,
expectedOutput: ALL_BYTES,
recipeConfig: [
{
op: "From Hexdump",
args: []
}
],
},
{
name: "From Hexdump: Wireshark",
input: `00000000 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f ........ ........
00000010 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f ........ ........
00000020 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f !"#$%&' ()*+,-./
00000030 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 01234567 89:;<=>?
00000040 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f @ABCDEFG HIJKLMNO
00000050 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f PQRSTUVW XYZ[\\]^_
00000060 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f \`abcdefg hijklmno
00000070 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f pqrstuvw xyz{|}~.
00000080 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f ........ ........
00000090 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f ........ ........
000000A0 a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af ........ ........
000000B0 b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf ........ ........
000000C0 c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf ........ ........
000000D0 d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df ........ ........
000000E0 e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef ........ ........
000000F0 f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff ........ ........
`,
expectedOutput: ALL_BYTES,
recipeConfig: [
{
op: "From Hexdump",
args: []
}
],
},
{
name: "From Hexdump: 010",
input: `0000h: 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F ................
0010h: 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F ................
0020h: 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F !"#$%&'()*+,-./
0030h: 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F 0123456789:;<=>?
0040h: 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F @ABCDEFGHIJKLMNO
0050h: 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F PQRSTUVWXYZ[\\]^_
0060h: 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F \`abcdefghijklmno
0070h: 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F pqrstuvwxyz{|}~
0080h: 80 81 82 83 84 85 86 87 88 89 8A 8B 8C 8D 8E 8F .ƒˆŠŒ...
0090h: 90 91 92 93 94 95 96 97 98 99 9A 9B 9C 9D 9E 9F .˜šœ.žŸ
00A0h: A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB AC AD AE AF \xa0¡¢£¤¥¦§¨©ª«¬­®¯
00B0h: B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF °±²³´µ·¸¹º»¼½¾¿
00C0h: C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏ
00D0h: D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB DC DD DE DF ÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞß
00E0h: E0 E1 E2 E3 E4 E5 E6 E7 E8 E9 EA EB EC ED EE EF àáâãäåæçèéêëìíîï
00F0h: F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF ðñòóôõö÷øùúûüýþÿ`,
expectedOutput: ALL_BYTES,
recipeConfig: [
{
op: "From Hexdump",
args: []
}
],
},
{
name: "From Hexdump: Linux hexdump",
input: `00000000 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f |................|
00000010 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f |................|
00000020 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f | !"#$%&'()*+,-./|
00000030 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f |0123456789:;<=>?|
00000040 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f |@ABCDEFGHIJKLMNO|
00000050 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f |PQRSTUVWXYZ[\\]^_|
00000060 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f |\`abcdefghijklmno|
00000070 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f |pqrstuvwxyz{|}~.|
00000080 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f |................|
00000090 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f |................|
000000a0 a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af |................|
000000b0 b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf |................|
000000c0 c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf |................|
000000d0 d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df |................|
000000e0 e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef |................|
000000f0 f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff |................|
00000100`,
expectedOutput: ALL_BYTES,
recipeConfig: [
{
op: "From Hexdump",
args: []
}
],
},
]);

43
test/tests/operations/StrUtils.js Normal file → Executable file
View file

@ -218,13 +218,24 @@ TestRegister.addTests([
],
},
{
name: "Escape String: quotes",
input: "Hello \"World\"! Escape 'these' quotes.",
expectedOutput: "Hello \\\"World\\\"! Escape \\'these\\' quotes.",
name: "Escape String: single quotes",
input: "Escape 'these' quotes.",
expectedOutput: "Escape \\'these\\' quotes.",
recipeConfig: [
{
"op": "Escape string",
"args": []
"args": ["Special chars", "Single", false, true, false]
}
],
},
{
name: "Escape String: double quotes",
input: "Hello \"World\"!",
expectedOutput: "Hello \\\"World\\\"!",
recipeConfig: [
{
"op": "Escape string",
"args": ["Special chars", "Double", false, true, false]
}
],
},
@ -235,7 +246,7 @@ TestRegister.addTests([
recipeConfig: [
{
"op": "Escape string",
"args": []
"args": ["Special chars", "Double", false, true, false]
}
],
},
@ -261,4 +272,26 @@ TestRegister.addTests([
}
],
},
{
name: "Escape String: complex",
input: "null\0backspace\btab\tnewline\nverticaltab\vformfeed\fcarriagereturn\rdoublequote\"singlequote'hex\xa9unicode\u2665codepoint\u{1D306}",
expectedOutput: "null\\0backspace\\btab\\tnewline\\nverticaltab\\x0bformfeed\\fcarriagereturn\\rdoublequote\"singlequote\\'hex\\xa9unicode\\u2665codepoint\\u{1d306}",
recipeConfig: [
{
"op": "Escape string",
"args": ["Special chars", "Single", false, true, false]
}
],
},
{
name: "Unescape String: complex",
input: "null\\0backspace\\btab\\tnewline\\nverticaltab\\vformfeed\\fcarriagereturn\\rdoublequote\\\"singlequote\\'hex\\xa9unicode\\u2665codepoint\\u{1D306}",
expectedOutput: "null\0backspace\btab\tnewline\nverticaltab\vformfeed\fcarriagereturn\rdoublequote\"singlequote'hex\xa9unicode\u2665codepoint\u{1D306}",
recipeConfig: [
{
"op": "Unescape string",
"args": []
}
],
},
]);

View file

@ -35,7 +35,6 @@ module.exports = {
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
moment: "moment-timezone",
log: "loglevel"
}),
new webpack.BannerPlugin({