2
0
mirror of https://github.com/gchq/CyberChef synced 2025-12-05 23:53:27 +00:00

Compare commits

...

18 Commits

Author SHA1 Message Date
n1474335
8dd223f1cb 7.7.8 2018-03-04 17:51:39 +00:00
n1474335
d15662dea4 Merge branch 'bug-hashes' 2018-03-04 17:49:36 +00:00
n1474335
f47a408755 Fix for UTF-8/binary handling in hashing operations. Added tests to prevent future breakages. Closes #249. 2018-03-04 17:39:53 +00:00
n1474335
8360c9e9f9 Fixed noindex meta tag for standalone version 2018-03-02 11:15:37 +00:00
n1474335
328142dac7 Added 's' to the standalone version string 2018-03-01 20:32:09 +00:00
n1474335
372b2378a8 7.7.7 2018-03-01 19:45:47 +00:00
n1474335
574207c626 Updated many dependencies including Webpack (v4) and crypto-api (v0.8) 2018-03-01 19:45:34 +00:00
n1474335
ead64dcb47 7.7.6 2018-02-28 16:40:22 +00:00
n1474335
da473de9f0 Switched from uas_parser.js to ua-parser-js library to improve library management and remove ReDos vulnerabilities. Also improved performance of two native regexes. Thanks to James Davis for raising awareness. 2018-02-28 16:40:15 +00:00
n1474335
a177e2ab7e 7.7.5 2018-02-21 11:24:46 +00:00
n1474335
8cef6db482 Added IPv6 interface IDs to the 'Format MAC address' operation 2018-02-21 11:24:38 +00:00
n1474335
79a3128491 Changed fragment to query in sitemap 2018-02-20 17:39:46 +00:00
n1474335
cb1fe80214 Added robots meta tag to inline version to prevent indexing. 2018-02-20 17:34:19 +00:00
n1474335
19f2e6dae0 Fixed robots.txt copy 2018-02-20 17:15:06 +00:00
n1474335
74394a773d Fixed URL in sitemap 2018-02-20 17:09:02 +00:00
n1474335
d491e95d1c 7.7.4 2018-02-20 17:04:47 +00:00
n1474335
881523ce54 Merge branch 'sitemap' 2018-02-20 17:04:34 +00:00
n1474335
502a9fbb92 Added dynamically generated sitemap and robots.txt file to prevent crawling of inline version 2018-02-20 16:52:27 +00:00
19 changed files with 3280 additions and 27712 deletions

View File

@@ -11,6 +11,7 @@ script:
- grunt node
- grunt prod --msg="$COMPILE_MSG"
before_deploy:
- grunt exec:sitemap
- grunt copy:ghPages
deploy:
- provider: pages

View File

@@ -185,6 +185,7 @@ module.exports = function (grunt) {
webpack: {
options: webpackConfig,
metaConf: {
mode: "production",
target: "node",
entry: [
"babel-polyfill",
@@ -200,6 +201,7 @@ module.exports = function (grunt) {
externals: [NodeExternals()],
},
metaConfDev: {
mode: "development",
target: "node",
entry: [
"babel-polyfill",
@@ -216,9 +218,11 @@ module.exports = function (grunt) {
watch: true
},
web: {
mode: "production",
target: "web",
entry: Object.assign({
main: "./src/web/index.js"
main: "./src/web/index.js",
sitemap: "./src/web/static/sitemap.js"
}, moduleEntryPoints),
output: {
path: __dirname + "/build/prod"
@@ -230,15 +234,6 @@ module.exports = function (grunt) {
},
plugins: [
new webpack.DefinePlugin(BUILD_CONSTANTS),
new webpack.optimize.UglifyJsPlugin({
compress: {
"screw_ie8": true,
"dead_code": true,
"unused": true,
"warnings": false
},
comments: false,
}),
new HtmlWebpackPlugin({
filename: "index.html",
template: "./src/web/html/index.html",
@@ -255,6 +250,7 @@ module.exports = function (grunt) {
]
},
webInline: {
mode: "production",
target: "web",
entry: "./src/web/index.js",
output: {
@@ -262,21 +258,14 @@ module.exports = function (grunt) {
path: __dirname + "/build/prod"
},
plugins: [
new webpack.DefinePlugin(BUILD_CONSTANTS),
new webpack.optimize.UglifyJsPlugin({
compress: {
"screw_ie8": true,
"dead_code": true,
"unused": true,
"warnings": false
},
comments: false,
}),
new webpack.DefinePlugin(Object.assign({}, BUILD_CONSTANTS, {
INLINE: "true"
})),
new HtmlWebpackPlugin({
filename: "cyberchef.htm",
template: "./src/web/html/index.html",
compileTime: compileTime,
version: pkg.version,
version: pkg.version + "s",
inline: true,
minify: {
removeComments: true,
@@ -288,6 +277,7 @@ module.exports = function (grunt) {
]
},
tests: {
mode: "development",
target: "node",
entry: "./test/index.js",
externals: [NodeExternals()],
@@ -300,6 +290,7 @@ module.exports = function (grunt) {
]
},
node: {
mode: "production",
target: "node",
entry: "./src/node/index.js",
externals: [NodeExternals()],
@@ -326,11 +317,13 @@ module.exports = function (grunt) {
children: false,
chunks: false,
modules: false,
entrypoints: false,
warningsFilter: /source-map/,
}
},
start: {
webpack: {
mode: "development",
target: "web",
entry: Object.assign({
main: "./src/web/index.js"
@@ -377,7 +370,7 @@ module.exports = function (grunt) {
expand: true,
src: "docs/**",
dest: "build/prod/"
}
},
]
}
},
@@ -406,6 +399,9 @@ module.exports = function (grunt) {
cleanGit: {
command: "git gc --prune=now --aggressive"
},
sitemap: {
command: "node build/prod/sitemap.js > build/prod/sitemap.xml"
}
},
execute: {
test: "build/test/index.js"

4500
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "cyberchef",
"version": "7.7.3",
"version": "7.7.8",
"description": "The Cyber Swiss Army Knife for encryption, encoding, compression and data analysis.",
"author": "n1474335 <n1474335@gmail.com>",
"homepage": "https://gchq.github.io/CyberChef",
@@ -31,15 +31,15 @@
"bugs": "https://github.com/gchq/CyberChef/issues",
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-loader": "^7.1.3",
"babel-preset-env": "^1.6.1",
"css-loader": "^0.28.9",
"eslint": "^4.17.0",
"exports-loader": "^0.6.4",
"extract-text-webpack-plugin": "^3.0.2",
"file-loader": "^1.1.6",
"grunt": ">=1.0.1",
"grunt-accessibility": "~5.0.0",
"css-loader": "^0.28.10",
"eslint": "^4.18.1",
"exports-loader": "^0.7.0",
"extract-text-webpack-plugin": "^4.0.0-alpha0",
"file-loader": "^1.1.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",
@@ -49,23 +49,24 @@
"grunt-execute": "^0.2.2",
"grunt-jsdoc": "^2.2.1",
"grunt-webpack": "^3.0.2",
"html-webpack-plugin": "^2.30.1",
"imports-loader": "^0.7.1",
"html-webpack-plugin": "^3.0.4",
"imports-loader": "^0.8.0",
"ink-docstrap": "^1.3.2",
"jsdoc-babel": "^0.3.0",
"less": "^2.7.3",
"less-loader": "^4.0.5",
"less": "^3.0.1",
"less-loader": "^4.0.6",
"postcss-css-variables": "^0.8.0",
"postcss-import": "^11.0.0",
"postcss-loader": "^2.0.10",
"style-loader": "^0.19.1",
"postcss-import": "^11.1.0",
"postcss-loader": "^2.1.1",
"sitemap": "^1.13.0",
"style-loader": "^0.20.2",
"url-loader": "^0.6.2",
"val-loader": "^1.1.0",
"web-resource-inliner": "^4.2.1",
"webpack": "^3.10.0",
"webpack-dev-server": "^2.11.1",
"webpack": "^4.0.1",
"webpack-dev-server": "^3.1.0",
"webpack-node-externals": "^1.6.0",
"worker-loader": "^1.1.0"
"worker-loader": "^1.1.1"
},
"dependencies": {
"babel-polyfill": "^6.26.0",
@@ -73,10 +74,10 @@
"bootstrap": "^3.3.7",
"bootstrap-colorpicker": "^2.5.2",
"bootstrap-switch": "^3.3.4",
"crypto-api": "^0.7.5",
"crypto-api": "^0.8.0",
"crypto-js": "^3.1.9-1",
"diff": "^3.4.0",
"escodegen": "^1.9.0",
"escodegen": "^1.9.1",
"esmangle": "^1.0.1",
"esprima": "^4.0.0",
"exif-parser": "^0.1.12",
@@ -87,24 +88,25 @@
"js-sha3": "^0.7.0",
"jsbn": "^1.1.0",
"jsonpath": "^1.0.0",
"jsrsasign": "8.0.4",
"lodash": "^4.17.4",
"jsrsasign": "8.0.6",
"lodash": "^4.17.5",
"loglevel": "^1.6.1",
"loglevel-message-prefix": "^3.0.0",
"moment": "^2.20.1",
"moment-timezone": "^0.5.14",
"node-forge": "^0.7.1",
"node-forge": "^0.7.2",
"node-md6": "^0.1.0",
"nwmatcher": "^1.4.3",
"otp": "^0.1.3",
"sladex-blowfish": "^0.8.1",
"sortablejs": "^1.7.0",
"split.js": "^1.3.5",
"ua-parser-js": "^0.7.17",
"utf8": "^3.0.0",
"vkbeautify": "^0.99.3",
"xmldom": "^0.1.27",
"xpath": "0.0.27",
"xregexp": "^4.0.0",
"xregexp": "^4.1.1",
"zlibjs": "^0.3.1"
},
"scripts": {

View File

@@ -138,6 +138,7 @@ function loadRequiredModules(recipeConfig) {
log.info("Loading module " + module);
self.sendStatusMessage("Loading module " + module);
self.importScripts(self.docURL + "/" + module + ".js");
self.sendStatusMessage("");
}
});
}

View File

@@ -495,15 +495,16 @@ const Utils = {
* Converts an ArrayBuffer to a string.
*
* @param {ArrayBuffer} arrayBuffer
* @param {boolean} [utf8=true] - Whether to attempt to decode the buffer as UTF-8
* @returns {string}
*
* @example
* // returns "hello"
* Utils.arrayBufferToStr(Uint8Array.from([104,101,108,108,111]).buffer);
*/
arrayBufferToStr: function(arrayBuffer) {
arrayBufferToStr: function(arrayBuffer, utf8=true) {
const byteArray = Array.prototype.slice.call(new Uint8Array(arrayBuffer));
return Utils.byteArrayToUtf8(byteArray);
return utf8 ? Utils.byteArrayToUtf8(byteArray) : Utils.byteArrayToChars(byteArray);
},
@@ -952,7 +953,7 @@ const Utils = {
// Parse bespoke recipe format
recipe = recipe.replace(/\n/g, "");
let m,
recipeRegex = /([^(]+)\(((?:'[^'\\]*(?:\\.[^'\\]*)*'|[^)/])*)(\/[^)]+)?\)/g,
recipeRegex = /([^(]+)\(((?:'[^'\\]*(?:\\.[^'\\]*)*'|[^)/'])*)(\/[^)]+)?\)/g,
recipeConfig = [],
args;

View File

@@ -1825,6 +1825,11 @@ const OperationConfig = {
name: "Cisco style",
type: "boolean",
value: MAC.CISCO_STYLE
},
{
name: "IPv6 interface ID",
type: "boolean",
value: MAC.IPV6_INTERFACE_ID
}
]
},
@@ -3005,21 +3010,21 @@ const OperationConfig = {
"MD2": {
module: "Hashing",
description: "The MD2 (Message-Digest 2) algorithm is a cryptographic hash function developed by Ronald Rivest in 1989. The algorithm is optimized for 8-bit computers.<br><br>Although MD2 is no longer considered secure, even as of 2014, it remains in use in public key infrastructures as part of certificates generated with MD2 and RSA.",
inputType: "string",
inputType: "ArrayBuffer",
outputType: "string",
args: []
},
"MD4": {
module: "Hashing",
description: "The MD4 (Message-Digest 4) algorithm is a cryptographic hash function developed by Ronald Rivest in 1990. The digest length is 128 bits. The algorithm has influenced later designs, such as the MD5, SHA-1 and RIPEMD algorithms.<br><br>The security of MD4 has been severely compromised.",
inputType: "string",
inputType: "ArrayBuffer",
outputType: "string",
args: []
},
"MD5": {
module: "Hashing",
description: "MD5 (Message-Digest 5) is a widely used hash function. It has been used in a variety of security applications and is also commonly used to check the integrity of files.<br><br>However, MD5 is not collision resistant and it isn't suitable for applications like SSL/TLS certificates or digital signatures that rely on this property.",
inputType: "string",
inputType: "ArrayBuffer",
outputType: "string",
args: []
},
@@ -3049,21 +3054,21 @@ const OperationConfig = {
"SHA0": {
module: "Hashing",
description: "SHA-0 is a retronym applied to the original version of the 160-bit hash function published in 1993 under the name 'SHA'. It was withdrawn shortly after publication due to an undisclosed 'significant flaw' and replaced by the slightly revised version SHA-1.",
inputType: "string",
inputType: "ArrayBuffer",
outputType: "string",
args: []
},
"SHA1": {
module: "Hashing",
description: "The SHA (Secure Hash Algorithm) hash functions were designed by the NSA. SHA-1 is the most established of the existing SHA hash functions and it is used in a variety of security applications and protocols.<br><br>However, SHA-1's collision resistance has been weakening as new attacks are discovered or improved.",
inputType: "string",
inputType: "ArrayBuffer",
outputType: "string",
args: []
},
"SHA2": {
module: "Hashing",
description: "The SHA-2 (Secure Hash Algorithm 2) hash functions were designed by the NSA. SHA-2 includes significant changes from its predecessor, SHA-1. The SHA-2 family consists of hash functions with digests (hash values) that are 224, 256, 384 or 512 bits: SHA224, SHA256, SHA384, SHA512.<br><br><ul><li>SHA-512 operates on 64-bit words.</li><li>SHA-256 operates on 32-bit words.</li><li>SHA-384 is largely identical to SHA-512 but is truncated to 384 bytes.</li><li>SHA-224 is largely identical to SHA-256 but is truncated to 224 bytes.</li><li>SHA-512/224 and SHA-512/256 are truncated versions of SHA-512, but the initial values are generated using the method described in Federal Information Processing Standards (FIPS) PUB 180-4.</li></ul>",
inputType: "string",
inputType: "ArrayBuffer",
outputType: "string",
args: [
{
@@ -3076,7 +3081,7 @@ const OperationConfig = {
"SHA3": {
module: "Hashing",
description: "The SHA-3 (Secure Hash Algorithm 3) hash functions were released by NIST on August 5, 2015. Although part of the same series of standards, SHA-3 is internally quite different from the MD5-like structure of SHA-1 and SHA-2.<br><br>SHA-3 is a subset of the broader cryptographic primitive family Keccak designed by Guido Bertoni, Joan Daemen, Michaël Peeters, and Gilles Van Assche, building upon RadioGatún.",
inputType: "string",
inputType: "ArrayBuffer",
outputType: "string",
args: [
{
@@ -3089,7 +3094,7 @@ const OperationConfig = {
"Keccak": {
module: "Hashing",
description: "The Keccak hash algorithm was designed by Guido Bertoni, Joan Daemen, Michaël Peeters, and Gilles Van Assche, building upon RadioGatún. It was selected as the winner of the SHA-3 design competition.<br><br>This version of the algorithm is Keccak[c=2d] and differs from the SHA-3 specification.",
inputType: "string",
inputType: "ArrayBuffer",
outputType: "string",
args: [
{
@@ -3102,7 +3107,7 @@ const OperationConfig = {
"Shake": {
module: "Hashing",
description: "Shake is an Extendable Output Function (XOF) of the SHA-3 hash algorithm, part of the Keccak family, allowing for variable output length/size.",
inputType: "string",
inputType: "ArrayBuffer",
outputType: "string",
args: [
{
@@ -3121,7 +3126,7 @@ const OperationConfig = {
"RIPEMD": {
module: "Hashing",
description: "RIPEMD (RACE Integrity Primitives Evaluation Message Digest) is a family of cryptographic hash functions developed in Leuven, Belgium, by Hans Dobbertin, Antoon Bosselaers and Bart Preneel at the COSIC research group at the Katholieke Universiteit Leuven, and first published in 1996.<br><br>RIPEMD was based upon the design principles used in MD4, and is similar in performance to the more popular SHA-1.<br><br>",
inputType: "string",
inputType: "ArrayBuffer",
outputType: "string",
args: [
{
@@ -3134,14 +3139,14 @@ const OperationConfig = {
"HAS-160": {
module: "Hashing",
description: "HAS-160 is a cryptographic hash function designed for use with the Korean KCDSA digital signature algorithm. It is derived from SHA-1, with assorted changes intended to increase its security. It produces a 160-bit output.<br><br>HAS-160 is used in the same way as SHA-1. First it divides input in blocks of 512 bits each and pads the final block. A digest function updates the intermediate hash value by processing the input blocks in turn.<br><br>The message digest algorithm consists of 80 rounds.",
inputType: "string",
inputType: "ArrayBuffer",
outputType: "string",
args: []
},
"Whirlpool": {
module: "Hashing",
description: "Whirlpool is a cryptographic hash function designed by Vincent Rijmen (co-creator of AES) and Paulo S. L. M. Barreto, who first described it in 2000.<br><br>Several variants exist:<ul><li>Whirlpool-0 is the original version released in 2000.</li><li>Whirlpool-T is the first revision, released in 2001, improving the generation of the s-box.</li><li>Wirlpool is the latest revision, released in 2003, fixing a flaw in the difusion matrix.</li></ul>",
inputType: "string",
inputType: "ArrayBuffer",
outputType: "string",
args: [
{
@@ -3154,7 +3159,7 @@ const OperationConfig = {
"Snefru": {
module: "Hashing",
description: "Snefru is a cryptographic hash function invented by Ralph Merkle in 1990 while working at Xerox PARC. The function supports 128-bit and 256-bit output. It was named after the Egyptian Pharaoh Sneferu, continuing the tradition of the Khufu and Khafre block ciphers.<br><br>The original design of Snefru was shown to be insecure by Eli Biham and Adi Shamir who were able to use differential cryptanalysis to find hash collisions. The design was then modified by increasing the number of iterations of the main pass of the algorithm from two to eight.",
inputType: "string",
inputType: "ArrayBuffer",
outputType: "string",
args: [
{
@@ -3172,11 +3177,11 @@ const OperationConfig = {
"HMAC": {
module: "Hashing",
description: "Keyed-Hash Message Authentication Codes (HMAC) are a mechanism for message authentication using cryptographic hash functions.",
inputType: "string",
inputType: "ArrayBuffer",
outputType: "string",
args: [
{
name: "Password",
name: "Key",
type: "binaryString",
value: ""
},
@@ -3239,7 +3244,7 @@ const OperationConfig = {
"Generate all hashes": {
module: "Hashing",
description: "Generates all available hashes and checksums for the input.",
inputType: "string",
inputType: "ArrayBuffer",
outputType: "string",
args: []
},

File diff suppressed because it is too large Load Diff

View File

@@ -207,7 +207,7 @@ const Extract = {
*/
runEmail: function(input, args) {
let displayTotal = args[0],
regex = /\w[-.\w]*@[-\w]+(?:\.[-\w]+)*\.[A-Z]{2,4}/ig;
regex = /\b\w[-.\w]*@[-\w]+(?:\.[-\w]+)*\.[A-Z]{2,4}\b/ig;
return Extract._search(input, regex, null, displayTotal);
},

View File

@@ -1,4 +1,4 @@
import {UAS_parser as UAParser} from "../lib/uas_parser.js";
import UAParser from "ua-parser-js";
/**
@@ -46,20 +46,22 @@ const HTTP = {
* @returns {string}
*/
runParseUserAgent: function(input, args) {
const ua = UAParser.parse(input);
return "Type: " + ua.type + "\n" +
"Family: " + ua.uaFamily + "\n" +
"Name: " + ua.uaName + "\n" +
"URL: " + ua.uaUrl + "\n" +
"Company: " + ua.uaCompany + "\n" +
"Company URL: " + ua.uaCompanyUrl + "\n\n" +
"OS Family: " + ua.osFamily + "\n" +
"OS Name: " + ua.osName + "\n" +
"OS URL: " + ua.osUrl + "\n" +
"OS Company: " + ua.osCompany + "\n" +
"OS Company URL: " + ua.osCompanyUrl + "\n" +
"Device Type: " + ua.deviceType + "\n";
const ua = UAParser(input);
return `Browser
Name: ${ua.browser.name || "unknown"}
Version: ${ua.browser.version || "unknown"}
Device
Model: ${ua.device.model || "unknown"}
Type: ${ua.device.type || "unknown"}
Vendor: ${ua.device.vendor || "unknown"}
Engine
Name: ${ua.engine.name || "unknown"}
Version: ${ua.engine.version || "unknown"}
OS
Name: ${ua.os.name || "unknown"}
Version: ${ua.os.version || "unknown"}
CPU
Architecture: ${ua.cpu.architecture || "unknown"}`;
},

View File

@@ -1,5 +1,5 @@
import Utils from "../Utils.js";
import CryptoApi from "crypto-api";
import CryptoApi from "babel-loader!crypto-api";
import MD6 from "node-md6";
import * as SHA3 from "js-sha3";
import Checksum from "./Checksum.js";
@@ -20,22 +20,22 @@ const Hash = {
* Generic hash function.
*
* @param {string} name
* @param {string} input
* @param {ArrayBuffer} input
* @param {Object} [options={}]
* @returns {string}
*/
runHash: function(name, input) {
const hasher = CryptoApi.hasher(name);
hasher.state.message = input;
hasher.state.length += input.length;
hasher.process();
return hasher.finalize().stringify("hex");
runHash: function(name, input, options={}) {
const msg = Utils.arrayBufferToStr(input, false),
hasher = CryptoApi.getHasher(name, options);
hasher.update(msg);
return CryptoApi.encoder.toHex(hasher.finalize());
},
/**
* MD2 operation.
*
* @param {string} input
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {string}
*/
@@ -47,7 +47,7 @@ const Hash = {
/**
* MD4 operation.
*
* @param {string} input
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {string}
*/
@@ -59,7 +59,7 @@ const Hash = {
/**
* MD5 operation.
*
* @param {string} input
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {string}
*/
@@ -103,7 +103,7 @@ const Hash = {
/**
* SHA0 operation.
*
* @param {string} input
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {string}
*/
@@ -115,7 +115,7 @@ const Hash = {
/**
* SHA1 operation.
*
* @param {string} input
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {string}
*/
@@ -133,7 +133,7 @@ const Hash = {
/**
* SHA2 operation.
*
* @param {string} input
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {string}
*/
@@ -152,7 +152,7 @@ const Hash = {
/**
* SHA3 operation.
*
* @param {string} input
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {string}
*/
@@ -190,7 +190,7 @@ const Hash = {
/**
* Keccak operation.
*
* @param {string} input
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {string}
*/
@@ -233,7 +233,7 @@ const Hash = {
/**
* Shake operation.
*
* @param {string} input
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {string}
*/
@@ -269,7 +269,7 @@ const Hash = {
/**
* RIPEMD operation.
*
* @param {string} input
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {string}
*/
@@ -282,7 +282,7 @@ const Hash = {
/**
* HAS-160 operation.
*
* @param {string} input
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {string}
*/
@@ -300,7 +300,7 @@ const Hash = {
/**
* Whirlpool operation.
*
* @param {string} input
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {string}
*/
@@ -324,14 +324,15 @@ const Hash = {
/**
* Snefru operation.
*
* @param {string} input
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {string}
*/
runSnefru: function (input, args) {
const rounds = args[0],
size = args[1];
return Hash.runHash(`snefru-${rounds}-${size}`, input);
return Hash.runHash("snefru", input, {
rounds: args[0],
length: args[1]
});
},
@@ -358,71 +359,83 @@ const Hash = {
"HAS160",
"Whirlpool",
"Whirlpool-0",
"Whirlpool-T"
"Whirlpool-T",
"Snefru"
],
/**
* HMAC operation.
*
* @param {string} input
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {string}
*/
runHMAC: function (input, args) {
const password = args[0],
const key = args[0],
hashFunc = args[1].toLowerCase(),
hmac = CryptoApi.mac("hmac", password, hashFunc, {});
msg = Utils.arrayBufferToStr(input, false),
hasher = CryptoApi.getHasher(hashFunc);
hmac.update(input);
return hmac.finalize().stringify("hex");
// Horrible shim to fix constructor bug. Reported in nf404/crypto-api#8
hasher.reset = () => {
hasher.state = {};
const tmp = new hasher.constructor();
hasher.state = tmp.state;
};
const mac = CryptoApi.getHmac(CryptoApi.encoder.fromUtf(key), hasher);
mac.update(msg);
return CryptoApi.encoder.toHex(mac.finalize());
},
/**
* Generate all hashes operation.
*
* @param {string} input
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {string}
*/
runAll: function (input, args) {
let byteArray = Utils.strToByteArray(input),
output = "MD2: " + Hash.runMD2(input, []) +
"\nMD4: " + Hash.runMD4(input, []) +
"\nMD5: " + Hash.runMD5(input, []) +
"\nMD6: " + Hash.runMD6(input, []) +
"\nSHA0: " + Hash.runSHA0(input, []) +
"\nSHA1: " + Hash.runSHA1(input, []) +
"\nSHA2 224: " + Hash.runSHA2(input, ["224"]) +
"\nSHA2 256: " + Hash.runSHA2(input, ["256"]) +
"\nSHA2 384: " + Hash.runSHA2(input, ["384"]) +
"\nSHA2 512: " + Hash.runSHA2(input, ["512"]) +
"\nSHA3 224: " + Hash.runSHA3(input, ["224"]) +
"\nSHA3 256: " + Hash.runSHA3(input, ["256"]) +
"\nSHA3 384: " + Hash.runSHA3(input, ["384"]) +
"\nSHA3 512: " + Hash.runSHA3(input, ["512"]) +
"\nKeccak 224: " + Hash.runKeccak(input, ["224"]) +
"\nKeccak 256: " + Hash.runKeccak(input, ["256"]) +
"\nKeccak 384: " + Hash.runKeccak(input, ["384"]) +
"\nKeccak 512: " + Hash.runKeccak(input, ["512"]) +
"\nShake 128: " + Hash.runShake(input, ["128", 256]) +
"\nShake 256: " + Hash.runShake(input, ["256", 512]) +
"\nRIPEMD-128: " + Hash.runRIPEMD(input, ["128"]) +
"\nRIPEMD-160: " + Hash.runRIPEMD(input, ["160"]) +
"\nRIPEMD-256: " + Hash.runRIPEMD(input, ["256"]) +
"\nRIPEMD-320: " + Hash.runRIPEMD(input, ["320"]) +
"\nHAS-160: " + Hash.runHAS(input, []) +
"\nWhirlpool-0: " + Hash.runWhirlpool(input, ["Whirlpool-0"]) +
"\nWhirlpool-T: " + Hash.runWhirlpool(input, ["Whirlpool-T"]) +
"\nWhirlpool: " + Hash.runWhirlpool(input, ["Whirlpool"]) +
const arrayBuffer = input,
str = Utils.arrayBufferToStr(arrayBuffer, false),
byteArray = new Uint8Array(arrayBuffer),
output = "MD2: " + Hash.runMD2(arrayBuffer, []) +
"\nMD4: " + Hash.runMD4(arrayBuffer, []) +
"\nMD5: " + Hash.runMD5(arrayBuffer, []) +
"\nMD6: " + Hash.runMD6(str, []) +
"\nSHA0: " + Hash.runSHA0(arrayBuffer, []) +
"\nSHA1: " + Hash.runSHA1(arrayBuffer, []) +
"\nSHA2 224: " + Hash.runSHA2(arrayBuffer, ["224"]) +
"\nSHA2 256: " + Hash.runSHA2(arrayBuffer, ["256"]) +
"\nSHA2 384: " + Hash.runSHA2(arrayBuffer, ["384"]) +
"\nSHA2 512: " + Hash.runSHA2(arrayBuffer, ["512"]) +
"\nSHA3 224: " + Hash.runSHA3(arrayBuffer, ["224"]) +
"\nSHA3 256: " + Hash.runSHA3(arrayBuffer, ["256"]) +
"\nSHA3 384: " + Hash.runSHA3(arrayBuffer, ["384"]) +
"\nSHA3 512: " + Hash.runSHA3(arrayBuffer, ["512"]) +
"\nKeccak 224: " + Hash.runKeccak(arrayBuffer, ["224"]) +
"\nKeccak 256: " + Hash.runKeccak(arrayBuffer, ["256"]) +
"\nKeccak 384: " + Hash.runKeccak(arrayBuffer, ["384"]) +
"\nKeccak 512: " + Hash.runKeccak(arrayBuffer, ["512"]) +
"\nShake 128: " + Hash.runShake(arrayBuffer, ["128", 256]) +
"\nShake 256: " + Hash.runShake(arrayBuffer, ["256", 512]) +
"\nRIPEMD-128: " + Hash.runRIPEMD(arrayBuffer, ["128"]) +
"\nRIPEMD-160: " + Hash.runRIPEMD(arrayBuffer, ["160"]) +
"\nRIPEMD-256: " + Hash.runRIPEMD(arrayBuffer, ["256"]) +
"\nRIPEMD-320: " + Hash.runRIPEMD(arrayBuffer, ["320"]) +
"\nHAS-160: " + Hash.runHAS(arrayBuffer, []) +
"\nWhirlpool-0: " + Hash.runWhirlpool(arrayBuffer, ["Whirlpool-0"]) +
"\nWhirlpool-T: " + Hash.runWhirlpool(arrayBuffer, ["Whirlpool-T"]) +
"\nWhirlpool: " + Hash.runWhirlpool(arrayBuffer, ["Whirlpool"]) +
"\n\nChecksums:" +
"\nFletcher-8: " + Checksum.runFletcher8(byteArray, []) +
"\nFletcher-16: " + Checksum.runFletcher16(byteArray, []) +
"\nFletcher-32: " + Checksum.runFletcher32(byteArray, []) +
"\nFletcher-64: " + Checksum.runFletcher64(byteArray, []) +
"\nAdler-32: " + Checksum.runAdler32(byteArray, []) +
"\nCRC-16: " + Checksum.runCRC16(input, []) +
"\nCRC-32: " + Checksum.runCRC32(input, []);
"\nCRC-16: " + Checksum.runCRC16(str, []) +
"\nCRC-32: " + Checksum.runCRC32(str, []);
return output;
},

View File

@@ -34,6 +34,11 @@ const MAC = {
* @default
*/
CISCO_STYLE: false,
/**
* @constant
* @default
*/
IPV6_INTERFACE_ID: false,
/**
* Format MAC addresses operation.
@@ -50,6 +55,7 @@ const MAC = {
dashDelim = args[2],
colonDelim = args[3],
ciscoStyle = args[4],
ipv6IntID = args[5],
outputList = [],
macs = input.toLowerCase().split(/[,\s\r\n]+/);
@@ -57,23 +63,32 @@ const MAC = {
let cleanMac = mac.replace(/[:.-]+/g, ""),
macHyphen = cleanMac.replace(/(.{2}(?=.))/g, "$1-"),
macColon = cleanMac.replace(/(.{2}(?=.))/g, "$1:"),
macCisco = cleanMac.replace(/(.{4}(?=.))/g, "$1.");
macCisco = cleanMac.replace(/(.{4}(?=.))/g, "$1."),
macIPv6 = cleanMac.slice(0, 6) + "fffe" + cleanMac.slice(6);
macIPv6 = macIPv6.replace(/(.{4}(?=.))/g, "$1:");
let bite = parseInt(macIPv6.slice(0, 2), 16) ^ 2;
bite = bite.toString(16).padStart(2, "0");
macIPv6 = bite + macIPv6.slice(2);
if (outputCase === "Lower only") {
if (noDelim) outputList.push(cleanMac);
if (dashDelim) outputList.push(macHyphen);
if (colonDelim) outputList.push(macColon);
if (ciscoStyle) outputList.push(macCisco);
if (ipv6IntID) outputList.push(macIPv6);
} else if (outputCase === "Upper only") {
if (noDelim) outputList.push(cleanMac.toUpperCase());
if (dashDelim) outputList.push(macHyphen.toUpperCase());
if (colonDelim) outputList.push(macColon.toUpperCase());
if (ciscoStyle) outputList.push(macCisco.toUpperCase());
if (ipv6IntID) outputList.push(macIPv6.toUpperCase());
} else {
if (noDelim) outputList.push(cleanMac, cleanMac.toUpperCase());
if (dashDelim) outputList.push(macHyphen, macHyphen.toUpperCase());
if (colonDelim) outputList.push(macColon, macColon.toUpperCase());
if (ciscoStyle) outputList.push(macCisco, macCisco.toUpperCase());
if (ipv6IntID) outputList.push(macIPv6, macIPv6.toUpperCase());
}
outputList.push(

View File

@@ -32,7 +32,7 @@ const Regex = {
},
{
name: "Email address",
value: "(\\w[-.\\w]*)@([-\\w]+(?:\\.[-\\w]+)*)\\.([A-Za-z]{2,4})"
value: "\\b(\\w[-.\\w]*)@([-\\w]+(?:\\.[-\\w]+)*)\\.([A-Za-z]{2,4})\\b"
},
{
name: "URL",

View File

@@ -377,6 +377,7 @@ App.prototype.loadURIParams = function() {
window.location.href.split("#")[1] ||
window.location.hash;
this.uriParams = Utils.parseURIParams(params);
this.autoBakePause = true;
// Read in recipe from URI params
if (this.uriParams.recipe) {
@@ -387,35 +388,29 @@ App.prototype.loadURIParams = function() {
} else if (this.uriParams.op) {
// If there's no recipe, look for single operations
this.manager.recipe.clearRecipe();
try {
this.manager.recipe.addOperation(this.uriParams.op);
} catch (err) {
// If no exact match, search for nearest match and add that
const matchedOps = this.manager.ops.filterOperations(this.uriParams.op, false);
if (matchedOps.length) {
this.manager.recipe.addOperation(matchedOps[0].name);
}
// Populate search with the string
const search = document.getElementById("search");
search.value = this.uriParams.op;
search.dispatchEvent(new Event("search"));
// Search for nearest match and add it
const matchedOps = this.manager.ops.filterOperations(this.uriParams.op, false);
if (matchedOps.length) {
this.manager.recipe.addOperation(matchedOps[0].name);
}
// Populate search with the string
const search = document.getElementById("search");
search.value = this.uriParams.op;
search.dispatchEvent(new Event("search"));
}
// Read in input data from URI params
if (this.uriParams.input) {
this.autoBakePause = true;
try {
const inputData = Utils.fromBase64(this.uriParams.input);
this.setInput(inputData);
} catch (err) {
} finally {
this.autoBakePause = false;
}
} catch (err) {}
}
this.autoBakePause = false;
this.autoBake();
};

View File

@@ -382,10 +382,13 @@ ControlsWaiter.prototype.supportButtonClick = function(e) {
const saveLink = this.generateStateUrl(true, true, null, "https://gchq.github.io/CyberChef/");
if (reportBugInfo) {
reportBugInfo.innerHTML = "* Version: " + PKG_VERSION + "\n" +
"* Compile time: " + COMPILE_TIME + "\n" +
"* User-Agent: \n" + navigator.userAgent + "\n" +
"* [Link to reproduce](" + saveLink + ")\n\n";
reportBugInfo.innerHTML = `* Version: ${PKG_VERSION + (typeof INLINE === "undefined" ? "" : "s")}
* Compile time: ${COMPILE_TIME}
* User-Agent:
${navigator.userAgent}
* [Link to reproduce](${saveLink})
`;
}
};

View File

@@ -87,7 +87,9 @@
changeLoadingMsg();
window.loadingMsgsInt = setInterval(changeLoadingMsg, (Math.random() * 2000) + 1500);
</script>
<% if (!htmlWebpackPlugin.options.inline) { %>
<% if (htmlWebpackPlugin.options.inline) { %>
<meta name="robots" content="noindex" />
<% } else { %>
<script type="application/ld+json">
<% print(JSON.stringify(require("../static/structuredData.json"))); %>
</script>

33
src/web/static/sitemap.js Normal file
View File

@@ -0,0 +1,33 @@
import sm from "sitemap";
import OperationConfig from "../../core/config/MetaConfig.js";
/**
* Generates an XML sitemap for all CyberChef operations and a number of recipes.
*
* @author n1474335 [n1474335@gmail.com]
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
const sitemap = sm.createSitemap({
hostname: "https://gchq.github.io/CyberChef",
});
sitemap.add({
url: "/",
changefreq: "weekly",
priority: 1.0
});
for (let op in OperationConfig) {
sitemap.add({
url: `/?op=${encodeURIComponent(op)}`,
changeFreq: "yearly",
priority: 0.5
});
}
const xml = sitemap.toString();
console.log(xml); // eslint-disable-line no-console

View File

@@ -415,4 +415,264 @@ TestRegister.addTests([
}
]
},
{
name: "MD5: Complex bytes",
input: "10dc10e32010de10d010dc10d810d910d010e12e",
expectedOutput: "4f4f02e2646545aa8fc42f613c9aa068",
recipeConfig: [
{
"op": "From Hex",
"args": ["None"]
},
{
"op": "MD5",
"args": []
}
]
},
{
name: "SHA1: Complex bytes",
input: "10dc10e32010de10d010dc10d810d910d010e12e",
expectedOutput: "2c5400aaee7e8ad4cad29bfbdf8d566924e5442c",
recipeConfig: [
{
"op": "From Hex",
"args": ["None"]
},
{
"op": "SHA1",
"args": []
}
]
},
{
name: "SHA2 224: Complex bytes",
input: "10dc10e32010de10d010dc10d810d910d010e12e",
expectedOutput: "66c166eba2529ecc44a7b7b218a64a8e3892f873c8d231e8e3c1ef3d",
recipeConfig: [
{
"op": "From Hex",
"args": ["None"]
},
{
"op": "SHA2",
"args": ["224"]
}
]
},
{
name: "SHA2 256: Complex bytes",
input: "10dc10e32010de10d010dc10d810d910d010e12e",
expectedOutput: "186ffd22c3af83995afa4a0316023f81a7f8834fd16bd2ed358c7b1b8182ba41",
recipeConfig: [
{
"op": "From Hex",
"args": ["None"]
},
{
"op": "SHA2",
"args": ["256"]
}
]
},
{
name: "SHA2 384: Complex bytes",
input: "10dc10e32010de10d010dc10d810d910d010e12e",
expectedOutput: "2a6369ffec550ea0bfb810b3b8246b7d6b7f060edfae88441f0f242b98b91549aa4ff407de38c6d03b5f377434ad2f36",
recipeConfig: [
{
"op": "From Hex",
"args": ["None"]
},
{
"op": "SHA2",
"args": ["384"]
}
]
},
{
name: "SHA2 512: Complex bytes",
input: "10dc10e32010de10d010dc10d810d910d010e12e",
expectedOutput: "544ae686522c05b70d12b460b5b39ea0a758eb4027333edbded7e2b3f467aa605804f71f54db61a7bbe50e6e7898510635efd6721fd418a9ea4d05b286d12806",
recipeConfig: [
{
"op": "From Hex",
"args": ["None"]
},
{
"op": "SHA2",
"args": ["512"]
}
]
},
{
name: "SHA3 224: Complex bytes",
input: "10dc10e32010de10d010dc10d810d910d010e12e",
expectedOutput: "e2c07562ee8c2d73e3dd309efea257159abd0948ebc14619bab9ffb3",
recipeConfig: [
{
"op": "From Hex",
"args": ["None"]
},
{
"op": "SHA3",
"args": ["224"]
}
]
},
{
name: "SHA3 256: Complex bytes",
input: "10dc10e32010de10d010dc10d810d910d010e12e",
expectedOutput: "55a55275387586afd1ed64757c9ee7ad1d96ca81a5b7b742c40127856ee78a2d",
recipeConfig: [
{
"op": "From Hex",
"args": ["None"]
},
{
"op": "SHA3",
"args": ["256"]
}
]
},
{
name: "SHA3 384: Complex bytes",
input: "10dc10e32010de10d010dc10d810d910d010e12e",
expectedOutput: "39f8796dd697dc39e5a943817833793f2c29dc0d1adc7037854c0fb51e135c6bd26b113240c4fb1e3fcc16ff8690c91a",
recipeConfig: [
{
"op": "From Hex",
"args": ["None"]
},
{
"op": "SHA3",
"args": ["384"]
}
]
},
{
name: "SHA3 512: Complex bytes",
input: "10dc10e32010de10d010dc10d810d910d010e12e",
expectedOutput: "ee9061bed83b1ad1e2fc4a4bac72a5a65a23a0fa55193b808af0a3e2013b718a5a3e40474765b4f93d1b2747401058a5b58099cc890a159db92b2ea816287add",
recipeConfig: [
{
"op": "From Hex",
"args": ["None"]
},
{
"op": "SHA3",
"args": ["512"]
}
]
},
{
name: "MD5: UTF-8",
input: "ნუ პანიკას",
expectedOutput: "2e93ee2b5b2a337ccb678c7db12eff1b",
recipeConfig: [
{
"op": "MD5",
"args": []
}
]
},
{
name: "SHA1: UTF-8",
input: "ნუ პანიკას",
expectedOutput: "87f483b1515dce672be044bf183ae8103e3b2d4b",
recipeConfig: [
{
"op": "SHA1",
"args": []
}
]
},
{
name: "SHA2 224: UTF-8",
input: "ნუ პანიკას",
expectedOutput: "563ca57b500157717961a5fa87ce42c6db76a488c98ea9c28d620770",
recipeConfig: [
{
"op": "SHA2",
"args": ["224"]
}
]
},
{
name: "SHA2 256: UTF-8",
input: "ნუ პანიკას",
expectedOutput: "36abbb4622ffff06aa3e3cea266765601b21457bb3755a0a2cf0a206422863c1",
recipeConfig: [
{
"op": "SHA2",
"args": ["256"]
}
]
},
{
name: "SHA2 384: UTF-8",
input: "ნუ პანიკას",
expectedOutput: "140b929391a66c9a943bcd60e6964f0d19526d3bc9ba020fbb29aae51cddb8e63a78784d8770f1d36335bf4efff8c131",
recipeConfig: [
{
"op": "SHA2",
"args": ["384"]
}
]
},
{
name: "SHA2 512: UTF-8",
input: "ნუ პანიკას",
expectedOutput: "04a7887c400bf647b7c67b9a0f1ada70d176348b5afdfebea184f7e62748849828669c7b5160be99455fdbf625589bd1689c003bc06ef60c39607d825a2f8838",
recipeConfig: [
{
"op": "SHA2",
"args": ["512"]
}
]
},
{
name: "SHA3 224: UTF-8",
input: "ნუ პანიკას",
expectedOutput: "b3ffc9620949f879cb561fb240452494e2566cb4e4f701a85715e14f",
recipeConfig: [
{
"op": "SHA3",
"args": ["224"]
}
]
},
{
name: "SHA3 256: UTF-8",
input: "ნუ პანიკას",
expectedOutput: "b5f247d725b46546c832502cd07bccb5d4de0c41a6665d3944ed2cc55cd9d156",
recipeConfig: [
{
"op": "SHA3",
"args": ["256"]
}
]
},
{
name: "SHA3 384: UTF-8",
input: "ნუ პანიკას",
expectedOutput: "93e87b9aa8c9c47eba146adac357c525b418b71677f6db01d1c760d87b058682e639c8d43a8bfe91529cecd9800700e3",
recipeConfig: [
{
"op": "SHA3",
"args": ["384"]
}
]
},
{
name: "SHA3 512: UTF-8",
input: "ნუ პანიკას",
expectedOutput: "1fbc484b5184982561795162757717474eebc846ca9f10029a75a54cdd897a7b48d1db42f2478fa1d5d213a0dd7de71c809cb19c60581ba57e7289d29408fb36",
recipeConfig: [
{
"op": "SHA3",
"args": ["512"]
}
]
},
]);

View File

@@ -109,9 +109,13 @@ module.exports = {
children: false,
chunks: false,
modules: false,
entrypoints: false,
warningsFilter: /source-map/,
},
node: {
fs: "empty"
},
performance: {
hints: false
}
};