Skip to content

Commit 6de74b8

Browse files
committed
Merge branch 'esm'
2 parents dcc2843 + 3e5b390 commit 6de74b8

File tree

482 files changed

+39027
-30857
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

482 files changed

+39027
-30857
lines changed

.babelrc

+5
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,10 @@
1010
"modules": false,
1111
"useBuiltIns": true
1212
}]
13+
],
14+
"plugins": [
15+
["babel-plugin-transform-builtin-extend", {
16+
"globals": ["Error"]
17+
}]
1318
]
1419
}

.editorconfig

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# top-most EditorConfig file
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
end_of_line = lf
7+
insert_final_newline = true
8+
trim_trailing_whitespace = true
9+
indent_style = space
10+
indent_size = 4
11+
12+
[{package.json,.travis.yml}]
13+
indent_style = space
14+
indent_size = 2

.eslintignore

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
src/core/lib/**
2-
src/core/config/MetaConfig.js
1+
src/core/vendor/**

.eslintrc.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"parserOptions": {
3-
"ecmaVersion": 8,
3+
"ecmaVersion": 9,
44
"ecmaFeatures": {
55
"impliedStrict": true
66
},
@@ -84,12 +84,12 @@
8484
"no-whitespace-before-property": "error",
8585
"operator-linebreak": ["error", "after"],
8686
"space-in-parens": "error",
87-
"no-var": "error"
87+
"no-var": "error",
88+
"prefer-const": "error"
8889
},
8990
"globals": {
9091
"$": false,
9192
"jQuery": false,
92-
"moment": false,
9393
"log": false,
9494

9595
"COMPILE_TIME": false,

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@ docs/*
66
!docs/*.conf.json
77
!docs/*.ico
88
.vscode
9-
src/core/config/MetaConfig.js
9+
src/core/config/modules/*
10+
src/core/config/OperationConfig.json
11+
src/core/operations/index.mjs
12+

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
language: node_js
22
node_js:
3-
- "8.4"
3+
- node
44
install: npm install
55
before_script:
66
- npm install -g grunt

CHANGELOG.md

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Changelog
2+
All notable changes to this project will be documented in this file.
3+
4+
## [8.0.0] - 2018-08-05
5+
- Codebase rewritten using [ES modules](https://hacks.mozilla.org/2018/03/es-modules-a-cartoon-deep-dive/) and [classes](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes) #284
6+
- Operation architecture restructured to make adding new operations a lot simpler #284
7+
- A script has been added to aid in the creation of new operations by running `npm run newop` @n1474335 #284
8+
- 'Magic' operation added - [automated detection of encoded data](https://github.com/gchq/CyberChef/wiki/Automatic-detection-of-encoded-data-using-CyberChef-Magic) @n1474335 #239
9+
- UI updated to use [Bootstrap Material Design](https://fezvrasta.github.io/bootstrap-material-design/) @n1474335 #248
10+
- `JSON`, `File` and `List<File>` Dish types added @n1474335 #284
11+
- `OperationError` type added for better handling of errors thrown by operations @d98762625 #296
12+
- A `present()` method has been added, allowing operations to pass machine-friendly data to subsequent operations whilst presenting human-friendly data to the user @n1474335 #284
13+
- Set operations added @d98762625 #281
14+
- 'To Table' operation added @JustAnotherMark #294
15+
- 'Haversine distance' operation added @Dachande663 #325
16+
- Started keeping a changelog @n1474335
17+
18+
## [7.0.0] - 2017-12-28
19+
- Added support for loading, processing and downloading files up to 500MB @n1474335 #224
20+
21+
## [6.0.0] - 2017-09-19
22+
- Added threading support, moving all recipe processing into a [Web Worker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers) to increase performance and allow long-running operations to be cancelled @n1474335 #173
23+
- Created modules so that operations relying on large libraries can be downloaded separately as required, reducing the initial loading time for the app @n1474335 #173
24+
25+
## [5.0.0] - 2017-03-30
26+
- Configured Webpack build process, Babel transpilation and ES6 imports and exports @n1474335 #95
27+
28+
## [4.0.0] - 2016-11-28
29+
- Initial open source commit @n1474335
30+
31+
32+
[8.0.0]: https://github.com/gchq/CyberChef/releases/tag/v8.0.0
33+
[7.0.0]: https://github.com/gchq/CyberChef/releases/tag/v7.0.0
34+
[6.0.0]: https://github.com/gchq/CyberChef/releases/tag/v6.0.0
35+
[5.0.0]: https://github.com/gchq/CyberChef/releases/tag/v5.0.0
36+
[4.0.0]: https://github.com/gchq/CyberChef/commit/b1d73a725dc7ab9fb7eb789296efd2b7e4b08306

Gruntfile.js

+52-67
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ const webpack = require("webpack");
44
const HtmlWebpackPlugin = require("html-webpack-plugin");
55
const NodeExternals = require("webpack-node-externals");
66
const Inliner = require("web-resource-inliner");
7-
const fs = require("fs");
7+
const glob = require("glob");
8+
const path = require("path");
89

910
/**
1011
* Grunt configuration for building the app in various formats.
@@ -21,31 +22,31 @@ module.exports = function (grunt) {
2122
// Tasks
2223
grunt.registerTask("dev",
2324
"A persistent task which creates a development build whenever source files are modified.",
24-
["clean:dev", "concurrent:dev"]);
25+
["clean:dev", "exec:generateConfig", "concurrent:dev"]);
2526

2627
grunt.registerTask("node",
2728
"Compiles CyberChef into a single NodeJS module.",
28-
["clean:node", "webpack:metaConf", "webpack:node", "chmod:build"]);
29+
["clean:node", "clean:config", "exec:generateConfig", "webpack:node", "chmod:build"]);
2930

3031
grunt.registerTask("test",
3132
"A task which runs all the tests in test/tests.",
32-
["clean:test", "webpack:metaConf", "webpack:tests", "execute:test"]);
33+
["exec:generateConfig", "exec:tests"]);
3334

3435
grunt.registerTask("docs",
3536
"Compiles documentation in the /docs directory.",
3637
["clean:docs", "jsdoc", "chmod:docs"]);
3738

3839
grunt.registerTask("prod",
3940
"Creates a production-ready build. Use the --msg flag to add a compile message.",
40-
["eslint", "clean:prod", "webpack:metaConf", "webpack:web", "inline", "chmod"]);
41+
["eslint", "clean:prod", "exec:generateConfig", "webpack:web", "inline", "chmod"]);
4142

4243
grunt.registerTask("default",
4344
"Lints the code base",
4445
["eslint", "exec:repoSize"]);
4546

4647
grunt.registerTask("inline",
4748
"Compiles a production build of CyberChef into a single, portable web page.",
48-
["webpack:webInline", "runInliner", "clean:inlineScripts"]);
49+
["exec:generateConfig", "webpack:webInline", "runInliner", "clean:inlineScripts"]);
4950

5051

5152
grunt.registerTask("runInliner", runInliner);
@@ -60,9 +61,9 @@ module.exports = function (grunt) {
6061
grunt.loadNpmTasks("grunt-jsdoc");
6162
grunt.loadNpmTasks("grunt-contrib-clean");
6263
grunt.loadNpmTasks("grunt-contrib-copy");
64+
grunt.loadNpmTasks("grunt-contrib-watch");
6365
grunt.loadNpmTasks("grunt-chmod");
6466
grunt.loadNpmTasks("grunt-exec");
65-
grunt.loadNpmTasks("grunt-execute");
6667
grunt.loadNpmTasks("grunt-accessibility");
6768
grunt.loadNpmTasks("grunt-concurrent");
6869

@@ -118,12 +119,12 @@ module.exports = function (grunt) {
118119
* Generates an entry list for all the modules.
119120
*/
120121
function listEntryModules() {
121-
const path = "./src/core/config/modules/";
122-
let entryModules = {};
122+
const entryModules = {};
123123

124-
fs.readdirSync(path).forEach(file => {
125-
if (file !== "Default.js" && file !== "OpModules.js")
126-
entryModules[file.split(".js")[0]] = path + file;
124+
glob.sync("./src/core/config/modules/*.mjs").forEach(file => {
125+
const basename = path.basename(file);
126+
if (basename !== "Default.mjs" && basename !== "OpModules.mjs")
127+
entryModules[basename.split(".mjs")[0]] = path.resolve(file);
127128
});
128129

129130
return entryModules;
@@ -132,9 +133,9 @@ module.exports = function (grunt) {
132133
grunt.initConfig({
133134
clean: {
134135
dev: ["build/dev/*"],
135-
prod: ["build/prod/*", "src/core/config/MetaConfig.js"],
136-
test: ["build/test/*", "src/core/config/MetaConfig.js"],
137-
node: ["build/node/*", "src/core/config/MetaConfig.js"],
136+
prod: ["build/prod/*"],
137+
node: ["build/node/*"],
138+
config: ["src/core/config/OperationConfig.json", "src/core/config/modules/*", "src/code/operations/index.mjs"],
138139
docs: ["docs/*", "!docs/*.conf.json", "!docs/*.ico", "!docs/*.png"],
139140
inlineScripts: ["build/prod/scripts.js"],
140141
},
@@ -143,10 +144,10 @@ module.exports = function (grunt) {
143144
configFile: "./.eslintrc.json"
144145
},
145146
configs: ["Gruntfile.js"],
146-
core: ["src/core/**/*.js", "!src/core/lib/**/*", "!src/core/config/MetaConfig.js"],
147-
web: ["src/web/**/*.js"],
148-
node: ["src/node/**/*.js"],
149-
tests: ["test/**/*.js"],
147+
core: ["src/core/**/*.{js,mjs}", "!src/core/vendor/**/*", "!src/core/operations/legacy/**/*"],
148+
web: ["src/web/**/*.{js,mjs}"],
149+
node: ["src/node/**/*.{js,mjs}"],
150+
tests: ["test/**/*.{js,mjs}"],
150151
},
151152
jsdoc: {
152153
options: {
@@ -159,17 +160,11 @@ module.exports = function (grunt) {
159160
all: {
160161
src: [
161162
"src/**/*.js",
162-
"!src/core/lib/**/*",
163-
"!src/core/config/MetaConfig.js"
163+
"src/**/*.mjs",
164+
"!src/core/vendor/**/*"
164165
],
165166
}
166167
},
167-
concurrent: {
168-
options: {
169-
logConcurrentOutput: true
170-
},
171-
dev: ["webpack:metaConfDev", "webpack-dev-server:start"]
172-
},
173168
accessibility: {
174169
options: {
175170
accessibilityLevel: "WCAG2A",
@@ -184,39 +179,6 @@ module.exports = function (grunt) {
184179
},
185180
webpack: {
186181
options: webpackConfig,
187-
metaConf: {
188-
mode: "production",
189-
target: "node",
190-
entry: [
191-
"babel-polyfill",
192-
"./src/core/config/OperationConfig.js"
193-
],
194-
output: {
195-
filename: "MetaConfig.js",
196-
path: __dirname + "/src/core/config/",
197-
library: "MetaConfig",
198-
libraryTarget: "commonjs2",
199-
libraryExport: "default"
200-
},
201-
externals: [NodeExternals()],
202-
},
203-
metaConfDev: {
204-
mode: "development",
205-
target: "node",
206-
entry: [
207-
"babel-polyfill",
208-
"./src/core/config/OperationConfig.js"
209-
],
210-
output: {
211-
filename: "MetaConfig.js",
212-
path: __dirname + "/src/core/config/",
213-
library: "MetaConfig",
214-
libraryTarget: "commonjs2",
215-
libraryExport: "default"
216-
},
217-
externals: [NodeExternals()],
218-
watch: true
219-
},
220182
web: {
221183
mode: "production",
222184
target: "web",
@@ -229,7 +191,7 @@ module.exports = function (grunt) {
229191
},
230192
resolve: {
231193
alias: {
232-
"./config/modules/OpModules.js": "./config/modules/Default.js"
194+
"./config/modules/OpModules": "./config/modules/Default"
233195
}
234196
},
235197
plugins: [
@@ -279,7 +241,7 @@ module.exports = function (grunt) {
279241
tests: {
280242
mode: "development",
281243
target: "node",
282-
entry: "./test/index.js",
244+
entry: "./test/index.mjs",
283245
externals: [NodeExternals()],
284246
output: {
285247
filename: "index.js",
@@ -292,7 +254,7 @@ module.exports = function (grunt) {
292254
node: {
293255
mode: "production",
294256
target: "node",
295-
entry: "./src/node/index.js",
257+
entry: "./src/node/index.mjs",
296258
externals: [NodeExternals()],
297259
output: {
298260
filename: "CyberChef.js",
@@ -330,7 +292,7 @@ module.exports = function (grunt) {
330292
}, moduleEntryPoints),
331293
resolve: {
332294
alias: {
333-
"./config/modules/OpModules.js": "./config/modules/Default.js"
295+
"./config/modules/OpModules": "./config/modules/Default"
334296
}
335297
},
336298
plugins: [
@@ -388,6 +350,18 @@ module.exports = function (grunt) {
388350
src: ["docs/**/*", "docs/"]
389351
}
390352
},
353+
watch: {
354+
config: {
355+
files: ["src/core/operations/**/*", "!src/core/operations/index.mjs"],
356+
tasks: ["exec:generateConfig"]
357+
}
358+
},
359+
concurrent: {
360+
dev: ["watch:config", "webpack-dev-server:start"],
361+
options: {
362+
logConcurrentOutput: true
363+
}
364+
},
391365
exec: {
392366
repoSize: {
393367
command: [
@@ -401,10 +375,21 @@ module.exports = function (grunt) {
401375
},
402376
sitemap: {
403377
command: "node build/prod/sitemap.js > build/prod/sitemap.xml"
378+
},
379+
generateConfig: {
380+
command: [
381+
"echo '\n--- Regenerating config files. ---'",
382+
"mkdir -p src/core/config/modules",
383+
"echo 'export default {};\n' > src/core/config/modules/OpModules.mjs",
384+
"echo '[]\n' > src/core/config/OperationConfig.json",
385+
"node --experimental-modules src/core/config/scripts/generateOpsIndex.mjs",
386+
"node --experimental-modules src/core/config/scripts/generateConfig.mjs",
387+
"echo '--- Config scripts finished. ---\n'"
388+
].join(";")
389+
},
390+
tests: {
391+
command: "node --experimental-modules test/index.mjs"
404392
}
405393
},
406-
execute: {
407-
test: "build/test/index.js"
408-
},
409394
});
410395
};

README.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
CyberChef is a simple, intuitive web app for carrying out all manner of "cyber" operations within a web browser. These operations include simple encoding like XOR or Base64, more complex encryption like AES, DES and Blowfish, creating binary and hexdumps, compression and decompression of data, calculating hashes and checksums, IPv6 and X.509 parsing, changing character encodings, and much more.
1414

15-
The tool is designed to enable both technical and non-technical analysts to manipulate data in complex ways without having to deal with complex tools or algorithms. It was conceived, designed, built and incrementally improved by an analyst in their 10% innovation time over several years. Every effort has been made to structure the code in a readable and extendable format, however it should be noted that the analyst is not a professional developer.
15+
The tool is designed to enable both technical and non-technical analysts to manipulate data in complex ways without having to deal with complex tools or algorithms. It was conceived, designed, built and incrementally improved by an analyst in their 10% innovation time over several years.
1616

1717
## Live demo
1818

@@ -43,16 +43,19 @@ You can use as many operations as you like in simple or complex ways. Some examp
4343
- [Carry out different operations on data of different types][8]
4444
- [Use parts of the input as arguments to operations][9]
4545
- [Perform AES decryption, extracting the IV from the beginning of the cipher stream][10]
46+
- [Automagically detect several layers of nested encoding][12]
4647

4748

4849
## Features
4950

5051
- Drag and drop
5152
- Operations can be dragged in and out of the recipe list, or reorganised.
52-
- Files can be dragged over the input box to load them directly into the browser.
53+
- Files up to 500MB can be dragged over the input box to load them directly into the browser.
5354
- Auto Bake
5455
- Whenever you modify the input or the recipe, CyberChef will automatically "bake" for you and produce the output immediately.
5556
- This can be turned off and operated manually if it is affecting performance (if the input is very large, for instance).
57+
- Automated encoding detection
58+
- CyberChef uses [a number of techniques](https://github.com/gchq/CyberChef/wiki/Automatic-detection-of-encoded-data-using-CyberChef-Magic) to attempt to automatically detect which encodings your data is under. If it finds a suitable operation which can make sense of your data, it displays the 'magic' icon in the Output field which you can click to decode your data.
5659
- Breakpoints
5760
- You can set breakpoints on any operation in your recipe to pause execution before running it.
5861
- You can also step through the recipe one operation at a time to see what the data looks like at each stage.
@@ -81,6 +84,8 @@ CyberChef is built to support
8184

8285
## Contributing
8386

87+
Contributing a new operation to CyberChef is super easy! There is a quickstart script which will walk you through the process. If you can write basic JavaScript, you can write a CyberChef operation.
88+
8489
An installation walkthrough, how-to guides for adding new operations and themes, descriptions of the repository structure, available data types and coding conventions can all be found in the project [wiki pages](https://github.com/gchq/CyberChef/wiki).
8590

8691
- Sign the [GCHQ Contributor Licence Agreement](https://github.com/gchq/Gaffer/wiki/GCHQ-OSS-Contributor-License-Agreement-V1.0)
@@ -104,3 +109,4 @@ CyberChef is released under the [Apache 2.0 Licence](https://www.apache.org/lice
104109
[9]: https://gchq.github.io/CyberChef/#recipe=Register('key%3D(%5B%5C%5Cda-f%5D*)',true,false)Find_/_Replace(%7B'option':'Regex','string':'.*data%3D(.*)'%7D,'$1',true,false,true)RC4(%7B'option':'Hex','string':'$R0'%7D,'Hex','Latin1')&input=aHR0cDovL21hbHdhcmV6LmJpei9iZWFjb24ucGhwP2tleT0wZTkzMmE1YyZkYXRhPThkYjdkNWViZTM4NjYzYTU0ZWNiYjMzNGUzZGIxMQ
105110
[10]: https://gchq.github.io/CyberChef/#recipe=Register('(.%7B32%7D)',true,false)Drop_bytes(0,32,false)AES_Decrypt(%7B'option':'Hex','string':'1748e7179bd56570d51fa4ba287cc3e5'%7D,%7B'option':'Hex','string':'$R0'%7D,'CTR','Hex','Raw',%7B'option':'Hex','string':''%7D)&input=NTFlMjAxZDQ2MzY5O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
[12]: https://gchq.github.io/CyberChef/#recipe=Magic(3,false,false)&input=V1VhZ3dzaWFlNm1QOGdOdENDTFVGcENwQ0IyNlJtQkRvREQ4UGFjZEFtekF6QlZqa0syUXN0RlhhS2hwQzZpVVM3UkhxWHJKdEZpc29SU2dvSjR3aGptMWFybTg2NHFhTnE0UmNmVW1MSHJjc0FhWmM1VFhDWWlmTmRnUzgzZ0RlZWpHWDQ2Z2FpTXl1QlY2RXNrSHQxc2NnSjg4eDJ0TlNvdFFEd2JHWTFtbUNvYjJBUkdGdkNLWU5xaU45aXBNcTFaVTFtZ2tkYk51R2NiNzZhUnRZV2hDR1VjOGc5M1VKdWRoYjhodHNoZVpud1RwZ3FoeDgzU1ZKU1pYTVhVakpUMnptcEM3dVhXdHVtcW9rYmRTaTg4WXRrV0RBYzFUb291aDJvSDRENGRkbU5LSldVRHBNd21uZ1VtSzE0eHdtb21jY1BRRTloTTE3MkFQblNxd3hkS1ExNzJSa2NBc3lzbm1qNWdHdFJtVk5OaDJzMzU5d3I2bVMyUVJQ

0 commit comments

Comments
 (0)