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

Compare commits

...

50 Commits

Author SHA1 Message Date
n1474335
ec50105e34 9.11.12 2019-12-09 13:51:52 +00:00
n1474335
86ebed132d Updated dependencies 2019-12-09 13:51:48 +00:00
n1474335
798f013219 9.11.11 2019-12-02 15:17:22 +00:00
n1474335
61e6423d95 Added word separator code to Morse Code ops. 2019-12-02 15:17:17 +00:00
n1474335
44c2b71e6c 9.11.10 2019-11-27 12:56:30 +00:00
n1474335
b806be3f49 Merge branch 'n1073645-master' 2019-11-27 12:56:21 +00:00
n1474335
2750284eea Improved comment in Tar extractor 2019-11-27 12:56:10 +00:00
n1474335
5366f1a2eb Merge branch 'master' of https://github.com/n1073645/CyberChef into n1073645-master 2019-11-27 12:52:25 +00:00
n1474335
b459c15d74 9.11.9 2019-11-27 12:47:16 +00:00
n1474335
8a02b35d7d Merge branch 'Mirclus-master' 2019-11-27 12:47:10 +00:00
n1474335
d4441823aa Merge branch 'master' of https://github.com/Mirclus/CyberChef into Mirclus-master 2019-11-27 12:46:25 +00:00
n1474335
13e9a4f0da 9.11.8 2019-11-27 12:36:18 +00:00
n1474335
33471a33d6 Merge branch 'fjh1997-master' 2019-11-27 12:36:13 +00:00
Mirclus
8e5aa2c393 DNS over HTTP: Fix "validate" argument
The argument sets the "cd" parameter on the request.
For both included providers, this flag disables validation ([1], [2]),
so doing the exact opposite of the described action.

This changes the label to the correct name and also flips the default
value to keep the old behavior.

[1] Google
<https://developers.google.com/speed/public-dns/docs/doh/json#supported_parameters>
[2] Cloudflare
<https://developers.cloudflare.com/1.1.1.1/dns-over-https/json-format/>
2019-11-25 20:08:30 +01:00
fjh1997
d16bbe1e7e Fixed typo in IPV6 alphabet
According to python3 base64.b85decode module https://github.com/python/cpython/blob/3.8/Lib/base64.py
2019-11-24 22:03:37 +08:00
n1474335
610d46a1a4 9.11.7 2019-11-21 14:21:20 +00:00
n1474335
f7acef4642 Fixed module detection issue. Closes #881 2019-11-21 14:13:36 +00:00
n1474335
fd5b6c5243 9.11.6 2019-11-21 13:05:39 +00:00
n1474335
a8917e4713 Updated dependencies 2019-11-21 12:15:07 +00:00
n1073645
7a4ebbf47e Tidied up ExtractTAR 2019-11-18 08:42:46 +00:00
n1073645
2e7ce477d7 Tidied up ExtractTAR 2019-11-18 08:40:57 +00:00
n1073645
c1a22ef639 Made TAR extractor and MACHO signature more robust 2019-11-15 16:01:33 +00:00
n1073645
0a7b78b7ee Made TAR extractor and MACHO signature more robust 2019-11-15 15:46:13 +00:00
n1073645
e1cb62848c Made TAR extractor and MACHO signature more robust 2019-11-15 15:35:37 +00:00
n1073645
acf5c733c2 Tidied up local and global variables for Mach-o 2019-11-15 09:26:49 +00:00
n1073645
7c25e29515 Rectified magic bytes for MACHO extractor 2019-11-15 09:21:46 +00:00
n1073645
7c72871c02 Added Tar and Mach-O extractors 2019-11-14 17:17:25 +00:00
n1474335
ddb77c6ab3 Merge branch 'n1073645-master' 2019-11-14 16:09:38 +00:00
n1073645
8502fd246d Linting changes 2019-11-14 14:52:40 +00:00
n1073645
30c6917914 Merge remote-tracking branch 'upstream/master' 2019-11-14 09:03:06 +00:00
n1073645
33464b3388 Linting changes 2019-11-14 08:55:27 +00:00
n1474335
2205637ad6 9.11.5 2019-11-13 18:06:39 +00:00
n1474335
149198ef1c Merge branch 'janisozaur-node12filenames' 2019-11-13 18:06:20 +00:00
n1474335
2c40353180 Merge branch 'node12filenames' of https://github.com/janisozaur/CyberChef into janisozaur-node12filenames 2019-11-13 18:05:55 +00:00
n1474335
a62a6c2aa4 9.11.4 2019-11-13 18:05:31 +00:00
n1474335
4be06f6779 Merge branch 'n1073645-master' 2019-11-13 18:04:51 +00:00
n1474335
03f4740968 Tidied up consumeWhile and consumeUntil 2019-11-13 18:04:36 +00:00
n1474335
ea6d80edfb Merge branch 'master' of https://github.com/n1073645/CyberChef into n1073645-master 2019-11-13 17:59:51 +00:00
n1474335
68e8a221ff 9.11.3 2019-11-13 17:59:22 +00:00
n1474335
cce84c3782 Fixed bug in Base62 operations when using different alphabets 2019-11-13 17:59:16 +00:00
n1073645
c1878ca28b Linting adjustments 2019-11-13 17:15:54 +00:00
n1073645
e9b7a43b9a Adjustment to consumeWhile 2019-11-13 17:11:04 +00:00
n1073645
3921b4f445 Small correction to continueWhile 2019-11-13 09:59:55 +00:00
n1073645
dfd4cca43f Corrections 2019-11-13 09:02:36 +00:00
Michał Janiszewski
69c6c3e790 Add missing filenames for Node 12 imports 2019-11-12 23:43:16 +01:00
n1073645
4541d75f49 Improved continueUntil, added consumeWhile and made the EVTX extractor more complete 2019-11-12 13:17:04 +00:00
n1073645
9eda670026 up-to-date 2019-11-12 11:06:10 +00:00
n1073645
d3c13b118d Improved continueUntil, added consumeWhile and made the EVTX extractor more complete 2019-11-12 11:00:43 +00:00
n1073645
8e2345cf9e Improved continueUntil, added consumeWhile and made the EVTX extractor more complete 2019-11-11 16:08:03 +00:00
n1073645
d240d65c5f Improved continueUntil, added consumeWhile and made the EVTX extractor more complete 2019-11-11 15:47:16 +00:00
30 changed files with 3924 additions and 1880 deletions

View File

@@ -47,6 +47,7 @@
"block-spacing": "error",
"array-bracket-spacing": "error",
"comma-spacing": "error",
"spaced-comment": ["error", "always", { "exceptions": ["/"] } ],
"comma-style": "error",
"computed-property-spacing": "error",
"no-trailing-spaces": "warn",

View File

@@ -26,7 +26,7 @@ module.exports = function (grunt) {
grunt.registerTask("prod",
"Creates a production-ready build. Use the --msg flag to add a compile message.",
[
"eslint", "clean:prod", "clean:config", "exec:generateConfig", "webpack:web",
"eslint", "clean:prod", "clean:config", "exec:generateConfig", "findModules", "webpack:web",
"copy:standalone", "zip:standalone", "clean:standalone", "chmod"
]);
@@ -58,6 +58,19 @@ module.exports = function (grunt) {
grunt.registerTask("tests", "test");
grunt.registerTask("lint", "eslint");
grunt.registerTask("findModules",
"Finds all generated modules and updates the entry point list for Webpack",
function(arg1, arg2) {
const moduleEntryPoints = listEntryModules();
grunt.log.writeln(`Found ${Object.keys(moduleEntryPoints).length} modules.`);
grunt.config.set("webpack.web.entry",
Object.assign({
main: "./src/web/index.js"
}, moduleEntryPoints));
});
// Load tasks provided by each plugin
grunt.loadNpmTasks("grunt-eslint");
@@ -83,7 +96,53 @@ module.exports = function (grunt) {
PKG_VERSION: JSON.stringify(pkg.version),
},
moduleEntryPoints = listEntryModules(),
nodeConsumerTestPath = "~/tmp-cyberchef";
nodeConsumerTestPath = "~/tmp-cyberchef",
/**
* Configuration for Webpack production build. Defined as a function so that it
* can be recalculated when new modules are generated.
*/
webpackProdConf = () => {
return {
mode: "production",
target: "web",
entry: Object.assign({
main: "./src/web/index.js"
}, moduleEntryPoints),
output: {
path: __dirname + "/build/prod",
filename: chunkData => {
return chunkData.chunk.name === "main" ? "assets/[name].js": "[name].js";
},
globalObject: "this"
},
resolve: {
alias: {
"./config/modules/OpModules.mjs": "./config/modules/Default.mjs"
}
},
plugins: [
new webpack.DefinePlugin(BUILD_CONSTANTS),
new HtmlWebpackPlugin({
filename: "index.html",
template: "./src/web/html/index.html",
chunks: ["main"],
compileTime: compileTime,
version: pkg.version,
minify: {
removeComments: true,
collapseWhitespace: true,
minifyJS: true,
minifyCSS: true
}
}),
new BundleAnalyzerPlugin({
analyzerMode: "static",
reportFilename: "BundleAnalyzerReport.html",
openAnalyzer: false
}),
]
};
};
/**
@@ -154,48 +213,7 @@ module.exports = function (grunt) {
},
webpack: {
options: webpackConfig,
web: () => {
return {
mode: "production",
target: "web",
entry: Object.assign({
main: "./src/web/index.js"
}, moduleEntryPoints),
output: {
path: __dirname + "/build/prod",
filename: chunkData => {
return chunkData.chunk.name === "main" ? "assets/[name].js": "[name].js";
},
globalObject: "this"
},
resolve: {
alias: {
"./config/modules/OpModules.mjs": "./config/modules/Default.mjs"
}
},
plugins: [
new webpack.DefinePlugin(BUILD_CONSTANTS),
new HtmlWebpackPlugin({
filename: "index.html",
template: "./src/web/html/index.html",
chunks: ["main"],
compileTime: compileTime,
version: pkg.version,
minify: {
removeComments: true,
collapseWhitespace: true,
minifyJS: true,
minifyCSS: true
}
}),
new BundleAnalyzerPlugin({
analyzerMode: "static",
reportFilename: "BundleAnalyzerReport.html",
openAnalyzer: false
}),
]
};
},
web: webpackProdConf(),
},
"webpack-dev-server": {
options: {
@@ -345,7 +363,8 @@ module.exports = function (grunt) {
command: "git gc --prune=now --aggressive"
},
sitemap: {
command: "node --experimental-modules --no-warnings --no-deprecation src/web/static/sitemap.mjs > build/prod/sitemap.xml"
command: "node --experimental-modules --no-warnings --no-deprecation src/web/static/sitemap.mjs > build/prod/sitemap.xml",
sync: true
},
generateConfig: {
command: chainCommands([
@@ -354,7 +373,8 @@ module.exports = function (grunt) {
"node --experimental-modules --no-warnings --no-deprecation src/core/config/scripts/generateOpsIndex.mjs",
"node --experimental-modules --no-warnings --no-deprecation src/core/config/scripts/generateConfig.mjs",
"echo '--- Config scripts finished. ---\n'"
])
]),
sync: true
},
generateNodeIndex: {
command: chainCommands([
@@ -362,6 +382,7 @@ module.exports = function (grunt) {
"node --experimental-modules --no-warnings --no-deprecation src/node/config/scripts/generateNodeIndex.mjs",
"echo '--- Node index generated. ---\n'"
]),
sync: true
},
opTests: {
command: "node --experimental-modules --no-warnings --no-deprecation tests/operations/index.mjs"
@@ -381,6 +402,7 @@ module.exports = function (grunt) {
`cd ${nodeConsumerTestPath}`,
"npm link cyberchef"
]),
sync: true
},
teardownNodeConsumers: {
command: chainCommands([

5220
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "cyberchef",
"version": "9.11.2",
"version": "9.11.12",
"description": "The Cyber Swiss Army Knife for encryption, encoding, compression and data analysis.",
"author": "n1474335 <n1474335@gmail.com>",
"homepage": "https://gchq.github.io/CyberChef",
@@ -36,26 +36,26 @@
"node >= 10"
],
"devDependencies": {
"@babel/core": "^7.5.5",
"@babel/plugin-transform-runtime": "^7.5.5",
"@babel/preset-env": "^7.5.5",
"autoprefixer": "^9.6.1",
"@babel/core": "^7.7.5",
"@babel/plugin-transform-runtime": "^7.7.6",
"@babel/preset-env": "^7.7.6",
"autoprefixer": "^9.7.3",
"babel-eslint": "^10.0.3",
"babel-loader": "^8.0.6",
"babel-plugin-dynamic-import-node": "^2.3.0",
"chromedriver": "^77.0.0",
"colors": "^1.3.3",
"copy-webpack-plugin": "^5.0.4",
"css-loader": "^3.2.0",
"eslint": "^6.2.2",
"chromedriver": "^78.0.1",
"colors": "^1.4.0",
"copy-webpack-plugin": "^5.0.5",
"css-loader": "^3.2.1",
"eslint": "^6.7.2",
"exports-loader": "^0.7.0",
"file-loader": "^4.2.0",
"file-loader": "^5.0.2",
"grunt": "^1.0.4",
"grunt-accessibility": "~6.0.0",
"grunt-chmod": "~1.1.1",
"grunt-concurrent": "^3.0.0",
"grunt-contrib-clean": "~2.0.0",
"grunt-contrib-connect": "^2.0.0",
"grunt-contrib-connect": "^2.1.0",
"grunt-contrib-copy": "~1.0.0",
"grunt-contrib-watch": "^1.1.0",
"grunt-eslint": "^22.0.0",
@@ -65,43 +65,43 @@
"html-webpack-plugin": "^3.2.0",
"imports-loader": "^0.8.0",
"mini-css-extract-plugin": "^0.8.0",
"nightwatch": "^1.2.1",
"node-sass": "^4.12.0",
"postcss-css-variables": "^0.13.0",
"nightwatch": "^1.3.2",
"node-sass": "^4.13.0",
"postcss-css-variables": "^0.14.0",
"postcss-import": "^12.0.1",
"postcss-loader": "^3.0.0",
"prompt": "^1.0.0",
"sass-loader": "^8.0.0",
"sitemap": "^4.1.1",
"style-loader": "^1.0.0",
"svg-url-loader": "^3.0.1",
"url-loader": "^2.1.0",
"webpack": "^4.39.3",
"webpack-bundle-analyzer": "^3.4.1",
"webpack-dev-server": "^3.8.0",
"sitemap": "^5.1.0",
"style-loader": "^1.0.1",
"svg-url-loader": "^3.0.3",
"url-loader": "^3.0.0",
"webpack": "^4.41.2",
"webpack-bundle-analyzer": "^3.6.0",
"webpack-dev-server": "^3.9.0",
"webpack-node-externals": "^1.7.2",
"worker-loader": "^2.0.0"
},
"dependencies": {
"@babel/polyfill": "^7.4.4",
"@babel/runtime": "^7.5.5",
"@babel/polyfill": "^7.7.0",
"@babel/runtime": "^7.7.6",
"arrive": "^2.4.1",
"avsc": "^5.4.16",
"babel-plugin-transform-builtin-extend": "1.1.2",
"bcryptjs": "^2.4.3",
"bignumber.js": "^9.0.0",
"blakejs": "^1.1.0",
"bootstrap": "4.3.1",
"bootstrap-colorpicker": "^3.1.2",
"bootstrap": "4.4.1",
"bootstrap-colorpicker": "^3.2.0",
"bootstrap-material-design": "^4.1.2",
"bson": "^4.0.2",
"chi-squared": "^1.1.0",
"codepage": "^1.14.0",
"core-js": "^3.2.1",
"core-js": "^3.4.8",
"crypto-api": "^0.8.5",
"crypto-js": "^3.1.9-1",
"ctph.js": "0.0.5",
"d3": "^5.11.0",
"d3": "^5.14.2",
"d3-hexbin": "^0.2.2",
"diff": "^4.0.1",
"es6-promisify": "^6.0.2",
@@ -112,8 +112,8 @@
"exif-parser": "^0.1.12",
"file-saver": "^2.0.2",
"geodesy": "^1.1.3",
"highlight.js": "^9.15.10",
"jimp": "^0.6.4",
"highlight.js": "^9.16.2",
"jimp": "^0.9.3",
"jquery": "3.4.1",
"js-crc": "^0.2.0",
"js-sha3": "^0.8.0",
@@ -122,27 +122,27 @@
"jsonwebtoken": "^8.5.1",
"jsqr": "^1.2.0",
"jsrsasign": "8.0.12",
"kbpgp": "2.1.3",
"kbpgp": "2.1.6",
"libbzip2-wasm": "0.0.4",
"libyara-wasm": "^1.0.1",
"lodash": "^4.17.15",
"loglevel": "^1.6.3",
"loglevel": "^1.6.6",
"loglevel-message-prefix": "^3.0.0",
"markdown-it": "^9.1.0",
"markdown-it": "^10.0.0",
"moment": "^2.24.0",
"moment-timezone": "^0.5.26",
"moment-timezone": "^0.5.27",
"ngeohash": "^0.6.3",
"node-forge": "^0.9.1",
"node-md6": "^0.1.0",
"nodom": "^2.2.0",
"nodom": "^2.4.0",
"notepack.io": "^2.2.0",
"nwmatcher": "^1.4.4",
"otp": "^0.1.3",
"popper.js": "^1.15.0",
"popper.js": "^1.16.0",
"qr-image": "^3.2.0",
"scryptsy": "^2.1.0",
"snackbarjs": "^1.1.0",
"sortablejs": "^1.9.0",
"sortablejs": "^1.10.1",
"split.js": "^1.5.11",
"ssdeep.js": "0.0.2",
"tesseract.js": "^2.0.0-alpha.15",

View File

@@ -758,15 +758,15 @@ class Utils {
"%7E": "~",
"%21": "!",
"%24": "$",
//"%26": "&",
// "%26": "&",
"%27": "'",
"%28": "(",
"%29": ")",
"%2A": "*",
//"%2B": "+",
// "%2B": "+",
"%2C": ",",
"%3B": ";",
//"%3D": "=",
// "%3D": "=",
"%3A": ":",
"%40": "@",
"%2F": "/",
@@ -1335,14 +1335,14 @@ export function debounce(func, wait, id, scope, args) {
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padStart
if (!String.prototype.padStart) {
String.prototype.padStart = function padStart(targetLength, padString) {
targetLength = targetLength>>0; //floor if number or convert non-number to 0;
targetLength = targetLength>>0; // floor if number or convert non-number to 0;
padString = String((typeof padString !== "undefined" ? padString : " "));
if (this.length > targetLength) {
return String(this);
} else {
targetLength = targetLength-this.length;
if (targetLength > padString.length) {
padString += padString.repeat(targetLength/padString.length); //append to original to ensure we are longer than needed
padString += padString.repeat(targetLength/padString.length); // append to original to ensure we are longer than needed
}
return padString.slice(0, targetLength) + String(this);
}
@@ -1354,14 +1354,14 @@ if (!String.prototype.padStart) {
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padEnd
if (!String.prototype.padEnd) {
String.prototype.padEnd = function padEnd(targetLength, padString) {
targetLength = targetLength>>0; //floor if number or convert non-number to 0;
targetLength = targetLength>>0; // floor if number or convert non-number to 0;
padString = String((typeof padString !== "undefined" ? padString : " "));
if (this.length > targetLength) {
return String(this);
} else {
targetLength = targetLength-this.length;
if (targetLength > padString.length) {
padString += padString.repeat(targetLength/padString.length); //append to original to ensure we are longer than needed
padString += padString.repeat(targetLength/padString.length); // append to original to ensure we are longer than needed
}
return String(this) + padString.slice(0, targetLength);
}

View File

@@ -9,7 +9,7 @@
* @license Apache-2.0
*/
/*eslint no-console: ["off"] */
/* eslint no-console: ["off"] */
import path from "path";
import fs from "fs";

View File

@@ -7,7 +7,7 @@
* @license Apache-2.0
*/
/*eslint no-console: ["off"] */
/* eslint no-console: ["off"] */
import path from "path";
import fs from "fs";

View File

@@ -6,7 +6,7 @@
* @license Apache-2.0
*/
/*eslint no-console: ["off"] */
/* eslint no-console: ["off"] */
import prompt from "prompt";
import colors from "colors";
@@ -208,7 +208,7 @@ ${result.highlight ? `
export default ${moduleName};
`;
//console.log(template);
// console.log(template);
const filename = path.join(dir, `./${moduleName}.mjs`);
if (fs.existsSync(filename)) {

View File

@@ -20,7 +20,7 @@ export const ALPHABET_OPTIONS = [
},
{
name: "IPv6",
value: "0-9A-Za-z!#$%&()*+\\-;<=>?@^_`{|~}",
value: "0-9A-Za-z!#$%&()*+\\-;<=>?@^_`{|}~",
}
];

View File

@@ -1282,17 +1282,30 @@ export const FILE_SIGNATURES = {
extension: "dylib",
mime: "application/octet-stream",
description: "",
signature: {
0: 0xca,
1: 0xfe,
2: 0xba,
3: 0xbe,
4: 0x00,
5: 0x00,
6: 0x00,
7: [0x01, 0x02, 0x03]
},
extractor: null
signature: [
{
0: 0xca,
1: 0xfe,
2: 0xba,
3: 0xbe,
4: 0x00,
5: 0x00,
6: 0x00,
7: [0x01, 0x02, 0x03]
},
{
0: 0xce,
1: 0xfa,
2: 0xed,
3: 0xfe,
4: 0x07,
5: 0x00,
6: 0x00,
7: 0x00,
8: [0x01, 0x02, 0x03]
}
],
extractor: extractMACHO
},
{
name: "MacOS Mach-O 64-bit object",
@@ -1305,7 +1318,7 @@ export const FILE_SIGNATURES = {
2: 0xed,
3: 0xfe
},
extractor: null
extractor: extractMACHO
},
{
name: "Adobe Flash",
@@ -1404,7 +1417,7 @@ export const FILE_SIGNATURES = {
260: 0x61,
261: 0x72
},
extractor: null
extractor: extractTAR
},
{
name: "Roshal Archive",
@@ -2720,6 +2733,154 @@ export function extractZIP(bytes, offset) {
}
/**
* MACHO extractor
*
* @param {Uint8Array} bytes
* @param {number} offset
* @returns {Uint8Array}
*/
export function extractMACHO(bytes, offset) {
// Magic bytes.
const MHCIGAM64 = "207250237254";
const MHMAGIC64 = "254237250207";
const MHCIGAM = "206250237254";
/**
* Checks to see if the file is 64-bit.
*
* @param {string} magic
* @returns {bool}
*/
function isMagic64(magic) {
return magic === MHCIGAM64 || magic === MHMAGIC64;
}
/**
* Checks the endianness of the file.
*
* @param {string} magic
* @returns {bool}
*/
function shouldSwapBytes(magic) {
return magic === MHCIGAM || magic === MHCIGAM64;
}
/**
* Jumps through segment information and calculates the sum of the segement sizes.
*
* @param {Stream} stream
* @param {number} offset
* @param {string} isSwap
* @param {number} ncmds
* @returns {number}
*/
function dumpSegmentCommands(stream, offset, isSwap, ncmds) {
let total = 0;
const LCSEGEMENT64 = 0x19;
const LCSEGEMENT = 0x1;
for (let i = 0; i < ncmds; i++) {
// Move to start of segment.
stream.moveTo(offset);
const cmd = stream.readInt(4, isSwap);
if (cmd === LCSEGEMENT64) {
// Move to size of segment field.
stream.moveTo(offset + 48);
// Extract size of segement.
total += stream.readInt(8, isSwap);
stream.moveTo(offset + 4);
// Move to offset of next segment.
offset += stream.readInt(4, isSwap);
} else if (cmd === LCSEGEMENT) {
stream.moveTo(offset + 36);
// Extract size of segement.
total += stream.readInt(4, isSwap);
stream.moveTo(offset + 4);
offset += stream.readInt(4, isSwap);
}
}
return total;
}
/**
* Reads the number of command segments.
*
* @param {Stream} stream
* @param {bool} is64
* @param {string} isSwap
* @returns {number}
*/
function dumpMachHeader(stream, is64, isSwap) {
let loadCommandsOffset = 28;
if (is64)
loadCommandsOffset += 4;
// Move to number of commands field.
stream.moveTo(16);
const ncmds = stream.readInt(4, isSwap);
return dumpSegmentCommands(stream, loadCommandsOffset, isSwap, ncmds);
}
const stream = new Stream(bytes.slice(offset));
const magic = stream.getBytes(4).join("");
// Move to the end of the final segment.
stream.moveTo(dumpMachHeader(stream, isMagic64(magic), shouldSwapBytes(magic) ? "le" : "be"));
return stream.carve();
}
/**
* TAR extractor.
*
* @param {Uint8Array} bytes
* @param {number} offset
* @returns {Uint8Array}
*/
export function extractTAR(bytes, offset) {
const stream = new Stream(bytes.slice(offset));
while (stream.hasMore()) {
// Move to ustar identifier.
stream.moveForwardsBy(0x101);
if (stream.getBytes(5).join("") !== [0x75, 0x73, 0x74, 0x61, 0x72].join("")) {
// Reverse back to the end of the last section.
stream.moveBackwardsBy(0x106);
break;
}
// Move back to file size field.
stream.moveBackwardsBy(0x8a);
let fsize = 0;
// Read file size field.
stream.getBytes(11).forEach((element, index) => {
fsize += (element - 48).toString();
});
// Round number up from octet to nearest 512.
fsize = (Math.ceil(parseInt(fsize, 8) / 512) * 512);
// Move forwards to the end of that file.
stream.moveForwardsBy(fsize + 0x179);
}
stream.consumeWhile(0x00);
return stream.carve();
}
/**
* PNG extractor.
*
@@ -3350,12 +3511,11 @@ export function extractEVTX(bytes, offset) {
while (stream.hasMore()) {
// Loop through ELFCHNKs.
if (stream.getBytes(7).join("") === "\x45\x6c\x66\x43\x68\x6e\x6b")
stream.moveForwardsBy(0xfff9);
else
if (stream.getBytes(7).join("") !== [0x45, 0x6c, 0x66, 0x43, 0x68, 0x6e, 0x6b].join(""))
break;
stream.moveForwardsBy(0xfff9);
}
stream.consumeWhile(0x00);
return stream.carve();
}

View File

@@ -155,19 +155,69 @@ export default class Stream {
}
// val is an array
let found = false;
while (!found && this.position < this.length) {
while (++this.position < this.length && this.bytes[this.position] !== val[0]) {
continue;
}
/**
* Builds the skip forward table from the value to be searched.
*
* @param {Uint8Array} val
* @param {Number} len
* @returns {Uint8Array}
*/
function preprocess(val, len) {
const skiptable = new Array();
val.forEach((element, index) => {
skiptable[element] = len - index;
});
return skiptable;
}
const length = val.length;
const initial = val[length-1];
this.position = length;
// Get the skip table.
const skiptable = preprocess(val, length);
let found = true;
while (this.position < this.length) {
// Until we hit the final element of val in the stream.
while ((this.position < this.length) && (this.bytes[this.position++] !== initial));
found = true;
for (let i = 1; i < val.length; i++) {
if (this.position + i > this.length || this.bytes[this.position + i] !== val[i])
// Loop through the elements comparing them to val.
for (let x = length-1; x >= 0; x--) {
if (this.bytes[this.position - length + x] !== val[x]) {
found = false;
// If element is not equal to val's element then jump forward by the correct amount.
this.position += skiptable[val[x]];
break;
}
}
if (found) {
this.position -= length;
break;
}
}
}
/**
* Consume bytes if they match the supplied value.
*
* @param {Number} val
*/
consumeWhile(val) {
while (this.position < this.length) {
if (this.bytes[this.position] !== val) {
break;
}
this.position++;
}
this.bitPos = 0;
}
/**
* Consume the next byte if it matches the supplied value.
*

View File

@@ -63,9 +63,9 @@ class DNSOverHTTPS extends Operation {
value: false
},
{
name: "Validate DNSSEC",
name: "Disable DNSSEC validation",
type: "boolean",
value: true
value: false
}
];
}

View File

@@ -42,15 +42,22 @@ class FromBase62 extends Operation {
*/
run(input, args) {
if (input.length < 1) return [];
const ALPHABET = Utils.expandAlphRange(args[0]).join("");
const BN = BigNumber.clone({ ALPHABET });
const alphabet = Utils.expandAlphRange(args[0]).join("");
const BN62 = BigNumber.clone({ ALPHABET: alphabet });
const re = new RegExp("[^" + ALPHABET.replace(/[[\]\\\-^$]/g, "\\$&") + "]", "g");
const re = new RegExp("[^" + alphabet.replace(/[[\]\\\-^$]/g, "\\$&") + "]", "g");
input = input.replace(re, "");
const number = new BN(input, 62);
// Read number in using Base62 alphabet
const number = new BN62(input, 62);
// Copy to new BigNumber object that uses the default alphabet
const normalized = new BigNumber(number);
return Utils.convertToByteArray(number.toString(16), "Hex");
// Convert to hex and add leading 0 if required
let hex = normalized.toString(16);
if (hex.length % 2 !== 0) hex = "0" + hex;
return Utils.convertToByteArray(hex, "Hex");
}
}

View File

@@ -59,7 +59,7 @@ class FromMorseCode extends Operation {
const letterDelim = Utils.charRep(args[0]);
const wordDelim = Utils.charRep(args[1]);
input = input.replace(/-|||_||—|dash/ig, "<dash>"); //hyphen-minus|hyphen|minus-sign|undersore|en-dash|em-dash
input = input.replace(/-|||_||—|dash/ig, "<dash>"); // hyphen-minus|hyphen|minus-sign|undersore|en-dash|em-dash
input = input.replace(/\.|·|dot/ig, "<dot>");
let words = input.split(wordDelim);
@@ -147,7 +147,8 @@ const MORSE_TABLE = {
"=": "<dash><dot><dot><dot><dash>",
"&": "<dot><dash><dot><dot><dot>",
"_": "<dot><dot><dash><dash><dot><dash>",
"$": "<dot><dot><dot><dash><dot><dot><dash>"
"$": "<dot><dot><dot><dash><dot><dot><dash>",
" ": "<dot><dot><dot><dot><dot><dot><dot>"
};
export default FromMorseCode;

View File

@@ -117,7 +117,7 @@ class GroupIPAddresses extends Operation {
// Sort IPv6 network dictionaries and print
for (networkStr in ipv6Networks) {
//ipv6Networks[networkStr] = ipv6Networks[networkStr].sort(); TODO
// ipv6Networks[networkStr] = ipv6Networks[networkStr].sort(); TODO
output += networkStr + "/" + cidr + "\n";

View File

@@ -6,8 +6,8 @@
* @license Apache-2.0
*/
import Operation from "../Operation";
import OperationError from "../errors/OperationError";
import Operation from "../Operation.mjs";
import OperationError from "../errors/OperationError.mjs";
/**
* Lorenz operation
@@ -391,7 +391,7 @@ class Lorenz extends Operation {
// Chi 2 one back lim - The active character of Chi 2 (2nd Chi wheel) in the previous position
lim = parseInt(chiSettings[2][x2bptr-1], 10);
if (kt) {
//p5 back 2
// p5 back 2
if (lim===p5[2]) {
lim = 0;
} else {
@@ -413,7 +413,7 @@ class Lorenz extends Operation {
lim = 1;
if (x2b1lug===s1b1lug) lim=0;
if (kt) {
//p5 back 2
// p5 back 2
if (lim===p5[2]) {
lim=0;
} else {

View File

@@ -44,12 +44,15 @@ class ToBase62 extends Operation {
input = new Uint8Array(input);
if (input.length < 1) return "";
const ALPHABET = Utils.expandAlphRange(args[0]).join("");
const BN = BigNumber.clone({ ALPHABET });
const alphabet = Utils.expandAlphRange(args[0]).join("");
const BN62 = BigNumber.clone({ ALPHABET: alphabet });
input = toHexFast(input).toUpperCase();
const number = new BN(input, 16);
// Read number in as hex using normal alphabet
const normalized = new BigNumber(input, 16);
// Copy to BigNumber clone that uses the specified Base62 alphabet
const number = new BN62(normalized);
return number.toString(62);
}

View File

@@ -148,7 +148,8 @@ const MORSE_TABLE = {
"=": "<dash><dot><dot><dot><dash>",
"&": "<dot><dash><dot><dot><dot>",
"_": "<dot><dot><dash><dash><dot><dash>",
"$": "<dot><dot><dot><dash><dot><dot><dash>"
"$": "<dot><dot><dot><dash><dot><dot><dash>",
" ": "<dot><dot><dot><dot><dot><dot><dot>"
};
export default ToMorseCode;

View File

@@ -6,7 +6,7 @@
* @license Apache-2.0
*/
/*eslint no-console: ["off"] */
/* eslint no-console: ["off"] */
import NodeDish from "./NodeDish.mjs";
import NodeRecipe from "./NodeRecipe.mjs";

View File

@@ -7,7 +7,7 @@
* @license Apache-2.0
*/
/*eslint no-global-assign: ["off"] */
/* eslint no-global-assign: ["off"] */
require = require("esm")(module);
module.exports = require("./index.mjs");
module.exports.File = require("./File.mjs");

View File

@@ -9,7 +9,7 @@
* @license Apache-2.0
*/
/*eslint no-console: 0 */
/* eslint no-console: 0 */
import fs from "fs";
import path from "path";

View File

@@ -11,7 +11,7 @@ const chef = require("./cjs.js");
const repl = require("repl");
/*eslint no-console: ["off"] */
/* eslint no-console: ["off"] */
console.log(`
______ __ ________ ____

View File

@@ -604,7 +604,7 @@ class App {
else if (prev[1] > 0) prev[1]--;
else prev[0]--;
//const compareURL = `https://github.com/gchq/CyberChef/compare/v${prev.join(".")}...v${PKG_VERSION}`;
// const compareURL = `https://github.com/gchq/CyberChef/compare/v${prev.join(".")}...v${PKG_VERSION}`;
let compileInfo = `<a href='https://github.com/gchq/CyberChef/blob/master/CHANGELOG.md'>Last build: ${timeSinceCompile.substr(0, 1).toUpperCase() + timeSinceCompile.substr(1)} ago</a>`;

View File

@@ -29,7 +29,7 @@
<meta name="description" content="The Cyber Swiss Army Knife - a web app for encryption, encoding, compression and data analysis" />
<meta name="keywords" content="base64, hex, decode, encode, encrypt, decrypt, compress, decompress, regex, regular expressions, hash, crypt, hexadecimal, user agent, url, certificate, x.509, parser, JSON, gzip, md5, sha1, aes, des, blowfish, xor" />
<link rel="icon" type="image/ico" href="<%- require('../static/images/favicon.ico') %>" />
<link rel="icon" type="image/ico" href="<%- require('../static/images/favicon.ico').default %>" />
<script type="application/javascript">
"use strict";
@@ -197,7 +197,7 @@
</button>
<button type="button" class="mx-2 btn btn-lg btn-success btn-raised btn-block" id="bake">
<img aria-hidden="true" src="<%- require('../static/images/cook_male-32x32.png') %>" alt="Chef Icon"/>
<img aria-hidden="true" src="<%- require('../static/images/cook_male-32x32.png').default %>" alt="Chef Icon"/>
<span>Bake!</span>
</button>
@@ -271,7 +271,7 @@
<div class="file-overlay" id="file-overlay"></div>
<div style="position: relative; height: 100%;">
<div class="io-card card">
<img aria-hidden="true" src="<%- require('../static/images/file-128x128.png') %>" alt="File icon" id="input-file-thumbnail"/>
<img aria-hidden="true" src="<%- require('../static/images/file-128x128.png').default %>" alt="File icon" id="input-file-thumbnail"/>
<div class="card-body">
<button type="button" class="close" id="input-file-close">&times;</button>
Name: <span id="input-file-name"></span><br>
@@ -346,12 +346,12 @@
<div id="output-highlighter" class="no-select"></div>
<div id="output-html"></div>
<textarea id="output-text" readonly="readonly" spellcheck="false"></textarea>
<img id="show-file-overlay" aria-hidden="true" src="<%- require('../static/images/file-32x32.png') %>" alt="Show file overlay" title="Show file overlay"/>
<img id="show-file-overlay" aria-hidden="true" src="<%- require('../static/images/file-32x32.png').default %>" alt="Show file overlay" title="Show file overlay"/>
<div id="output-file">
<div class="file-overlay"></div>
<div style="position: relative; height: 100%;">
<div class="io-card card">
<img aria-hidden="true" src="<%- require('../static/images/file-128x128.png') %>" alt="File icon"/>
<img aria-hidden="true" src="<%- require('../static/images/file-128x128.png').default %>" alt="File icon"/>
<div class="card-body">
Size: <span id="output-file-size"></span><br>
<button id="output-file-download" type="button" class="btn btn-primary btn-outline">Download</button>
@@ -622,7 +622,7 @@
<h5 class="modal-title">CyberChef - The Cyber Swiss Army Knife</h5>
</div>
<div class="modal-body">
<img aria-hidden="true" class="about-img-left" src="<%- require('../static/images/cyberchef-128x128.png') %>" alt="CyberChef Logo"/>
<img aria-hidden="true" class="about-img-left" src="<%- require('../static/images/cyberchef-128x128.png').default %>" alt="CyberChef Logo"/>
<p class="subtext">
Version <%= htmlWebpackPlugin.options.version %><br>
Compile time: <%= htmlWebpackPlugin.options.compileTime %>
@@ -745,7 +745,7 @@
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
<a href="https://github.com/gchq/CyberChef">
<img aria-hidden="true" style="position: absolute; top: 0; right: 0; border: 0;" src="<%- require('../static/images/fork_me.png') %>" alt="Fork me on GitHub">
<img aria-hidden="true" style="position: absolute; top: 0; right: 0; border: 0;" src="<%- require('../static/images/fork_me.png').default %>" alt="Fork me on GitHub">
</a>
</div>
</div>

View File

@@ -446,7 +446,6 @@ class HighlighterWaiter {
}
const cssClass = "hl1";
//if (colour) cssClass += "-"+colour;
// Remove HTML tags
text = text

View File

@@ -29,20 +29,20 @@ class InputWaiter {
// Define keys that don't change the input so we don't have to autobake when they are pressed
this.badKeys = [
16, //Shift
17, //Ctrl
18, //Alt
19, //Pause
20, //Caps
27, //Esc
33, 34, 35, 36, //PgUp, PgDn, End, Home
37, 38, 39, 40, //Directional
44, //PrntScrn
91, 92, //Win
93, //Context
112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, //F1-12
144, //Num
145, //Scroll
16, // Shift
17, // Ctrl
18, // Alt
19, // Pause
20, // Caps
27, // Esc
33, 34, 35, 36, // PgUp, PgDn, End, Home
37, 38, 39, 40, // Directional
44, // PrntScrn
91, 92, // Win
93, // Context
112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, // F1-12
144, // Num
145, // Scroll
];
this.inputWorker = null;

View File

@@ -125,7 +125,7 @@ TestRegister.addApiTests([
<a href="https://github.com">Click here</a>
<script src="script.js"></script>
</body>
</html>`.replace(/\n|\s{4}/g, ""); //remove newlines, tabs
</html>`.replace(/\n|\s{4}/g, ""); // remove newlines, tabs
const dish = new Dish(html, Dish.HTML);
dish.get(4);

View File

@@ -73,7 +73,7 @@ TestRegister.addTests([
},
{
name: "To Octal: Γειά σου",
input: "Γειά σου", //[206,147,206,181,206,185,206,172,32,207,131,206,191,207,133],
input: "Γειά σου", // [206,147,206,181,206,185,206,172,32,207,131,206,191,207,133],
expectedOutput: "316 223 316 265 316 271 316 254 40 317 203 316 277 317 205",
recipeConfig: [
{

View File

@@ -1099,7 +1099,7 @@ TestRegister.addTests([
}
]
}
/*{ // This takes a LONG time to run (over a minute usually).
/* { // This takes a LONG time to run (over a minute usually).
name: "Scrypt: RFC test vector 4",
input: "pleaseletmein",
expectedOutput: "2101cb9b6a511aaeaddbbe09cf70f881ec568d574a2ffd4dabe5ee9820adaa478e56fd8f4ba5d09ffa1c6d927c40f4c337304049e8a952fbcbf45c6fa77a41a4",
@@ -1115,5 +1115,5 @@ TestRegister.addTests([
]
}
]
},*/
}, */
]);

View File

@@ -248,7 +248,7 @@ TestRegister.addTests([
}
]
},
/*{ This operation only works in a browser
/* { This operation only works in a browser
name: "Optical Character Recognition",
input: "iVBORw0KGgoAAAANSUhEUgAAAUAAAAC0CAIAAABqhmJGAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAASuSURBVHhe7dftVdswAIbRzsVAzMM0XabDUCOUxLYsWW4Jp+/pvf9w9GH76CHw4x2IJWAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAI9p8G/PbyY8rL2686g8t+vnqHTyfgIYfvz/26veTXn/UKX8+f0EU9bHrtu/6KfAN/AwEXAj7lFf2TBFw4nae8on+SgIvJ01n/KLzpDK+L3bT/Ap4O+HC+V12mTH+M3gzcLbIY/EO6HfxYp13k09nb6r3UqcdnjoCL3ll72J26h+35Oxy2XvZ0wOLaXq9v2+F1UC+7RZtMZ/DnfX1lwDOPzwUCLo7O2trtDK8H3M/iqoc6bj1subT68XTA/F7bGJooyzKbhTvLPHY8eJLHlbNX1DqYUVfdXbqwJjsCLsans37aNNJM6w68OR0wv9f9ymKw3k67yn2ZZpHlg3a3zis60s6oV+ZvlzMCLoanc3Dsdt9TdWT/lM8OmNjr5KY72jmzq1zfrbvXtVtmRMDF8HTWcgaaqIrD1U4G/MFewxrW262s5jS/Fzpmdts6mnHy+Fwl4GJ0OjsNrG1P/y7CNo3+gEt7jW56MVprNed7A/5w+n6YJ+BieDpnj/jO6pweTz0acGWvmZveL9XOmd3x6wKuTt8PEwRczLRw4eje1XX7c/cDruw1uuneOu2c4aOvzI57mJhRh1xZlQ0BF+Oz9vcF96fuB1zYa7R2b5mD6/XSwdfg8snj4q21+W/L02dfzIxhQMDFyTm6Hd7m+JYP7rPKT5sRuzhOBywm91rUkYc3fV9ltchtr8VmzuGOdfDB9N1tFYefNfdXLmyGjNZkhoCLUQufVqd/7z7rUcLW/XieDvg0s9difNOdRV5ePibt5vTuazusWbF9rs2E5v4mH58LBFyMW7g5OID7s9cMuTygmt9rcNPb5MrAz0lHc3Z9Ht7XZsxqxO36ZtLR/c0+PpMEzLOc/4LhrwmYZ6lfywJ+JgHzJPr9DgLmi23/zdXvcwmYL7YKWL1PJ2AIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmAIJmCI9f7+G6yFxVg/GyYwAAAAAElFTkSuQmCC",
expectedOutput: "Tesseract.js\n",
@@ -262,5 +262,5 @@ TestRegister.addTests([
"args": [false]
}
]
}*/
} */
]);