mirror of
https://github.com/gchq/CyberChef
synced 2025-12-05 23:53:27 +00:00
Compare commits
63 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d18a7df3bc | ||
|
|
f81012ef6e | ||
|
|
cb66508b8a | ||
|
|
c56038a1e2 | ||
|
|
81e62a6c22 | ||
|
|
c501720cdd | ||
|
|
92b5aa08f3 | ||
|
|
1097170a68 | ||
|
|
e6e2b169dc | ||
|
|
e41145427e | ||
|
|
caadf8e762 | ||
|
|
1143c23ad9 | ||
|
|
c1bb93eec1 | ||
|
|
1ae9c82e29 | ||
|
|
715ca1c292 | ||
|
|
2f5b0533d8 | ||
|
|
5ece79c74d | ||
|
|
12c226f874 | ||
|
|
567474ce00 | ||
|
|
209a5b7274 | ||
|
|
e962c9594b | ||
|
|
242bad09ea | ||
|
|
8dd223f1cb | ||
|
|
d15662dea4 | ||
|
|
f47a408755 | ||
|
|
8360c9e9f9 | ||
|
|
328142dac7 | ||
|
|
372b2378a8 | ||
|
|
574207c626 | ||
|
|
ead64dcb47 | ||
|
|
da473de9f0 | ||
|
|
a177e2ab7e | ||
|
|
8cef6db482 | ||
|
|
79a3128491 | ||
|
|
cb1fe80214 | ||
|
|
19f2e6dae0 | ||
|
|
74394a773d | ||
|
|
d491e95d1c | ||
|
|
881523ce54 | ||
|
|
502a9fbb92 | ||
|
|
cc44fe6557 | ||
|
|
5b1ac3de18 | ||
|
|
5a2a649d8e | ||
|
|
1aef193b40 | ||
|
|
750fa45c04 | ||
|
|
50f2819699 | ||
|
|
ab55b91da1 | ||
|
|
59f7774964 | ||
|
|
b5eb44af9f | ||
|
|
8518fa67f2 | ||
|
|
f6b68f9880 | ||
|
|
f6b2783f8b | ||
|
|
aa3f781e18 | ||
|
|
50a3cc57ad | ||
|
|
7554cbda72 | ||
|
|
6a67fe09de | ||
|
|
f07263ca2a | ||
|
|
bfbefb7318 | ||
|
|
db8955d90d | ||
|
|
5a5ce1101b | ||
|
|
670566b7eb | ||
|
|
dcd8f98e8c | ||
|
|
60c8da7bbb |
2
.babelrc
2
.babelrc
@@ -5,7 +5,7 @@
|
||||
"chrome": 40,
|
||||
"firefox": 35,
|
||||
"edge": 14,
|
||||
"node": "6.5",
|
||||
"node": "6.5"
|
||||
},
|
||||
"modules": false,
|
||||
"useBuiltIns": true
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
"mode": "minimum"
|
||||
}],
|
||||
"indent": ["error", 4, {
|
||||
"ignoreComments": true,
|
||||
"ArrayExpression": "first",
|
||||
"SwitchCase": 1
|
||||
}],
|
||||
|
||||
@@ -11,6 +11,7 @@ script:
|
||||
- grunt node
|
||||
- grunt prod --msg="$COMPILE_MSG"
|
||||
before_deploy:
|
||||
- grunt exec:sitemap
|
||||
- grunt copy:ghPages
|
||||
deploy:
|
||||
- provider: pages
|
||||
|
||||
44
Gruntfile.js
44
Gruntfile.js
@@ -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"],
|
||||
@@ -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,
|
||||
warningsFilter: /source-map/,
|
||||
entrypoints: false,
|
||||
warningsFilter: [/source-map/, /dependency is an expression/],
|
||||
}
|
||||
},
|
||||
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"
|
||||
|
||||
@@ -103,4 +103,4 @@ CyberChef is released under the [Apache 2.0 Licence](https://www.apache.org/lice
|
||||
[8]: https://gchq.github.io/CyberChef/#recipe=Fork('%5C%5Cn','%5C%5Cn',false)Conditional_Jump('1',false,'base64',10)To_Hex('Space')Return()Label('base64')To_Base64('A-Za-z0-9%2B/%3D')&input=U29tZSBkYXRhIHdpdGggYSAxIGluIGl0ClNvbWUgZGF0YSB3aXRoIGEgMiBpbiBpdA
|
||||
[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
|
||||
[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=NTFlMjAxZDQ2MzY5OGVmNWY3MTdmNzFmNWI0NzEyYWYyMGJlNjc0YjNiZmY1M2QzODU0NjM5NmVlNjFkYWFjNDkwOGUzMTljYTNmY2Y3MDg5YmZiNmIzOGVhOTllNzgxZDI2ZTU3N2JhOWRkNmYzMTFhMzk0MjBiODk3OGU5MzAxNGIwNDJkNDQ3MjZjYWVkZjU0MzZlYWY2NTI0MjljMGRmOTRiNTIxNjc2YzdjMmNlODEyMDk3YzI3NzI3M2M3YzcyY2Q4OWFlYzhkOWZiNGEyNzU4NmNjZjZhYTBhZWUyMjRjMzRiYTNiZmRmN2FlYjFkZGQ0Nzc2MjJiOTFlNzJjOWU3MDlhYjYwZjhkYWY3MzFlYzBjYzg1Y2UwZjc0NmZmMTU1NGE1YTNlYzI5MWNhNDBmOWU2MjlhODcyNTkyZDk4OGZkZDgzNDUzNGFiYTc5YzFhZDE2NzY3NjlhN2MwMTBiZjA0NzM5ZWNkYjY1ZDk1MzAyMzcxZDYyOWQ5ZTM3ZTdiNGEzNjFkYTQ2OGYxZWQ1MzU4OTIyZDJlYTc1MmRkMTFjMzY2ZjMwMTdiMTRhYTAxMWQyYWYwM2M0NGY5NTU3OTA5OGExNWUzY2Y5YjQ0ODZmOGZmZTljMjM5ZjM0ZGU3MTUxZjZjYTY1MDBmZTRiODUwYzNmMWMwMmU4MDFjYWYzYTI0NDY0NjE0ZTQyODAxNjE1YjhmZmFhMDdhYzgyNTE0OTNmZmRhN2RlNWRkZjMzNjg4ODBjMmI5NWIwMzBmNDFmOGYxNTA2NmFkZDA3MWE2NmNmNjBlNWY0NmYzYTIzMGQzOTdiNjUyOTYzYTIxYTUzZg
|
||||
[11]: https://gchq.github.io/CyberChef/#recipe=XOR(%7B'option':'Hex','string':'3a'%7D,'',false)To_Hexdump(16,false,false)&input=VGhlIGFuc3dlciB0byB0aGUgdWx0aW1hdGUgcXVlc3Rpb24gb2YgbGlmZSwgdGhlIFVuaXZlcnNlLCBhbmQgZXZlcnl0aGluZyBpcyA0Mi4
|
||||
[11]: https://gchq.github.io/CyberChef/#recipe=XOR(%7B'option':'Hex','string':'3a'%7D,'Standard',false)To_Hexdump(16,false,false)&input=VGhlIGFuc3dlciB0byB0aGUgdWx0aW1hdGUgcXVlc3Rpb24gb2YgbGlmZSwgdGhlIFVuaXZlcnNlLCBhbmQgZXZlcnl0aGluZyBpcyA0Mi4
|
||||
|
||||
5384
package-lock.json
generated
5384
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
76
package.json
76
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "cyberchef",
|
||||
"version": "7.6.3",
|
||||
"version": "7.10.1",
|
||||
"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,14 +31,16 @@
|
||||
"bugs": "https://github.com/gchq/CyberChef/issues",
|
||||
"devDependencies": {
|
||||
"babel-core": "^6.26.0",
|
||||
"babel-loader": "^7.1.2",
|
||||
"babel-loader": "^7.1.4",
|
||||
"babel-polyfill": "^6.26.0",
|
||||
"babel-preset-env": "^1.6.1",
|
||||
"css-loader": "^0.28.9",
|
||||
"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.11",
|
||||
"eslint": "^4.19.1",
|
||||
"exports-loader": "^0.7.0",
|
||||
"extract-text-webpack-plugin": "^4.0.0-alpha0",
|
||||
"file-loader": "^1.1.11",
|
||||
"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",
|
||||
@@ -47,63 +49,73 @@
|
||||
"grunt-exec": "~3.0.0",
|
||||
"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",
|
||||
"grunt-webpack": "^3.1.1",
|
||||
"html-webpack-plugin": "^3.1.0",
|
||||
"imports-loader": "^0.8.0",
|
||||
"ink-docstrap": "^1.3.2",
|
||||
"jsdoc-babel": "^0.3.0",
|
||||
"less": "^2.7.3",
|
||||
"less-loader": "^4.0.5",
|
||||
"postcss-css-variables": "^0.8.0",
|
||||
"postcss-import": "^11.0.0",
|
||||
"postcss-loader": "^2.0.10",
|
||||
"style-loader": "^0.19.1",
|
||||
"url-loader": "^0.6.2",
|
||||
"jsdoc-babel": "^0.4.0",
|
||||
"less": "^3.0.1",
|
||||
"less-loader": "^4.1.0",
|
||||
"postcss-css-variables": "^0.8.1",
|
||||
"postcss-import": "^11.1.0",
|
||||
"postcss-loader": "^2.1.3",
|
||||
"sitemap": "^1.13.0",
|
||||
"style-loader": "^0.20.3",
|
||||
"url-loader": "^1.0.1",
|
||||
"val-loader": "^1.1.0",
|
||||
"web-resource-inliner": "^4.2.1",
|
||||
"webpack": "^3.10.0",
|
||||
"webpack-dev-server": "^2.11.1",
|
||||
"webpack": "^4.3.0",
|
||||
"webpack-dev-server": "^3.1.1",
|
||||
"webpack-node-externals": "^1.6.0",
|
||||
"worker-loader": "^1.1.0"
|
||||
"worker-loader": "^1.1.1"
|
||||
},
|
||||
"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",
|
||||
"crypto-api": "^0.7.5",
|
||||
"bson": "^2.0.4",
|
||||
"crypto-api": "^0.8.0",
|
||||
"crypto-js": "^3.1.9-1",
|
||||
"diff": "^3.4.0",
|
||||
"escodegen": "^1.9.0",
|
||||
"ctph.js": "0.0.5",
|
||||
"diff": "^3.5.0",
|
||||
"escodegen": "^1.9.1",
|
||||
"es6-promisify": "^6.0.0",
|
||||
"esmangle": "^1.0.1",
|
||||
"esprima": "^4.0.0",
|
||||
"exif-parser": "^0.1.12",
|
||||
"file-saver": "^1.3.3",
|
||||
"file-saver": "^1.3.8",
|
||||
"highlight.js": "^9.12.0",
|
||||
"jquery": "^3.3.1",
|
||||
"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.4",
|
||||
"lodash": "^4.17.4",
|
||||
"jsrsasign": "8.0.7",
|
||||
"lodash": "^4.17.5",
|
||||
"loglevel": "^1.6.1",
|
||||
"kbpgp": "^2.0.77",
|
||||
"loglevel-message-prefix": "^3.0.0",
|
||||
"moment": "^2.20.1",
|
||||
"moment": "^2.21.0",
|
||||
"moment-timezone": "^0.5.14",
|
||||
"node-forge": "^0.7.1",
|
||||
"node-forge": "^0.7.4",
|
||||
"node-md6": "^0.1.0",
|
||||
"nwmatcher": "^1.4.3",
|
||||
"nwmatcher": "^1.4.4",
|
||||
"otp": "^0.1.3",
|
||||
"scryptsy": "^2.0.0",
|
||||
"sladex-blowfish": "^0.8.1",
|
||||
"sortablejs": "^1.7.0",
|
||||
"split.js": "^1.3.5",
|
||||
"ssdeep.js": "0.0.2",
|
||||
"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": {
|
||||
|
||||
@@ -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("");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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()) {
|
||||
@@ -495,15 +509,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 +967,7 @@ const Utils = {
|
||||
// Parse bespoke recipe format
|
||||
recipe = recipe.replace(/\n/g, "");
|
||||
let m,
|
||||
recipeRegex = /([^(]+)\(((?:'[^'\\]*(?:\\.[^'\\]*)*'|[^)/])*)(\/[^)]+)?\)/g,
|
||||
recipeRegex = /([^(]+)\(((?:'[^'\\]*(?:\\.[^'\\]*)*'|[^)/'])*)(\/[^)]+)?\)/g,
|
||||
recipeConfig = [],
|
||||
args;
|
||||
|
||||
|
||||
@@ -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",
|
||||
]
|
||||
},
|
||||
@@ -111,6 +114,11 @@ const Categories = [
|
||||
"Hex to PEM",
|
||||
"Hex to Object Identifier",
|
||||
"Object Identifier to Hex",
|
||||
"Generate PGP Key Pair",
|
||||
"PGP Encrypt",
|
||||
"PGP Decrypt",
|
||||
"PGP Encrypt and Sign",
|
||||
"PGP Decrypt and Verify",
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -270,7 +278,15 @@ const Categories = [
|
||||
"HAS-160",
|
||||
"Whirlpool",
|
||||
"Snefru",
|
||||
"SSDEEP",
|
||||
"CTPH",
|
||||
"Compare SSDEEP hashes",
|
||||
"Compare CTPH hashes",
|
||||
"HMAC",
|
||||
"Bcrypt",
|
||||
"Bcrypt compare",
|
||||
"Bcrypt parse",
|
||||
"Scrypt",
|
||||
"Fletcher-8 Checksum",
|
||||
"Fletcher-16 Checksum",
|
||||
"Fletcher-32 Checksum",
|
||||
@@ -307,6 +323,8 @@ const Categories = [
|
||||
"To Snake case",
|
||||
"To Camel case",
|
||||
"To Kebab case",
|
||||
"BSON serialise",
|
||||
"BSON deserialise",
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -326,6 +344,7 @@ const Categories = [
|
||||
"Remove EXIF",
|
||||
"Extract EXIF",
|
||||
"Numberwang",
|
||||
"XKCD Random Number",
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
385
src/core/config/OperationConfig.js
Executable file → Normal file
385
src/core/config/OperationConfig.js
Executable file → Normal file
@@ -28,6 +28,7 @@ import MAC from "../operations/MAC.js";
|
||||
import MorseCode from "../operations/MorseCode.js";
|
||||
import NetBIOS from "../operations/NetBIOS.js";
|
||||
import PHP from "../operations/PHP.js";
|
||||
import PGP from "../operations/PGP.js";
|
||||
import PublicKey from "../operations/PublicKey.js";
|
||||
import Punycode from "../operations/Punycode.js";
|
||||
import Regex from "../operations/Regex.js";
|
||||
@@ -912,6 +913,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.",
|
||||
@@ -1825,6 +1854,11 @@ const OperationConfig = {
|
||||
name: "Cisco style",
|
||||
type: "boolean",
|
||||
value: MAC.CISCO_STYLE
|
||||
},
|
||||
{
|
||||
name: "IPv6 interface ID",
|
||||
type: "boolean",
|
||||
value: MAC.IPV6_INTERFACE_ID
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -2427,7 +2461,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",
|
||||
@@ -2438,6 +2472,11 @@ const OperationConfig = {
|
||||
name: "Treat as UTC",
|
||||
type: "boolean",
|
||||
value: DateTime.TREAT_AS_UTC
|
||||
},
|
||||
{
|
||||
name: "Show parsed datetime",
|
||||
type: "boolean",
|
||||
value: true
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -3005,21 +3044,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 +3088,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 +3115,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 +3128,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 +3141,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 +3160,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 +3173,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 +3193,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: [
|
||||
{
|
||||
@@ -3169,14 +3208,54 @@ const OperationConfig = {
|
||||
}
|
||||
]
|
||||
},
|
||||
"SSDEEP": {
|
||||
module: "Hashing",
|
||||
description: "SSDEEP is a program for computing context triggered piecewise hashes (CTPH). Also called fuzzy hashes, CTPH can match inputs that have homologies. Such inputs have sequences of identical bytes in the same order, although bytes in between these sequences may be different in both content and length.<br><br>SSDEEP hashes are now widely used for simple identification purposes (e.g. the 'Basic Properties' section in VirusTotal). Although 'better' fuzzy hashes are available, SSDEEP is still one of the primary choices because of its speed and being a de facto standard.<br><br>This operation is fundamentally the same as the CTPH operation, however their outputs differ in format.",
|
||||
inputType: "string",
|
||||
outputType: "string",
|
||||
args: []
|
||||
},
|
||||
"CTPH": {
|
||||
module: "Hashing",
|
||||
description: "Context Triggered Piecewise Hashing, also called Fuzzy Hashing, can match inputs that have homologies. Such inputs have sequences of identical bytes in the same order, although bytes in between these sequences may be different in both content and length.<br><br>CTPH was originally based on the work of Dr. Andrew Tridgell and a spam email detector called SpamSum. This method was adapted by Jesse Kornblum and published at the DFRWS conference in 2006 in a paper 'Identifying Almost Identical Files Using Context Triggered Piecewise Hashing'.",
|
||||
inputType: "string",
|
||||
outputType: "string",
|
||||
args: []
|
||||
},
|
||||
"Compare SSDEEP hashes": {
|
||||
module: "Hashing",
|
||||
description: "Compares two SSDEEP fuzzy hashes to determine the similarity between them on a scale of 0 to 100.",
|
||||
inputType: "string",
|
||||
outputType: "Number",
|
||||
args: [
|
||||
{
|
||||
name: "Delimiter",
|
||||
type: "option",
|
||||
value: Hash.DELIM_OPTIONS
|
||||
}
|
||||
]
|
||||
},
|
||||
"Compare CTPH hashes": {
|
||||
module: "Hashing",
|
||||
description: "Compares two Context Triggered Piecewise Hashing (CTPH) fuzzy hashes to determine the similarity between them on a scale of 0 to 100.",
|
||||
inputType: "string",
|
||||
outputType: "Number",
|
||||
args: [
|
||||
{
|
||||
name: "Delimiter",
|
||||
type: "option",
|
||||
value: Hash.DELIM_OPTIONS
|
||||
}
|
||||
]
|
||||
},
|
||||
"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: ""
|
||||
},
|
||||
@@ -3225,21 +3304,21 @@ const OperationConfig = {
|
||||
"CRC-32 Checksum": {
|
||||
module: "Hashing",
|
||||
description: "A cyclic redundancy check (CRC) is an error-detecting code commonly used in digital networks and storage devices to detect accidental changes to raw data.<br><br>The CRC was invented by W. Wesley Peterson in 1961; the 32-bit CRC function of Ethernet and many other standards is the work of several researchers and was published in 1975.",
|
||||
inputType: "string",
|
||||
inputType: "ArrayBuffer",
|
||||
outputType: "string",
|
||||
args: []
|
||||
},
|
||||
"CRC-16 Checksum": {
|
||||
module: "Hashing",
|
||||
description: "A cyclic redundancy check (CRC) is an error-detecting code commonly used in digital networks and storage devices to detect accidental changes to raw data.<br><br>The CRC was invented by W. Wesley Peterson in 1961.",
|
||||
inputType: "string",
|
||||
inputType: "ArrayBuffer",
|
||||
outputType: "string",
|
||||
args: []
|
||||
},
|
||||
"Generate all hashes": {
|
||||
module: "Hashing",
|
||||
description: "Generates all available hashes and checksums for the input.",
|
||||
inputType: "string",
|
||||
inputType: "ArrayBuffer",
|
||||
outputType: "string",
|
||||
args: []
|
||||
},
|
||||
@@ -3285,7 +3364,7 @@ const OperationConfig = {
|
||||
},
|
||||
"Parse X.509 certificate": {
|
||||
module: "PublicKey",
|
||||
description: "X.509 is an ITU-T standard for a public key infrastructure (PKI) and Privilege Management Infrastructure (PMI). It is commonly involved with SSL/TLS security.<br><br>This operation displays the contents of a certificate in a human readable format, similar to the openssl command line tool.",
|
||||
description: "X.509 is an ITU-T standard for a public key infrastructure (PKI) and Privilege Management Infrastructure (PMI). It is commonly involved with SSL/TLS security.<br><br>This operation displays the contents of a certificate in a human readable format, similar to the openssl command line tool.<br><br>Tags: X509, server hello, handshake",
|
||||
inputType: "string",
|
||||
outputType: "string",
|
||||
args: [
|
||||
@@ -3509,14 +3588,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>\\"</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>\\"</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>\\"</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>\\"</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: []
|
||||
@@ -3966,7 +4071,239 @@ const OperationConfig = {
|
||||
value: StrUtils.HAMMING_INPUT_TYPE
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"XKCD Random Number": {
|
||||
module: "Default",
|
||||
description: "RFC 1149.5 specifies 4 as the standard IEEE-vetted random number.<br><br><a href='https://xkcd.com/221/'>XKCD #221</a>",
|
||||
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: []
|
||||
},
|
||||
"Generate PGP Key Pair": {
|
||||
module: "PGP",
|
||||
description: "Generates a new public/private PGP key pair. Supports RSA and Eliptic Curve (EC) keys.",
|
||||
inputType: "string",
|
||||
outputType: "string",
|
||||
args: [
|
||||
{
|
||||
name: "Key type",
|
||||
type: "option",
|
||||
value: PGP.KEY_TYPES
|
||||
},
|
||||
{
|
||||
name: "Password (optional)",
|
||||
type: "string",
|
||||
value: ""
|
||||
},
|
||||
{
|
||||
name: "Name (optional)",
|
||||
type: "string",
|
||||
value: ""
|
||||
},
|
||||
{
|
||||
name: "Email (optional)",
|
||||
type: "string",
|
||||
value: ""
|
||||
},
|
||||
]
|
||||
},
|
||||
"PGP Encrypt": {
|
||||
module: "PGP",
|
||||
description: [
|
||||
"Input: the message you want to encrypt.",
|
||||
"<br><br>",
|
||||
"Arguments: the ASCII-armoured PGP public key of the recipient.",
|
||||
"<br><br>",
|
||||
"Pretty Good Privacy is an encryption standard (OpenPGP) used for encrypting, decrypting, and signing messages.",
|
||||
"<br><br>",
|
||||
"This function uses the Keybase implementation of PGP.",
|
||||
].join("\n"),
|
||||
inputType: "string",
|
||||
outputType: "string",
|
||||
args: [
|
||||
{
|
||||
name: "Public key of recipient",
|
||||
type: "text",
|
||||
value: ""
|
||||
},
|
||||
]
|
||||
},
|
||||
"PGP Decrypt": {
|
||||
module: "PGP",
|
||||
description: [
|
||||
"Input: the ASCII-armoured PGP message you want to decrypt.",
|
||||
"<br><br>",
|
||||
"Arguments: the ASCII-armoured PGP private key of the recipient, ",
|
||||
"(and the private key password if necessary).",
|
||||
"<br><br>",
|
||||
"Pretty Good Privacy is an encryption standard (OpenPGP) used for encrypting, decrypting, and signing messages.",
|
||||
"<br><br>",
|
||||
"This function uses the Keybase implementation of PGP.",
|
||||
].join("\n"),
|
||||
inputType: "string",
|
||||
outputType: "string",
|
||||
args: [
|
||||
{
|
||||
name: "Private key of recipient",
|
||||
type: "text",
|
||||
value: ""
|
||||
},
|
||||
{
|
||||
name: "Private key passphrase",
|
||||
type: "string",
|
||||
value: ""
|
||||
},
|
||||
]
|
||||
},
|
||||
"PGP Encrypt and Sign": {
|
||||
module: "PGP",
|
||||
description: [
|
||||
"Input: the cleartext you want to sign.",
|
||||
"<br><br>",
|
||||
"Arguments: the ASCII-armoured private key of the signer (plus the private key password if necessary)",
|
||||
"and the ASCII-armoured PGP public key of the recipient.",
|
||||
"<br><br>",
|
||||
"This operation uses PGP to produce an encrypted digital signature.",
|
||||
"<br><br>",
|
||||
"Pretty Good Privacy is an encryption standard (OpenPGP) used for encrypting, decrypting, and signing messages.",
|
||||
"<br><br>",
|
||||
"This function uses the Keybase implementation of PGP.",
|
||||
].join("\n"),
|
||||
inputType: "string",
|
||||
outputType: "string",
|
||||
args: [
|
||||
{
|
||||
name: "Private key of signer",
|
||||
type: "text",
|
||||
value: ""
|
||||
},
|
||||
{
|
||||
name: "Private key passphrase",
|
||||
type: "string",
|
||||
value: ""
|
||||
},
|
||||
{
|
||||
name: "Public key of recipient",
|
||||
type: "text",
|
||||
value: ""
|
||||
},
|
||||
]
|
||||
},
|
||||
"PGP Decrypt and Verify": {
|
||||
module: "PGP",
|
||||
description: [
|
||||
"Input: the ASCII-armoured encrypted PGP message you want to verify.",
|
||||
"<br><br>",
|
||||
"Arguments: the ASCII-armoured PGP public key of the signer, ",
|
||||
"the ASCII-armoured private key of the recipient (and the private key password if necessary).",
|
||||
"<br><br>",
|
||||
"This operation uses PGP to decrypt and verify an encrypted digital signature.",
|
||||
"<br><br>",
|
||||
"Pretty Good Privacy is an encryption standard (OpenPGP) used for encrypting, decrypting, and signing messages.",
|
||||
"<br><br>",
|
||||
"This function uses the Keybase implementation of PGP.",
|
||||
].join("\n"),
|
||||
inputType: "string",
|
||||
outputType: "string",
|
||||
args: [
|
||||
{
|
||||
name: "Public key of signer",
|
||||
type: "text",
|
||||
value: "",
|
||||
},
|
||||
{
|
||||
name: "Private key of recipient",
|
||||
type: "text",
|
||||
value: "",
|
||||
},
|
||||
{
|
||||
name: "Private key password",
|
||||
type: "string",
|
||||
value: "",
|
||||
},
|
||||
]
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
|
||||
22
src/core/config/modules/BSON.js
Normal file
22
src/core/config/modules/BSON.js
Normal 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;
|
||||
@@ -29,6 +29,8 @@ import StrUtils from "../../operations/StrUtils.js";
|
||||
import Tidy from "../../operations/Tidy.js";
|
||||
import Unicode from "../../operations/Unicode.js";
|
||||
import UUID from "../../operations/UUID.js";
|
||||
import XKCD from "../../operations/XKCD.js";
|
||||
|
||||
|
||||
/**
|
||||
* Default module.
|
||||
@@ -41,6 +43,7 @@ import UUID from "../../operations/UUID.js";
|
||||
* - otp
|
||||
* - crypto
|
||||
* - bignumber.js
|
||||
* - jsesc
|
||||
*
|
||||
* @author n1474335 [n1474335@gmail.com]
|
||||
* @copyright Crown Copyright 2017
|
||||
@@ -79,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,
|
||||
@@ -90,7 +94,7 @@ OpModules.Default = {
|
||||
"Bit shift right": BitwiseOp.runBitShiftRight,
|
||||
"XOR": BitwiseOp.runXor,
|
||||
"XOR Brute Force": BitwiseOp.runXorBrute,
|
||||
"OR": BitwiseOp.runXor,
|
||||
"OR": BitwiseOp.runOr,
|
||||
"NOT": BitwiseOp.runNot,
|
||||
"AND": BitwiseOp.runAnd,
|
||||
"ADD": BitwiseOp.runAdd,
|
||||
@@ -161,6 +165,7 @@ OpModules.Default = {
|
||||
"Standard Deviation": Arithmetic.runStdDev,
|
||||
"Windows Filetime to UNIX Timestamp": Filetime.runFromFiletimeToUnix,
|
||||
"UNIX Timestamp to Windows Filetime": Filetime.runToFiletimeFromUnix,
|
||||
"XKCD Random Number": XKCD.runRandomNumber,
|
||||
|
||||
|
||||
/*
|
||||
|
||||
@@ -18,31 +18,39 @@ import Hash from "../../operations/Hash.js";
|
||||
let OpModules = typeof self === "undefined" ? {} : self.OpModules || {};
|
||||
|
||||
OpModules.Hashing = {
|
||||
"Analyse hash": Hash.runAnalyse,
|
||||
"Generate all hashes": Hash.runAll,
|
||||
"MD2": Hash.runMD2,
|
||||
"MD4": Hash.runMD4,
|
||||
"MD5": Hash.runMD5,
|
||||
"MD6": Hash.runMD6,
|
||||
"SHA0": Hash.runSHA0,
|
||||
"SHA1": Hash.runSHA1,
|
||||
"SHA2": Hash.runSHA2,
|
||||
"SHA3": Hash.runSHA3,
|
||||
"Keccak": Hash.runKeccak,
|
||||
"Shake": Hash.runShake,
|
||||
"RIPEMD": Hash.runRIPEMD,
|
||||
"HAS-160": Hash.runHAS,
|
||||
"Whirlpool": Hash.runWhirlpool,
|
||||
"Snefru": Hash.runSnefru,
|
||||
"HMAC": Hash.runHMAC,
|
||||
"Fletcher-8 Checksum": Checksum.runFletcher8,
|
||||
"Fletcher-16 Checksum": Checksum.runFletcher16,
|
||||
"Fletcher-32 Checksum": Checksum.runFletcher32,
|
||||
"Fletcher-64 Checksum": Checksum.runFletcher64,
|
||||
"Adler-32 Checksum": Checksum.runAdler32,
|
||||
"CRC-16 Checksum": Checksum.runCRC16,
|
||||
"CRC-32 Checksum": Checksum.runCRC32,
|
||||
"TCP/IP Checksum": Checksum.runTCPIP,
|
||||
"Analyse hash": Hash.runAnalyse,
|
||||
"Generate all hashes": Hash.runAll,
|
||||
"MD2": Hash.runMD2,
|
||||
"MD4": Hash.runMD4,
|
||||
"MD5": Hash.runMD5,
|
||||
"MD6": Hash.runMD6,
|
||||
"SHA0": Hash.runSHA0,
|
||||
"SHA1": Hash.runSHA1,
|
||||
"SHA2": Hash.runSHA2,
|
||||
"SHA3": Hash.runSHA3,
|
||||
"Keccak": Hash.runKeccak,
|
||||
"Shake": Hash.runShake,
|
||||
"RIPEMD": Hash.runRIPEMD,
|
||||
"HAS-160": Hash.runHAS,
|
||||
"Whirlpool": Hash.runWhirlpool,
|
||||
"Snefru": Hash.runSnefru,
|
||||
"CTPH": Hash.runCTPH,
|
||||
"SSDEEP": Hash.runSSDEEP,
|
||||
"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,
|
||||
"Fletcher-64 Checksum": Checksum.runFletcher64,
|
||||
"Adler-32 Checksum": Checksum.runAdler32,
|
||||
"CRC-16 Checksum": Checksum.runCRC16,
|
||||
"CRC-32 Checksum": Checksum.runCRC32,
|
||||
"TCP/IP Checksum": Checksum.runTCPIP,
|
||||
};
|
||||
|
||||
export default OpModules;
|
||||
|
||||
@@ -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,
|
||||
|
||||
25
src/core/config/modules/PGP.js
Normal file
25
src/core/config/modules/PGP.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import PGP from "../../operations/PGP.js";
|
||||
|
||||
|
||||
/**
|
||||
* PGP module.
|
||||
*
|
||||
* Libraries:
|
||||
* - kbpgp
|
||||
*
|
||||
* @author tlwr [toby@toby.codes]
|
||||
* @author Matt C [matt@artemisbot.uk]
|
||||
* @copyright Crown Copyright 2017
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
let OpModules = typeof self === "undefined" ? {} : self.OpModules || {};
|
||||
|
||||
OpModules.PGP = {
|
||||
"Generate PGP Key Pair": PGP.runGenerateKeyPair,
|
||||
"PGP Encrypt": PGP.runEncrypt,
|
||||
"PGP Decrypt": PGP.runDecrypt,
|
||||
"PGP Encrypt and Sign": PGP.runSign,
|
||||
"PGP Decrypt and Verify": PGP.runVerify,
|
||||
};
|
||||
|
||||
export default OpModules;
|
||||
@@ -1443,8 +1443,8 @@ const Operands = [
|
||||
------------------------------------------------------------------------------------------------------------------------*/
|
||||
"10000004","10000004","10000004","10000004",
|
||||
"16000C00","170E0C00","0C001600","0C00170E",
|
||||
"10020008",
|
||||
"10020008",
|
||||
"110E0008",
|
||||
"110E0008",
|
||||
"0D060C01", //JMP Ap (w:z).
|
||||
"100000040004",
|
||||
"16001A01","170E1A01",
|
||||
@@ -5703,7 +5703,6 @@ function LDisassemble()
|
||||
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
59
src/core/operations/BSON.js
Normal file
59
src/core/operations/BSON.js
Normal 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;
|
||||
@@ -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
|
||||
|
||||
@@ -120,7 +120,7 @@ const Checksum = {
|
||||
/**
|
||||
* CRC-32 Checksum operation.
|
||||
*
|
||||
* @param {string} input
|
||||
* @param {ArrayBuffer} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
@@ -132,7 +132,7 @@ const Checksum = {
|
||||
/**
|
||||
* CRC-16 Checksum operation.
|
||||
*
|
||||
* @param {string} input
|
||||
* @param {ArrayBuffer} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
},
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
},
|
||||
|
||||
@@ -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"}`;
|
||||
},
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
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";
|
||||
import ctph from "ctph.js";
|
||||
import ssdeep from "ssdeep.js";
|
||||
import bcrypt from "bcryptjs";
|
||||
import scrypt from "scryptsy";
|
||||
|
||||
|
||||
/**
|
||||
@@ -20,22 +24,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 +51,7 @@ const Hash = {
|
||||
/**
|
||||
* MD4 operation.
|
||||
*
|
||||
* @param {string} input
|
||||
* @param {ArrayBuffer} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
@@ -59,7 +63,7 @@ const Hash = {
|
||||
/**
|
||||
* MD5 operation.
|
||||
*
|
||||
* @param {string} input
|
||||
* @param {ArrayBuffer} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
@@ -103,7 +107,7 @@ const Hash = {
|
||||
/**
|
||||
* SHA0 operation.
|
||||
*
|
||||
* @param {string} input
|
||||
* @param {ArrayBuffer} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
@@ -115,7 +119,7 @@ const Hash = {
|
||||
/**
|
||||
* SHA1 operation.
|
||||
*
|
||||
* @param {string} input
|
||||
* @param {ArrayBuffer} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
@@ -133,7 +137,7 @@ const Hash = {
|
||||
/**
|
||||
* SHA2 operation.
|
||||
*
|
||||
* @param {string} input
|
||||
* @param {ArrayBuffer} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
@@ -152,7 +156,7 @@ const Hash = {
|
||||
/**
|
||||
* SHA3 operation.
|
||||
*
|
||||
* @param {string} input
|
||||
* @param {ArrayBuffer} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
@@ -190,7 +194,7 @@ const Hash = {
|
||||
/**
|
||||
* Keccak operation.
|
||||
*
|
||||
* @param {string} input
|
||||
* @param {ArrayBuffer} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
@@ -233,7 +237,7 @@ const Hash = {
|
||||
/**
|
||||
* Shake operation.
|
||||
*
|
||||
* @param {string} input
|
||||
* @param {ArrayBuffer} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
@@ -269,7 +273,7 @@ const Hash = {
|
||||
/**
|
||||
* RIPEMD operation.
|
||||
*
|
||||
* @param {string} input
|
||||
* @param {ArrayBuffer} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
@@ -282,7 +286,7 @@ const Hash = {
|
||||
/**
|
||||
* HAS-160 operation.
|
||||
*
|
||||
* @param {string} input
|
||||
* @param {ArrayBuffer} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
@@ -300,7 +304,7 @@ const Hash = {
|
||||
/**
|
||||
* Whirlpool operation.
|
||||
*
|
||||
* @param {string} input
|
||||
* @param {ArrayBuffer} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
@@ -324,14 +328,73 @@ 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]
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* CTPH operation.
|
||||
*
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
runCTPH: function (input, args) {
|
||||
return ctph.digest(input);
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* SSDEEP operation.
|
||||
*
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
runSSDEEP: function (input, args) {
|
||||
return ssdeep.digest(input);
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
DELIM_OPTIONS: ["Line feed", "CRLF", "Space", "Comma"],
|
||||
|
||||
/**
|
||||
* Compare CTPH hashes operation.
|
||||
*
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {Number}
|
||||
*/
|
||||
runCompareCTPH: function (input, args) {
|
||||
const samples = input.split(Utils.charRep[args[0]]);
|
||||
if (samples.length !== 2) throw "Incorrect number of samples.";
|
||||
return ctph.similarity(samples[0], samples[1]);
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Compare SSDEEP hashes operation.
|
||||
*
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {Number}
|
||||
*/
|
||||
runCompareSSDEEP: function (input, args) {
|
||||
const samples = input.split(Utils.charRep[args[0]]);
|
||||
if (samples.length !== 2) throw "Incorrect number of samples.";
|
||||
return ssdeep.similarity(samples[0], samples[1]);
|
||||
},
|
||||
|
||||
|
||||
@@ -358,71 +421,206 @@ 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());
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* @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.
|
||||
*
|
||||
* @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"]) +
|
||||
"\nSSDEEP: " + Hash.runSSDEEP(str) +
|
||||
"\nCTPH: " + Hash.runCTPH(str) +
|
||||
"\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;
|
||||
},
|
||||
|
||||
@@ -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))) {
|
||||
|
||||
@@ -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(
|
||||
|
||||
358
src/core/operations/PGP.js
Executable file
358
src/core/operations/PGP.js
Executable file
@@ -0,0 +1,358 @@
|
||||
import * as kbpgp from "kbpgp";
|
||||
import {promisify} from "es6-promisify";
|
||||
|
||||
|
||||
/**
|
||||
* PGP operations.
|
||||
*
|
||||
* @author tlwr [toby@toby.codes]
|
||||
* @author Matt C [matt@artemisbot.uk]
|
||||
* @author n1474335 [n1474335@gmail.com]
|
||||
* @copyright Crown Copyright 2017
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* @namespace
|
||||
*/
|
||||
const PGP = {
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
KEY_TYPES: ["RSA-1024", "RSA-2048", "RSA-4096", "ECC-256", "ECC-384"],
|
||||
|
||||
|
||||
/**
|
||||
* Get size of subkey
|
||||
*
|
||||
* @private
|
||||
* @param {number} keySize
|
||||
* @returns {number}
|
||||
*/
|
||||
_getSubkeySize(keySize) {
|
||||
return {
|
||||
1024: 1024,
|
||||
2048: 1024,
|
||||
4096: 2048,
|
||||
256: 256,
|
||||
384: 256,
|
||||
}[keySize];
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Progress callback
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
_ASP: new kbpgp.ASP({
|
||||
"progress_hook": info => {
|
||||
let msg = "";
|
||||
|
||||
switch (info.what) {
|
||||
case "guess":
|
||||
msg = "Guessing a prime";
|
||||
break;
|
||||
case "fermat":
|
||||
msg = "Factoring prime using Fermat's factorization method";
|
||||
break;
|
||||
case "mr":
|
||||
msg = "Performing Miller-Rabin primality test";
|
||||
break;
|
||||
case "passed_mr":
|
||||
msg = "Passed Miller-Rabin primality test";
|
||||
break;
|
||||
case "failed_mr":
|
||||
msg = "Failed Miller-Rabin primality test";
|
||||
break;
|
||||
case "found":
|
||||
msg = "Prime found";
|
||||
break;
|
||||
default:
|
||||
msg = `Stage: ${info.what}`;
|
||||
}
|
||||
|
||||
if (ENVIRONMENT_IS_WORKER())
|
||||
self.sendStatusMessage(msg);
|
||||
}
|
||||
}),
|
||||
|
||||
|
||||
/**
|
||||
* Import private key and unlock if necessary
|
||||
*
|
||||
* @private
|
||||
* @param {string} privateKey
|
||||
* @param {string} [passphrase]
|
||||
* @returns {Object}
|
||||
*/
|
||||
async _importPrivateKey(privateKey, passphrase) {
|
||||
try {
|
||||
const key = await promisify(kbpgp.KeyManager.import_from_armored_pgp)({
|
||||
armored: privateKey,
|
||||
});
|
||||
if (key.is_pgp_locked() && passphrase) {
|
||||
if (passphrase) {
|
||||
await promisify(key.unlock_pgp.bind(key))({
|
||||
passphrase
|
||||
});
|
||||
} else if (!passphrase) {
|
||||
throw "Did not provide passphrase with locked private key.";
|
||||
}
|
||||
}
|
||||
return key;
|
||||
} catch (err) {
|
||||
throw `Could not import private key: ${err}`;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Import public key
|
||||
*
|
||||
* @private
|
||||
* @param {string} publicKey
|
||||
* @returns {Object}
|
||||
*/
|
||||
async _importPublicKey (publicKey) {
|
||||
try {
|
||||
const key = await promisify(kbpgp.KeyManager.import_from_armored_pgp)({
|
||||
armored: publicKey,
|
||||
});
|
||||
return key;
|
||||
} catch (err) {
|
||||
throw `Could not import public key: ${err}`;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Generate PGP Key Pair operation.
|
||||
*
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
runGenerateKeyPair(input, args) {
|
||||
let [keyType, keySize] = args[0].split("-"),
|
||||
password = args[1],
|
||||
name = args[2],
|
||||
email = args[3],
|
||||
userIdentifier = "";
|
||||
|
||||
if (name) userIdentifier += name;
|
||||
if (email) userIdentifier += ` <${email}>`;
|
||||
|
||||
let flags = kbpgp.const.openpgp.certify_keys;
|
||||
flags |= kbpgp.const.openpgp.sign_data;
|
||||
flags |= kbpgp.const.openpgp.auth;
|
||||
flags |= kbpgp.const.openpgp.encrypt_comm;
|
||||
flags |= kbpgp.const.openpgp.encrypt_storage;
|
||||
|
||||
let keyGenerationOptions = {
|
||||
userid: userIdentifier,
|
||||
ecc: keyType === "ecc",
|
||||
primary: {
|
||||
"nbits": keySize,
|
||||
"flags": flags,
|
||||
"expire_in": 0
|
||||
},
|
||||
subkeys: [{
|
||||
"nbits": PGP._getSubkeySize(keySize),
|
||||
"flags": kbpgp.const.openpgp.sign_data,
|
||||
"expire_in": 86400 * 365 * 8
|
||||
}, {
|
||||
"nbits": PGP._getSubkeySize(keySize),
|
||||
"flags": kbpgp.const.openpgp.encrypt_comm | kbpgp.const.openpgp.encrypt_storage,
|
||||
"expire_in": 86400 * 365 * 2
|
||||
}],
|
||||
asp: PGP._ASP
|
||||
};
|
||||
|
||||
return new Promise(async (resolve, reject) => {
|
||||
try {
|
||||
const unsignedKey = await promisify(kbpgp.KeyManager.generate)(keyGenerationOptions);
|
||||
await promisify(unsignedKey.sign.bind(unsignedKey))({});
|
||||
let signedKey = unsignedKey;
|
||||
let privateKeyExportOptions = {};
|
||||
if (password) privateKeyExportOptions.passphrase = password;
|
||||
const privateKey = await promisify(signedKey.export_pgp_private.bind(signedKey))(privateKeyExportOptions);
|
||||
const publicKey = await promisify(signedKey.export_pgp_public.bind(signedKey))({});
|
||||
resolve(privateKey + "\n" + publicKey.trim());
|
||||
} catch (err) {
|
||||
reject(`Error whilst generating key pair: ${err}`);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* PGP Encrypt operation.
|
||||
*
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
async runEncrypt(input, args) {
|
||||
let plaintextMessage = input,
|
||||
plainPubKey = args[0],
|
||||
key,
|
||||
encryptedMessage;
|
||||
|
||||
if (!plainPubKey) return "Enter the public key of the recipient.";
|
||||
|
||||
try {
|
||||
key = await promisify(kbpgp.KeyManager.import_from_armored_pgp)({
|
||||
armored: plainPubKey,
|
||||
});
|
||||
} catch (err) {
|
||||
throw `Could not import public key: ${err}`;
|
||||
}
|
||||
|
||||
try {
|
||||
encryptedMessage = await promisify(kbpgp.box)({
|
||||
"msg": plaintextMessage,
|
||||
"encrypt_for": key,
|
||||
"asp": PGP._ASP
|
||||
});
|
||||
} catch (err) {
|
||||
throw `Couldn't encrypt message with provided public key: ${err}`;
|
||||
}
|
||||
|
||||
return encryptedMessage.toString();
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* PGP Decrypt operation.
|
||||
*
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
async runDecrypt(input, args) {
|
||||
let encryptedMessage = input,
|
||||
privateKey = args[0],
|
||||
passphrase = args[1],
|
||||
keyring = new kbpgp.keyring.KeyRing(),
|
||||
plaintextMessage;
|
||||
|
||||
if (!privateKey) return "Enter the private key of the recipient.";
|
||||
|
||||
const key = await PGP._importPrivateKey(privateKey, passphrase);
|
||||
keyring.add_key_manager(key);
|
||||
|
||||
try {
|
||||
plaintextMessage = await promisify(kbpgp.unbox)({
|
||||
armored: encryptedMessage,
|
||||
keyfetch: keyring,
|
||||
asp: PGP._ASP
|
||||
});
|
||||
} catch (err) {
|
||||
throw `Couldn't decrypt message with provided private key: ${err}`;
|
||||
}
|
||||
|
||||
return plaintextMessage.toString();
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* PGP Sign Message operation.
|
||||
*
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
async runSign(input, args) {
|
||||
let message = input,
|
||||
privateKey = args[0],
|
||||
passphrase = args[1],
|
||||
publicKey = args[2],
|
||||
signedMessage;
|
||||
|
||||
if (!privateKey) return "Enter the private key of the signer.";
|
||||
if (!publicKey) return "Enter the public key of the recipient.";
|
||||
const privKey = await PGP._importPrivateKey(privateKey, passphrase);
|
||||
const pubKey = await PGP._importPublicKey(publicKey);
|
||||
|
||||
try {
|
||||
signedMessage = await promisify(kbpgp.box)({
|
||||
"msg": message,
|
||||
"encrypt_for": pubKey,
|
||||
"sign_with": privKey,
|
||||
"asp": PGP._ASP
|
||||
});
|
||||
} catch (err) {
|
||||
throw `Couldn't sign message: ${err}`;
|
||||
}
|
||||
|
||||
return signedMessage;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* PGP Verify Message operation.
|
||||
*
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
async runVerify(input, args) {
|
||||
let signedMessage = input,
|
||||
publicKey = args[0],
|
||||
privateKey = args[1],
|
||||
passphrase = args[2],
|
||||
keyring = new kbpgp.keyring.KeyRing(),
|
||||
unboxedLiterals;
|
||||
|
||||
if (!publicKey) return "Enter the public key of the signer.";
|
||||
if (!privateKey) return "Enter the private key of the recipient.";
|
||||
const privKey = await PGP._importPrivateKey(privateKey, passphrase);
|
||||
const pubKey = await PGP._importPublicKey(publicKey);
|
||||
keyring.add_key_manager(privKey);
|
||||
keyring.add_key_manager(pubKey);
|
||||
|
||||
try {
|
||||
unboxedLiterals = await promisify(kbpgp.unbox)({
|
||||
armored: signedMessage,
|
||||
keyfetch: keyring,
|
||||
asp: PGP._ASP
|
||||
});
|
||||
const ds = unboxedLiterals[0].get_data_signer();
|
||||
if (ds) {
|
||||
const km = ds.get_key_manager();
|
||||
if (km) {
|
||||
const signer = km.get_userids_mark_primary()[0].components;
|
||||
let text = "Signed by ";
|
||||
if (signer.email || signer.username || signer.comment) {
|
||||
if (signer.username) {
|
||||
text += `${signer.username} `;
|
||||
}
|
||||
if (signer.comment) {
|
||||
text += `${signer.comment} `;
|
||||
}
|
||||
if (signer.email) {
|
||||
text += `<${signer.email}>`;
|
||||
}
|
||||
text += "\n";
|
||||
}
|
||||
text += [
|
||||
`PGP fingerprint: ${km.get_pgp_fingerprint().toString("hex")}`,
|
||||
`Signed on ${new Date(ds.sig.hashed_subpackets[0].time * 1000).toUTCString()}`,
|
||||
"----------------------------------\n"
|
||||
].join("\n");
|
||||
text += unboxedLiterals.toString();
|
||||
return text.trim();
|
||||
} else {
|
||||
return "Could not identify a key manager.";
|
||||
}
|
||||
} else {
|
||||
return "The data does not appear to be signed.";
|
||||
}
|
||||
} catch (err) {
|
||||
return `Couldn't verify message: ${err}`;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export default PGP;
|
||||
@@ -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",
|
||||
|
||||
@@ -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);
|
||||
},
|
||||
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ const Unicode = {
|
||||
*/
|
||||
runUnescape: function(input, args) {
|
||||
let prefix = Unicode._prefixToRegex[args[0]],
|
||||
regex = new RegExp(prefix+"([a-f\\d]{4,6})", "ig"),
|
||||
regex = new RegExp(prefix+"([a-f\\d]{4})", "ig"),
|
||||
output = "",
|
||||
m,
|
||||
i = 0;
|
||||
@@ -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)) {
|
||||
// It’s a printable ASCII character so don’t 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.
|
||||
*
|
||||
|
||||
26
src/core/operations/XKCD.js
Executable file
26
src/core/operations/XKCD.js
Executable file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* XKCD operations.
|
||||
*
|
||||
* @author n1474335 [n1474335@gmail.com]
|
||||
* @copyright Crown Copyright 2018
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* @namespace
|
||||
*/
|
||||
const XKCD = {
|
||||
|
||||
/**
|
||||
* XKCD Random Number operation.
|
||||
*
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {number}
|
||||
*/
|
||||
runRandomNumber: function(input, args) {
|
||||
return 4; // chosen by fair dice roll.
|
||||
// guaranteed to be random.
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
export default XKCD;
|
||||
@@ -82,6 +82,9 @@ App.prototype.loaded = function() {
|
||||
// Clear the loading message interval
|
||||
clearInterval(window.loadingMsgsInt);
|
||||
|
||||
// Remove the loading error handler
|
||||
window.removeEventListener("error", window.loadingErrorHandler);
|
||||
|
||||
document.dispatchEvent(this.manager.apploaded);
|
||||
};
|
||||
|
||||
@@ -377,6 +380,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 +391,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();
|
||||
};
|
||||
|
||||
|
||||
@@ -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})
|
||||
|
||||
`;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -110,6 +110,15 @@ HTMLOperation.prototype.highlightSearchString = function(searchStr, namePos, des
|
||||
}
|
||||
|
||||
if (this.description && descPos >= 0) {
|
||||
// Find HTML tag offsets
|
||||
const re = /<[^>]+>/g;
|
||||
let match;
|
||||
while ((match = re.exec(this.description))) {
|
||||
// If the search string occurs within an HTML tag, return without highlighting it.
|
||||
if (descPos >= match.index && descPos <= (match.index + match[0].length))
|
||||
return;
|
||||
}
|
||||
|
||||
this.description = this.description.slice(0, descPos) + "<b><u>" +
|
||||
this.description.slice(descPos, descPos + searchStr.length) + "</u></b>" +
|
||||
this.description.slice(descPos + searchStr.length);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import LoaderWorker from "worker-loader?inline&fallback=false!./LoaderWorker.js";
|
||||
import Utils from "../core/Utils.js";
|
||||
|
||||
|
||||
/**
|
||||
@@ -263,11 +264,28 @@ InputWaiter.prototype.handleLoaderMessage = function(e) {
|
||||
if (r.hasOwnProperty("fileBuffer")) {
|
||||
log.debug("Input file loaded");
|
||||
this.fileBuffer = r.fileBuffer;
|
||||
this.displayFilePreview();
|
||||
window.dispatchEvent(this.manager.statechange);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Shows a chunk of the file in the input behind the file overlay.
|
||||
*/
|
||||
InputWaiter.prototype.displayFilePreview = function() {
|
||||
const inputText = document.getElementById("input-text"),
|
||||
fileSlice = this.fileBuffer.slice(0, 4096);
|
||||
|
||||
inputText.style.overflow = "hidden";
|
||||
inputText.classList.add("blur");
|
||||
inputText.value = Utils.printable(Utils.arrayBufferToStr(fileSlice));
|
||||
if (this.fileBuffer.byteLength > 4096) {
|
||||
inputText.value += "[truncated]...";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Handler for file close events.
|
||||
*/
|
||||
@@ -275,6 +293,9 @@ InputWaiter.prototype.closeFile = function() {
|
||||
if (this.loaderWorker) this.loaderWorker.terminate();
|
||||
this.fileBuffer = null;
|
||||
document.getElementById("input-file").style.display = "none";
|
||||
const inputText = document.getElementById("input-text");
|
||||
inputText.style.overflow = "auto";
|
||||
inputText.classList.remove("blur");
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ self.loadFile = function(file) {
|
||||
};
|
||||
|
||||
reader.onerror = function(e) {
|
||||
self.postMessage({"error": file.error.message});
|
||||
self.postMessage({"error": reader.error.message});
|
||||
};
|
||||
|
||||
seek();
|
||||
|
||||
@@ -128,6 +128,13 @@ OutputWaiter.prototype.setFile = function(buf) {
|
||||
|
||||
fileOverlay.style.display = "block";
|
||||
fileSize.textContent = file.size.toLocaleString() + " bytes";
|
||||
|
||||
// Display preview slice in the background
|
||||
const outputText = document.getElementById("output-text"),
|
||||
fileSlice = this.dishBuffer.slice(0, 4096);
|
||||
|
||||
outputText.classList.add("blur");
|
||||
outputText.value = Utils.printable(Utils.arrayBufferToStr(fileSlice));
|
||||
};
|
||||
|
||||
|
||||
@@ -137,6 +144,7 @@ OutputWaiter.prototype.setFile = function(buf) {
|
||||
OutputWaiter.prototype.closeFile = function() {
|
||||
this.dishBuffer = null;
|
||||
document.getElementById("output-file").style.display = "none";
|
||||
document.getElementById("output-text").classList.remove("blur");
|
||||
};
|
||||
|
||||
|
||||
@@ -163,6 +171,7 @@ OutputWaiter.prototype.displayFileSlice = function() {
|
||||
sliceTo = parseInt(sliceToEl.value, 10),
|
||||
str = Utils.arrayBufferToStr(this.dishBuffer.slice(sliceFrom, sliceTo));
|
||||
|
||||
document.getElementById("output-text").classList.remove("blur");
|
||||
showFileOverlay.style.display = "block";
|
||||
this.set(str, "string", new Date().getTime() - startTime, true);
|
||||
};
|
||||
@@ -177,6 +186,7 @@ OutputWaiter.prototype.showFileOverlayClick = function(e) {
|
||||
const outputFile = document.getElementById("output-file"),
|
||||
showFileOverlay = e.target;
|
||||
|
||||
document.getElementById("output-text").classList.add("blur");
|
||||
outputFile.style.display = "block";
|
||||
showFileOverlay.style.display = "none";
|
||||
this.setOutputInfo(this.dishBuffer.byteLength, null, 0);
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
}
|
||||
|
||||
// Define loading messages
|
||||
const loadingMsgs = [
|
||||
var loadingMsgs = [
|
||||
"Proving P = NP...",
|
||||
"Computing 6 x 9...",
|
||||
"Mining bitcoin...",
|
||||
@@ -66,18 +66,18 @@
|
||||
|
||||
// Shuffle array using Durstenfeld algorithm
|
||||
for (let i = loadingMsgs.length - 1; i > 0; --i) {
|
||||
const j = Math.floor(Math.random() * (i + 1));
|
||||
const temp = loadingMsgs[i];
|
||||
var j = Math.floor(Math.random() * (i + 1));
|
||||
var temp = loadingMsgs[i];
|
||||
loadingMsgs[i] = loadingMsgs[j];
|
||||
loadingMsgs[j] = temp;
|
||||
}
|
||||
|
||||
// Show next loading message and move it to the end of the array
|
||||
function changeLoadingMsg() {
|
||||
const msg = loadingMsgs.shift();
|
||||
var msg = loadingMsgs.shift();
|
||||
loadingMsgs.push(msg);
|
||||
try {
|
||||
const el = document.getElementById("preloader-msg");
|
||||
var el = document.getElementById("preloader-msg");
|
||||
if (!el.classList.contains("loading"))
|
||||
el.classList.add("loading"); // Causes CSS transition on first message
|
||||
el.innerHTML = msg;
|
||||
@@ -86,8 +86,50 @@
|
||||
|
||||
changeLoadingMsg();
|
||||
window.loadingMsgsInt = setInterval(changeLoadingMsg, (Math.random() * 2000) + 1500);
|
||||
|
||||
// If any errors are thrown during loading, handle them here
|
||||
function loadingErrorHandler(e) {
|
||||
function escapeHtml(str) {
|
||||
var HTML_CHARS = {
|
||||
"&": "&",
|
||||
"<": "<",
|
||||
">": ">",
|
||||
'"': """,
|
||||
"'": "'", // ' not recommended because it's not in the HTML spec
|
||||
"/": "/", // forward slash is included as it helps end an HTML entity
|
||||
"`": "`"
|
||||
};
|
||||
|
||||
return str.replace(/[&<>"'/`]/g, function (match) {
|
||||
return HTML_CHARS[match];
|
||||
});
|
||||
}
|
||||
|
||||
var msg = e.message +
|
||||
(e.filename ? "\nFilename: " + e.filename : "") +
|
||||
(e.lineno ? "\nLine: " + e.lineno : "") +
|
||||
(e.colno ? "\nColumn: " + e.colno : "") +
|
||||
(e.error ? "\nError: " + e.error : "") +
|
||||
"\nUser-Agent: " + navigator.userAgent +
|
||||
"\nCyberChef version: <%= htmlWebpackPlugin.options.version %>";
|
||||
|
||||
clearInterval(window.loadingMsgsInt);
|
||||
document.getElementById("preloader").remove();
|
||||
document.getElementById("preloader-msg").remove();
|
||||
document.getElementById("preloader-error").innerHTML =
|
||||
"CyberChef encountered an error while loading.<br><br>" +
|
||||
"The following browser versions are supported:" +
|
||||
"<ul><li>Google Chrome 40+</li><li>Mozilla Firefox 35+</li><li>Microsoft Edge 14+</li></ul>" +
|
||||
"Your user agent is:<br>" + escapeHtml(navigator.userAgent) + "<br><br>" +
|
||||
"If your browser is supported, please <a href='https://github.com/gchq/CyberChef/issues/new'>" +
|
||||
"raise an issue</a> including the following details:<br><br>" +
|
||||
"<pre>" + escapeHtml(msg) + "</pre>";
|
||||
};
|
||||
window.addEventListener("error", loadingErrorHandler);
|
||||
</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>
|
||||
@@ -98,6 +140,7 @@
|
||||
<div id="loader-wrapper">
|
||||
<div id="preloader" class="loader"></div>
|
||||
<div id="preloader-msg" class="loading-msg"></div>
|
||||
<div id="preloader-error" class="loading-error"></div>
|
||||
</div>
|
||||
<!-- End preloader overlay -->
|
||||
<span id="edit-favourites" class="btn btn-default btn-sm"><img aria-hidden="true" src="<%- require('../static/images/favourite-16x16.png') %>" alt="Star Icon"/> Edit</span>
|
||||
@@ -183,8 +226,9 @@
|
||||
</div>
|
||||
<div class="textarea-wrapper no-select">
|
||||
<div id="input-highlighter" class="no-select"></div>
|
||||
<textarea id="input-text"></textarea>
|
||||
<textarea id="input-text" spellcheck="false"></textarea>
|
||||
<div id="input-file">
|
||||
<div class="file-overlay"></div>
|
||||
<div style="position: relative; height: 100%;">
|
||||
<div class="card">
|
||||
<img aria-hidden="true" src="<%- require('../static/images/file-128x128.png') %>" alt="File icon"/>
|
||||
@@ -218,9 +262,10 @@
|
||||
<div class="textarea-wrapper">
|
||||
<div id="output-highlighter" class="no-select"></div>
|
||||
<div id="output-html"></div>
|
||||
<textarea id="output-text" readonly="readonly"></textarea>
|
||||
<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"/>
|
||||
<div id="output-file">
|
||||
<div class="file-overlay"></div>
|
||||
<div style="position: relative; height: 100%;">
|
||||
<div class="card">
|
||||
<img aria-hidden="true" src="<%- require('../static/images/file-128x128.png') %>" alt="File icon"/>
|
||||
@@ -233,7 +278,7 @@
|
||||
</span>
|
||||
<input type="number" class="form-control" id="output-file-slice-from" placeholder="From" value="0" step="1024" min="0">
|
||||
<div class="input-group-addon">to</div>
|
||||
<input type="number" class="form-control" id="output-file-slice-to" placeholder="To" value="1024" step="1024" min="0">
|
||||
<input type="number" class="form-control" id="output-file-slice-to" placeholder="To" value="2048" step="1024" min="0">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -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
|
||||
@@ -63,3 +64,4 @@ window.compileMessage = COMPILE_MSG;
|
||||
window.CanvasComponents = CanvasComponents;
|
||||
|
||||
document.addEventListener("DOMContentLoaded", main, false);
|
||||
|
||||
|
||||
33
src/web/static/sitemap.js
Normal file
33
src/web/static/sitemap.js
Normal 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
|
||||
@@ -84,10 +84,17 @@
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: var(--title-background-colour);
|
||||
display: none;
|
||||
}
|
||||
|
||||
.file-overlay {
|
||||
position: absolute;
|
||||
opacity: 0.8;
|
||||
background-color: var(--title-background-colour);
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
#show-file-overlay {
|
||||
position: absolute;
|
||||
right: 15px;
|
||||
|
||||
@@ -74,6 +74,14 @@
|
||||
transition: all 0.1s ease-in;
|
||||
}
|
||||
|
||||
.loading-error {
|
||||
display: block;
|
||||
position: relative;
|
||||
width: 600px;
|
||||
left: calc(50% - 300px);
|
||||
top: 10%;
|
||||
}
|
||||
|
||||
|
||||
/* Loaded */
|
||||
.loaded .loading-msg {
|
||||
|
||||
@@ -14,16 +14,20 @@ 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/Checksum.js";
|
||||
import "./tests/operations/Cipher.js";
|
||||
import "./tests/operations/Code.js";
|
||||
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
56
test/tests/operations/BSON.js
Executable 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: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
119
test/tests/operations/Base64.js
Normal file
119
test/tests/operations/Base64.js
Normal 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
151
test/tests/operations/ByteRepr.js
Normal file → Executable 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]
|
||||
}
|
||||
]
|
||||
},
|
||||
]);
|
||||
|
||||
120
test/tests/operations/Checksum.js
Normal file
120
test/tests/operations/Checksum.js
Normal file
@@ -0,0 +1,120 @@
|
||||
/**
|
||||
* Checksum tests.
|
||||
*
|
||||
* @author n1474335 [n1474335@gmail.com]
|
||||
* @copyright Crown Copyright 2018
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
import TestRegister from "../../TestRegister.js";
|
||||
|
||||
const BASIC_STRING = "The ships hung in the sky in much the same way that bricks don't.";
|
||||
const UTF8_STR = "ნუ პანიკას";
|
||||
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: "CRC-16: nothing",
|
||||
input: "",
|
||||
expectedOutput: "0000",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "CRC-16 Checksum",
|
||||
"args": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "CRC-16: basic string",
|
||||
input: BASIC_STRING,
|
||||
expectedOutput: "0c70",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "CRC-16 Checksum",
|
||||
"args": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "CRC-16: UTF-8",
|
||||
input: UTF8_STR,
|
||||
expectedOutput: "dcf6",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "CRC-16 Checksum",
|
||||
"args": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "CRC-16: all bytes",
|
||||
input: ALL_BYTES,
|
||||
expectedOutput: "bad3",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "CRC-16 Checksum",
|
||||
"args": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "CRC-32: nothing",
|
||||
input: "",
|
||||
expectedOutput: "00000000",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "CRC-32 Checksum",
|
||||
"args": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "CRC-32: basic string",
|
||||
input: BASIC_STRING,
|
||||
expectedOutput: "bf4b739c",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "CRC-32 Checksum",
|
||||
"args": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "CRC-32: UTF-8",
|
||||
input: UTF8_STR,
|
||||
expectedOutput: "87553290",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "CRC-32 Checksum",
|
||||
"args": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "CRC-32: all bytes",
|
||||
input: ALL_BYTES,
|
||||
expectedOutput: "29058c73",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "CRC-32 Checksum",
|
||||
"args": []
|
||||
}
|
||||
]
|
||||
},
|
||||
]);
|
||||
100
test/tests/operations/FlowControl.js
Normal file → Executable file
100
test/tests/operations/FlowControl.js
Normal file → Executable 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: [""]
|
||||
}
|
||||
]
|
||||
},
|
||||
]);
|
||||
|
||||
339
test/tests/operations/Hash.js
Normal file → Executable file
339
test/tests/operations/Hash.js
Normal file → Executable file
@@ -415,4 +415,343 @@ 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"]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
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
235
test/tests/operations/Hexdump.js
Executable 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
43
test/tests/operations/StrUtils.js
Normal file → Executable 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": []
|
||||
}
|
||||
],
|
||||
},
|
||||
]);
|
||||
|
||||
@@ -35,7 +35,6 @@ module.exports = {
|
||||
new webpack.ProvidePlugin({
|
||||
$: "jquery",
|
||||
jQuery: "jquery",
|
||||
moment: "moment-timezone",
|
||||
log: "loglevel"
|
||||
}),
|
||||
new webpack.BannerPlugin({
|
||||
@@ -54,7 +53,7 @@ module.exports = {
|
||||
rules: [
|
||||
{
|
||||
test: /\.js$/,
|
||||
exclude: /node_modules/,
|
||||
exclude: /node_modules\/(?!jsesc)/,
|
||||
loader: "babel-loader?compact=false"
|
||||
},
|
||||
{
|
||||
@@ -109,9 +108,13 @@ module.exports = {
|
||||
children: false,
|
||||
chunks: false,
|
||||
modules: false,
|
||||
warningsFilter: /source-map/,
|
||||
entrypoints: false,
|
||||
warningsFilter: [/source-map/, /dependency is an expression/],
|
||||
},
|
||||
node: {
|
||||
fs: "empty"
|
||||
},
|
||||
performance: {
|
||||
hints: false
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user