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

Compare commits

..

183 Commits

Author SHA1 Message Date
n1474335
4acf7b4e4f 8.10.2 2018-11-09 15:25:22 +00:00
n1474335
42e881326f Added 'Binary' key option to all bitwise operations. Closes #398 2018-11-09 15:25:16 +00:00
n1474335
3c4893d7c7 8.10.1 2018-11-07 15:20:51 +00:00
n1474335
027aca4ab2 Merge branch 'qistoph-NumSortHex' 2018-11-07 15:20:43 +00:00
n1474335
2d471f551f Lint 2018-11-07 15:20:09 +00:00
n1474335
5c598b69b0 Merge branch 'NumSortHex' of https://github.com/qistoph/CyberChef into qistoph-NumSortHex 2018-11-07 15:15:39 +00:00
n1474335
037300de79 8.10.0 2018-11-07 15:10:57 +00:00
n1474335
6990dcae89 Updated changelog 2018-11-07 15:10:25 +00:00
n1474335
6e81d6dfcd Merge branch 'klaxon1-feature/remove-letter-accents' 2018-11-07 15:08:09 +00:00
n1474335
cea30465d8 Changed 'Remove Letter Accents' to 'Remove Diacritics' 2018-11-07 15:07:54 +00:00
n1474335
b301d16cb2 Merge branch 'feature/remove-letter-accents' of https://github.com/klaxon1/CyberChef into klaxon1-feature/remove-letter-accents 2018-11-07 14:57:05 +00:00
n1474335
19c002fcdd 8.9.2 2018-11-07 14:40:13 +00:00
n1474335
ab3a73fe58 Merge branch 'qistoph-FromNegs' 2018-11-07 14:39:51 +00:00
n1474335
91fc2c28dc Added signed feature to 'To Decimal' 2018-11-07 14:39:33 +00:00
n1474335
ca47ba3c7c Merge branch 'FromNegs' of https://github.com/qistoph/CyberChef into qistoph-FromNegs 2018-11-07 14:23:39 +00:00
n1474335
e1b456c01c 8.9.1 2018-11-07 14:21:26 +00:00
n1474335
5eb7e00eac Merge branch 'qistoph-HmacToggleStr' 2018-11-07 14:21:18 +00:00
n1474335
8bcf68c8a1 Merge branch 'HmacToggleStr' of https://github.com/qistoph/CyberChef into qistoph-HmacToggleStr 2018-11-07 14:18:24 +00:00
n1474335
520eaedd9a 8.9.0 2018-11-07 13:23:26 +00:00
n1474335
4c5e664ce0 Merge branch 'arnydo-add_url_defang' 2018-11-07 13:23:17 +00:00
n1474335
53c500eb1b Added various options to the 'Defang URL' operation. 2018-11-07 13:23:05 +00:00
n1474335
253346a201 Merge branch 'add_url_defang' of https://github.com/arnydo/CyberChef into arnydo-add_url_defang 2018-11-07 12:29:58 +00:00
n1474335
c5d82a76ab 8.8.8 2018-11-07 12:29:32 +00:00
n1474335
18a9dfffc7 Updated dependencies. Removed shim from HMAC op and postinstall js-to-mjs step due to CryptoAPI fixes. 2018-11-07 12:29:23 +00:00
n1474335
38838e4dca 8.8.7 2018-11-06 18:52:31 +00:00
n1474335
5c151d727b Merge branch 'bwhitn-bugfixes' 2018-11-06 18:52:17 +00:00
n1474335
2d5b157c91 Merge branch 'bugfixes' of https://github.com/bwhitn/CyberChef into bwhitn-bugfixes 2018-11-06 18:51:40 +00:00
n1474335
10d3d27a33 8.8.6 2018-11-05 12:48:29 +00:00
n1474335
1614442bd7 Fixed theming issues 2018-11-05 12:48:22 +00:00
bwhitn
a3c5b1e107 Simplified while loop in FromBase58 to match ToBase58 2018-10-28 18:37:00 -04:00
Chris van Marle
3f0af9cdea Add tests for From Decimal 2018-10-22 17:51:26 +08:00
Brian Whitney
f4de4de8c1 Fixing the babel, scrypt, and base58 issues 2018-10-21 21:10:49 -04:00
arnydo
69033a7343 Add Defang URL 2018-10-16 15:03:29 -04:00
arnydo
5a22106731 Create DefangURL.mjs 2018-10-16 15:02:39 -04:00
d98762625
5155d0ed56 Merge branch 'qistoph-RegexTooltip' 2018-10-12 15:44:17 +01:00
Chris van Marle
9be674103f Tooltip regex matches #279
Tooltip shows offset and matched groups
2018-10-12 15:42:44 +01:00
Chris van Marle
ba24e12454 Update hexadecimal sort after review
- Use Array.map instead of for-loop
- Add test case
2018-10-12 15:39:06 +02:00
Chris van Marle
b76aa16143 Fix Hash test 2018-10-12 13:54:40 +02:00
d98762625
8f7bb3a7c9 Merge pull request #371 from OllieGeek/master
CSS label / register-list Aesthetics
2018-10-12 12:12:48 +01:00
Chris van Marle
be2b466376 Use toggleString for Key in HMAC #263 2018-10-12 13:05:32 +02:00
n1474335
f957925aac 8.8.5 2018-10-12 10:51:01 +00:00
n1474335
1bf8d63d1a Merge branch 'Cynser-fix-wiki-urls' 2018-10-12 10:50:27 +00:00
n1474335
8875144307 Merge branch 'fix-wiki-urls' of https://github.com/Cynser/CyberChef into Cynser-fix-wiki-urls 2018-10-12 10:45:54 +00:00
n1474335
d5c01f387a 8.8.4 2018-10-12 10:43:01 +00:00
n1474335
32709cd60f Merge branch 'klaxon1-feature/improve-email-extract' 2018-10-12 10:42:21 +00:00
n1474335
aaf0a91975 Fixed populateOption overflows 2018-10-12 10:42:03 +00:00
n1474335
6cc6230b91 Merge branch 'feature/improve-email-extract' of https://github.com/klaxon1/CyberChef into klaxon1-feature/improve-email-extract 2018-10-12 10:34:00 +00:00
n1474335
dd630f20f8 8.8.3 2018-10-12 10:28:23 +00:00
n1474335
0c6efd95fa Modified bzip2 library export to use ES6 syntax. Fixes #382. 2018-10-12 10:28:15 +00:00
Chris van Marle
a276378887 Enable parsing of negative decimals #176 2018-10-12 10:08:24 +02:00
Cynser
98d861a639 Add check for Forensics Wiki URLs 2018-10-11 17:27:51 +01:00
Chris van Marle
3b3c27072f Fix lint errors 2018-10-11 15:50:58 +02:00
Klaxon
3089c39369 add test 2018-10-11 22:26:44 +10:00
Chris van Marle
0cbb17f7ce Support hexadecimal and other bases in numeric sorting 2018-10-11 14:23:05 +02:00
Klaxon
54793f2b78 update operation 2018-10-11 21:52:49 +10:00
Klaxon
f1ffe19ec8 Merge branch 'master' into feature/remove-letter-accents 2018-10-11 21:28:04 +10:00
Klaxon
e638fb69b5 fix comment 2018-10-11 20:52:12 +10:00
Klaxon
718a94b5e0 add tests for internationalized email addresses 2018-10-11 20:42:16 +10:00
Klaxon
3079059ce3 Update regex to support a wider variety of email addresses. 2018-10-11 18:25:05 +10:00
n1474335
d6c6981bc0 8.8.2 2018-10-10 15:49:11 +00:00
n1474335
8aeb7b60a7 Updated dependencies 2018-10-10 15:49:07 +00:00
n1474335
9197ac6510 8.8.1 2018-10-10 14:08:32 +00:00
n1474335
b67ad3073c Merge branch 'Cynser-csv-escape' 2018-10-10 14:08:20 +00:00
n1474335
4a4f37f888 Merge branch 'csv-escape' of https://github.com/Cynser/CyberChef into Cynser-csv-escape 2018-10-10 14:06:49 +00:00
n1474335
c55331f220 8.8.0 2018-10-10 13:59:37 +00:00
n1474335
757ec98554 Updated CHANGELOG 2018-10-10 13:59:28 +00:00
n1474335
14309f2069 Merge branch 'GCHQ77703-tlv' 2018-10-10 13:56:47 +00:00
n1474335
e6b89d571e Tidied up TLV operation and tests 2018-10-10 13:56:20 +00:00
Cynser
d957198fd6 Make the check for Wikipedia URLs slightly stricter 2018-10-07 22:52:08 +01:00
Cynser
903bd22999 Stop treating backslashes in CSV as escape character 2018-10-07 22:20:43 +01:00
Klaxon
04ee2fb3e4 add function to replace accent chars with latin chars 2018-10-03 13:26:01 +10:00
Klaxon
ac2466a304 create operation from npm run newop 2018-10-03 13:11:22 +10:00
Klaxon
ab4c9ef0d6 fix comment 2018-10-02 15:12:51 +10:00
Klaxon
a69063de9b add tests 2018-10-02 13:51:55 +10:00
Klaxon
62b76777c0 update regex to match more email address variations 2018-10-02 13:40:47 +10:00
OllieGeek
32a91bda0a CSS label / register-list Aesthetics
Occasionally depending on the page width and the operation used, the label.bmd-label-floating's wraps and covers the input - CSS to hide the wrap

On register-list, if the regex match is not a word and longer than the div, it'll over run - CSS of word-break: break-all
2018-09-24 22:56:38 +01:00
n1474335
a15af602e0 Merge branch 'tlv' of https://github.com/GCHQ77703/CyberChef into GCHQ77703-tlv 2018-08-31 15:12:54 +00:00
n1474335
ec9dfd2918 Updated NPM token 2018-08-31 14:08:18 +00:00
n1474335
016086ef4e 8.7.0 2018-08-31 14:00:29 +00:00
n1474335
2e5ea968ee Updated CHANGELOG 2018-08-31 14:00:24 +00:00
n1474335
5dde1c1c04 Merge branch 'GCHQ77703-jwt' 2018-08-31 13:58:33 +00:00
n1474335
be14d56eae Tidied up JWT operations 2018-08-31 13:58:06 +00:00
n1474335
100b097ace Merge branch 'jwt' of https://github.com/GCHQ77703/CyberChef into GCHQ77703-jwt 2018-08-31 12:20:37 +00:00
GCHQ 77703
3833c5f9fe Rename operation, add working tests, add info URL 2018-08-31 13:20:28 +01:00
n1474335
3470dd9f3b Merge branch 'GCHQ77703-alphabetical' 2018-08-31 11:41:43 +00:00
GCHQ 77703
c5e8649284 alphabetically sort tests 2018-08-29 22:48:47 +01:00
GCHQ 77703
a95f43aa4d Implement tests, fix options argument 2018-08-29 22:43:10 +01:00
n1474335
0420aa8edb Merge branch 'Sam-Dowling-patch-1' 2018-08-29 19:09:53 +00:00
n1474335
806b43dfec Merge branch 'patch-1' of https://github.com/Sam-Dowling/CyberChef into Sam-Dowling-patch-1 2018-08-29 19:09:19 +00:00
n1474335
98f4fe4c2b 8.6.2 2018-08-29 19:06:02 +00:00
n1474335
0d63b3cbae JSON output is now indented by default. Closes #350. 2018-08-29 19:05:58 +00:00
n1474335
7061c05f77 8.6.1 2018-08-29 18:58:01 +00:00
n1474335
9b9a182f9f Merge branch 'klaxon1-feature/improve-parse-ip-range' 2018-08-29 18:57:08 +00:00
n1474335
2d9e7fcc6d Added full stop to operation description 2018-08-29 18:56:50 +00:00
n1474335
56946a66aa Merge branch 'feature/improve-parse-ip-range' of https://github.com/klaxon1/CyberChef into klaxon1-feature/improve-parse-ip-range 2018-08-29 18:48:29 +00:00
n1474335
c9242e32fe Auto-generated configs and modules are now cleaned when starting a new dev or prod task 2018-08-29 18:21:46 +00:00
n1474335
22e8883934 8.6.0 2018-08-29 18:04:55 +00:00
n1474335
552a18d89a Updated CHANGELOG 2018-08-29 18:04:49 +00:00
n1474335
6b725e9114 Merge branch 'GCHQ77703-master' 2018-08-29 18:00:06 +00:00
n1474335
415beaa0b0 Tidied up Geohash operations 2018-08-29 17:59:48 +00:00
n1474335
e9fe227ed7 Merge branch 'master' of https://github.com/GCHQ77703/CyberChef into GCHQ77703-master 2018-08-29 17:48:23 +00:00
n1474335
c1be109592 8.5.1 2018-08-29 17:36:05 +00:00
n1474335
88e603bbf1 Merge branch 'PenguinGeorge-cascadexor-new' 2018-08-29 17:35:13 +00:00
n1474335
c7b2095bb4 Updated package-lock.json 2018-08-29 17:34:47 +00:00
n1474335
7396117d89 Merge branch 'cascadexor-new' of https://github.com/PenguinGeorge/CyberChef into PenguinGeorge-cascadexor-new 2018-08-29 17:31:59 +00:00
Sam Dowling
fd96bf345b Fixed typo
Fixed typo in operation description.
Wirlpool -> Whirlpool
2018-08-29 17:15:52 +01:00
Klaxon
2820660264 fix regex issues and ESlint errors and warnings
fix comment

fix ESlint errors and warnings

fix regex

add author
2018-08-28 23:07:53 +10:00
Klaxon
86145dbf67 add tests 2018-08-28 23:07:48 +10:00
Klaxon
135b17186e update description 2018-08-28 23:07:40 +10:00
Klaxon
ce494339ef add parse IPv6 list 2018-08-28 23:07:32 +10:00
Klaxon
dd5af7eb10 add parse IPv4 list 2018-08-28 23:07:04 +10:00
GCHQ 77703
3abe99078e Fix linting 2018-08-27 16:03:15 +01:00
GCHQ 77703
edbd540c68 Add Dysfunctional Test 2018-08-27 15:42:07 +01:00
GCHQ 77703
06d9302d96 Implement TLV / KLV 2018-08-27 14:57:24 +01:00
GCHQ 77703
032b4bed7f Add Length Value Decoder Operatoin 2018-08-27 01:17:06 +01:00
GCHQ 77703
8559f5c8ea Add JWT Verify, Decode and Sign 2018-08-26 23:16:13 +01:00
GCHQ 77703
91133172d5 Remove subdomain from Wikipedia 2018-08-26 18:51:52 +01:00
GCHQ 77703
001f3f30cd Remove multi-line operations 2018-08-26 18:06:02 +01:00
GCHQ 77703
a1b1059ad1 Revert package-lock.json changes 2018-08-26 17:39:33 +01:00
GCHQ 77703
69a0122fea Fix "From Geohash" test 2018-08-26 17:20:50 +01:00
GCHQ 77703
3d505b4248 Add ToGeohash and FromGeohash operations 2018-08-26 14:27:15 +01:00
George J
70d4e3394c Updated XOR to include Cascade scheme 2018-08-24 22:33:24 +01:00
n1474335
3905c01a0d 8.5.0 2018-08-24 01:07:56 +01:00
n1474335
2a49af1ec3 'To Braille' and 'From Braille' operations added. Closes #255 2018-08-24 01:07:51 +01:00
n1474335
3d4f54e8bc 8.4.3 2018-08-24 00:32:57 +01:00
n1474335
61f2f2d2e3 'Show Base64 offsets' operation show supports base64 input. Closes #276 2018-08-24 00:32:52 +01:00
n1474335
00058bd5c7 8.4.2 2018-08-23 23:24:05 +01:00
n1474335
383fe50fc9 Support for negative values in 'Drop bytes' and 'Take bytes'. Closes #266 2018-08-23 23:23:00 +01:00
n1474335
e4fdadc573 8.4.1 2018-08-23 22:56:46 +01:00
n1474335
032f8808ef Fixed typo in Z85 alphabet 2018-08-23 22:56:18 +01:00
n1474335
10cf0d13c2 8.4.0 2018-08-23 22:10:23 +01:00
n1474335
6c9fea97ef Updated CHANGELOG 2018-08-23 22:10:15 +01:00
n1474335
4c2d612bdd Merge branch 'PenguinGeorge-ascii85-new' 2018-08-23 22:05:44 +01:00
n1474335
8e9fece77d Tidied up Base85 ops 2018-08-23 22:05:31 +01:00
n1474335
c818370123 Merge branch 'ascii85-new' of https://github.com/PenguinGeorge/CyberChef into PenguinGeorge-ascii85-new 2018-08-23 21:46:41 +01:00
n1474335
bf2643802a 8.3.1 2018-08-23 21:42:04 +01:00
n1474335
1ad079fbd4 'Find/Replace', 'Filter' and 'Register' now used XRegExp 2018-08-23 21:41:57 +01:00
George J
2d9e8773f5 Updated Base85 operations for latest CyberChef version 2018-08-22 20:24:32 +01:00
n1474335
5aa13f2428 Changelog improved 2018-08-22 03:26:02 +01:00
n1474335
38f5fcde86 8.3.0 2018-08-21 19:29:51 +01:00
n1474335
f99ab87ca1 Merge branch 'artemisbot-features/messagepack' 2018-08-21 19:29:39 +01:00
n1474335
d3d230a76d Tweaked MessagePack operations 2018-08-21 19:29:19 +01:00
n1474335
e7c6a05e9f Merge branch 'features/messagepack' of https://github.com/artemisbot/CyberChef into artemisbot-features/messagepack 2018-08-21 19:22:10 +01:00
n1474335
17ec5c2683 8.2.0 2018-08-21 19:11:15 +01:00
n1474335
8d1839b9e2 Updated CHANGELOG.md 2018-08-21 19:10:35 +01:00
n1474335
23213a4ac5 Merge branch 'PenguinGeorge-info-links' 2018-08-21 19:08:08 +01:00
n1474335
e81c81351d Added more infoLinks and updated newOperation script to include prompt for them. 2018-08-21 19:07:13 +01:00
Matt C
36e16d9925 Fixed linting issues 2018-08-20 19:14:19 +01:00
Matt C
84eaaf4819 Tests now work
Also they'll work in the node API too now
2018-08-20 19:08:01 +01:00
n1474335
757096d97a Added image licencing info 2018-08-20 01:20:02 +01:00
n1474335
2393eac218 Removed src/test.mjs 2018-08-20 00:50:59 +01:00
n1474335
745d21d1bc 8.1.4 2018-08-20 00:26:49 +01:00
n1474335
cb34518a89 Recipes with a single backslash argument are now parsed correctly. Fixes #319 2018-08-20 00:26:44 +01:00
Matt C
821dd9c48c Added messagepack tests but they don't work
and i'm too burnt out to figure out why
2018-08-20 00:20:04 +01:00
n1474335
740f3924df Pressing return on a highlighted search result now correctly adds it to the recipe in Firefox. 2018-08-20 00:10:57 +01:00
n1474335
f052ed9b00 Compile message no longer overflows on small screens 2018-08-20 00:04:49 +01:00
n1474335
2507362741 8.1.3 2018-08-19 23:08:02 +01:00
n1474335
481a4266b0 Reset progress on statechange events. Fixes #329. 2018-08-19 23:07:53 +01:00
n1474335
92d9abf43a 8.1.2 2018-08-19 22:58:35 +01:00
n1474335
5bcdd99870 'Change IP format' operation now uses the correct arguments. Fixes #332 2018-08-19 22:58:31 +01:00
n1474335
e11bb38625 8.1.1 2018-08-19 22:50:54 +01:00
n1474335
affe057cab Added 'Decimal' option for toggleStrings. Closes #337. 2018-08-19 22:50:49 +01:00
n1474335
c1b2fc9400 Updated CHANGELOG.md 2018-08-19 17:39:49 +01:00
n1474335
782e0f3475 8.1.0 2018-08-19 17:37:19 +01:00
n1474335
6be7ac89d4 Merge branch 'sevzero-esm' 2018-08-19 17:37:03 +01:00
n1474335
ad2424cfdd Tidied up 'Dechunk HTTP Response' operation 2018-08-19 17:36:40 +01:00
n1474335
b9703e2bb6 8.0.2 2018-08-19 17:14:36 +01:00
n1474335
198b67104f Merge branch 'Cynser-fix-date-time' 2018-08-19 17:14:20 +01:00
n1474335
8dab0eac58 Removed excess newline 2018-08-19 17:14:07 +01:00
Cynser
8b78383732 Newline at end of files 2018-08-16 03:31:09 +01:00
Cynser
f1c31ea966 Added some tests for the Translate DateTime Format operation 2018-08-16 03:28:11 +01:00
Cynser
1a1fad7433 Fixed DateTime format arguments 2018-08-16 03:01:19 +01:00
d98762625
ab248a0209 Merge pull request #333 from d98762625/update-cla-doc
Update CLA info in README
2018-08-14 12:09:19 +01:00
d98762625
6155dbb6e9 Update CLA info in README 2018-08-14 09:35:41 +01:00
n1474335
f7310369e6 8.0.1 2018-08-09 19:17:35 +01:00
n1474335
9b7f4e824a Improvements and basic tests for Magic op and addition of deep cloning for dishes 2018-08-09 19:17:24 +01:00
Matt C
0c06e64051 Added MessagePack operations 2018-08-09 11:09:28 +01:00
sevzero
ed84614389 Fixed issues raised by Travis 2018-05-24 13:39:14 +00:00
sevzero
67bd2605c0 Updated variable scope in legacy HTTP.js file 2018-05-24 13:21:50 +00:00
sevzero
83c145c2ac Reduced variable scopes 2018-05-24 13:17:46 +00:00
sevzero
53bf52c989 Added decoder for chunked HTTP encoding
This decoder will join up a HTTP response sent using chunked transfer encoding, raised in issue #168.

This is useful when attempting to extract files or gzipped responses sent using chunked transfer encoding, particularly when combined with the gunzip operation.
2018-05-24 13:09:04 +00:00
George J
77a0238406 Fixes syntax error 2018-05-13 13:27:52 +01:00
George J
c7f13ff67f Added 'More Info' links to the descriptions of many operations for #265 2018-05-05 00:43:42 +01:00
316 changed files with 5514 additions and 2216 deletions

View File

@@ -1,6 +1,6 @@
{ {
"presets": [ "presets": [
["env", { ["@babel/preset-env", {
"targets": { "targets": {
"chrome": 40, "chrome": 40,
"firefox": 35, "firefox": 35,
@@ -8,7 +8,7 @@
"node": "6.5" "node": "6.5"
}, },
"modules": false, "modules": false,
"useBuiltIns": true "useBuiltIns": "entry"
}] }]
], ],
"plugins": [ "plugins": [

View File

@@ -36,7 +36,7 @@ deploy:
skip_cleanup: true skip_cleanup: true
email: "n1474335@gmail.com" email: "n1474335@gmail.com"
api_key: api_key:
secure: "Z3FK6bm4RfQEIRXZ1lBNzQkVIoHpivThr9U+XBHmsBgIfdrK/XUnzs/slugo+NIz8nPiGmMx4gxyJonBCLHDGb1ysky2aEWTl26c0teaF4DeQEjWC1ZaGzv8MV1/GkUamnr1qouXjyUhyEAp33rd8ccN9Rq3QNYB/qLDcA9/FCme7JCW6sCd4zWO0LGEYMJEMc2FzAUkqhqsI05hegGhSDgKXRn5PmLARek4yHD+Hx7pstaTeQIy0WoGJjdzoB3iJIMmo/hWZGzZafktUOh223c5qzx4zMpDRNmMngBUw6R94nKd4KvplYRgB87Y3L/aiVU4CF+axwLmK8RPaC1wbJnlHf06zxHPdiFmsY/zKPpNel+nOnxzRrF5l2KMU4TU6gug3s9Jnzp9T5UMfhp0jW3YkxHGeuOPOeE1i0lTUWUGWrPHLQquAhLfkr2zxaU4ETk/y85hq9W4LAy0ENEDVXX2jP7FnI4Z1fdpmljpmVNJR+outPg6t+Coqgvil7v7XpMtDm8lKQanVYuxwmkb/ncOWFRWuM2j5zIEg3CHnFDcJ9bYrfKRg0b0tb/2BWD14pQnV76goVwzJQYVzdPc8TKIYJw2BZ1Nh9c0iruQVebe/6l1FX9fDCkz8VMmltni61/LxZrf8y0NT1YaU1raeNY2dH5UWvEa9p72FPMI6Eg=" secure: "UnDQL3Kh+GK2toL0TK3FObO0ujVssU3Eg4BBuYdjwLB81GhiGE5/DTh7THdZPOpbLo6wQeOwfZDuMeKC1OU+0Uf4NsdYFu1aq6xMO20qBQ4qUfgsyiK4Qgywj9gk0p1+OFZdGAZ/j1CNRAaF71XQIY6iV84c+SO4WoizXYrNT0Jh4sr2DA4/97G2xmJtPi0qOzYrJ09R56ZUozmqeik5G0pMRIuJRbpjS/7bZXV+N7WV0ombZc9RkUaetbabEVOLQ+Xx5YAIVq+VuEeMe9VBSnxY/FfCLmy1wJsjGzpLCyBI9nbrG4nw8Wgc2m8NfK9rcpIvBTGner9r2j60NVDkZ8kLZPrqXhq6AZMwa+oz6K5UQCqRo2RRQzSGwXxg67HY5Tcq+oNmjd+DqpPg4LZ3eGlluyP5XfG+hpSr9Ya4d8q8SrUWLxkoLHI6ZKMtoKFbTCSSQPiluW5hsZxjz3yDkkjsJw64M/EM8UyJrgaXqDklQu+7rBGKLfsK6os7RDiqjBWpQ7gwpo8HvY0O8yqEAabPz+QGkanpjcCOZCXFbSkzWxYy37RMAPu88iINVZVlZE4l+WJenCpZY95ueyy0mG9cyMSzVRPyX6A+/n4H6VMFPFjpGDLTD588ACEjY1lmHfS/eXwXJcgqPPD2gW0XdRdUheU/ssqlfCfGWQMTDXs="
on: on:
tags: true tags: true
branch: master branch: master

View File

@@ -1,36 +1,107 @@
# Changelog # Changelog
All notable changes to this project will be documented in this file. All notable changes to CyberChef will be documented in this file.
### [8.10.0] - 2018-11-07
- 'Remove Diacritics' operation added [@klaxon1] | [#387]
### [8.9.0] - 2018-11-07
- 'Defang URL' operation added [@arnydo] | [#394]
### [8.8.0] - 2018-10-10
- 'Parse TLV' operation added [@GCHQ77703] | [#351]
### [8.7.0] - 2018-08-31
- 'JWT Sign', 'JWT Verify' and 'JWT Decode' operations added [@GCHQ77703] | [#348]
### [8.6.0] - 2018-08-29
- 'To Geohash' and 'From Geohash' operations added [@GCHQ77703] | [#344]
### [8.5.0] - 2018-08-23
- 'To Braille' and 'From Braille' operations added [@n1474335] | [#255]
### [8.4.0] - 2018-08-23
- 'To Base85' and 'From Base85' operations added [@PenguinGeorge] | [#340]
### [8.3.0] - 2018-08-21
- 'To MessagePack' and 'From MessagePack' operations added [@artemisbot] | [#338]
### [8.2.0] - 2018-08-21
- Information links added to most operations, accessible in the description popover [@PenguinGeorge] | [#298]
### [8.1.0] - 2018-08-19
- 'Dechunk HTTP response' operation added [@sevzero] | [#311]
## [8.0.0] - 2018-08-05 ## [8.0.0] - 2018-08-05
- Codebase rewritten using [ES modules](https://hacks.mozilla.org/2018/03/es-modules-a-cartoon-deep-dive/) and [classes](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes) #284 - Codebase rewritten using [ES modules](https://hacks.mozilla.org/2018/03/es-modules-a-cartoon-deep-dive/) and [classes](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes) [@n1474335] [@d98762625] [@artemisbot] [@picapi] | [#284]
- Operation architecture restructured to make adding new operations a lot simpler #284 - Operation architecture restructured to make adding new operations a lot simpler [@n1474335] | [#284]
- A script has been added to aid in the creation of new operations by running `npm run newop` @n1474335 #284 - A script has been added to aid in the creation of new operations by running `npm run newop` [@n1474335] | [#284]
- 'Magic' operation added - [automated detection of encoded data](https://github.com/gchq/CyberChef/wiki/Automatic-detection-of-encoded-data-using-CyberChef-Magic) @n1474335 #239 - 'Magic' operation added - [automated detection of encoded data](https://github.com/gchq/CyberChef/wiki/Automatic-detection-of-encoded-data-using-CyberChef-Magic) [@n1474335] | [#239]
- UI updated to use [Bootstrap Material Design](https://fezvrasta.github.io/bootstrap-material-design/) @n1474335 #248 - UI updated to use [Bootstrap Material Design](https://fezvrasta.github.io/bootstrap-material-design/) [@n1474335] | [#248]
- `JSON`, `File` and `List<File>` Dish types added @n1474335 #284 - `JSON`, `File` and `List<File>` Dish types added [@n1474335] | [#284]
- `OperationError` type added for better handling of errors thrown by operations @d98762625 #296 - `OperationError` type added for better handling of errors thrown by operations [@d98762625] | [#296]
- A `present()` method has been added, allowing operations to pass machine-friendly data to subsequent operations whilst presenting human-friendly data to the user @n1474335 #284 - A `present()` method has been added, allowing operations to pass machine-friendly data to subsequent operations whilst presenting human-friendly data to the user [@n1474335] | [#284]
- Set operations added @d98762625 #281 - Set operations added [@d98762625] | [#281]
- 'To Table' operation added @JustAnotherMark #294 - 'To Table' operation added [@JustAnotherMark] | [#294]
- 'Haversine distance' operation added @Dachande663 #325 - 'Haversine distance' operation added [@Dachande663] | [#325]
- Started keeping a changelog @n1474335 - Started keeping a changelog [@n1474335]
## [7.0.0] - 2017-12-28 ## [7.0.0] - 2017-12-28
- Added support for loading, processing and downloading files up to 500MB @n1474335 #224 - Added support for loading, processing and downloading files up to 500MB [@n1474335] | [#224]
## [6.0.0] - 2017-09-19 ## [6.0.0] - 2017-09-19
- Added threading support, moving all recipe processing into a [Web Worker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers) to increase performance and allow long-running operations to be cancelled @n1474335 #173 - Threading support added. All recipe processing moved into a [Web Worker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers) to increase performance and allowing long-running operations to be cancelled [@n1474335] | [#173]
- Created modules so that operations relying on large libraries can be downloaded separately as required, reducing the initial loading time for the app @n1474335 #173 - Module system created so that operations relying on large libraries can be downloaded separately as required, reducing the initial loading time for the app [@n1474335] | [#173]
## [5.0.0] - 2017-03-30 ## [5.0.0] - 2017-03-30
- Configured Webpack build process, Babel transpilation and ES6 imports and exports @n1474335 #95 - Webpack build process configured with Babel transpilation and ES6 imports and exports [@n1474335] | [#95]
## [4.0.0] - 2016-11-28 ## [4.0.0] - 2016-11-28
- Initial open source commit @n1474335 - Initial open source commit [@n1474335] | [b1d73a72](https://github.com/gchq/CyberChef/commit/b1d73a725dc7ab9fb7eb789296efd2b7e4b08306)
[8.8.0]: https://github.com/gchq/CyberChef/releases/tag/v8.8.0
[8.7.0]: https://github.com/gchq/CyberChef/releases/tag/v8.7.0
[8.6.0]: https://github.com/gchq/CyberChef/releases/tag/v8.6.0
[8.5.0]: https://github.com/gchq/CyberChef/releases/tag/v8.5.0
[8.4.0]: https://github.com/gchq/CyberChef/releases/tag/v8.4.0
[8.3.0]: https://github.com/gchq/CyberChef/releases/tag/v8.3.0
[8.2.0]: https://github.com/gchq/CyberChef/releases/tag/v8.2.0
[8.1.0]: https://github.com/gchq/CyberChef/releases/tag/v8.1.0
[8.0.0]: https://github.com/gchq/CyberChef/releases/tag/v8.0.0 [8.0.0]: https://github.com/gchq/CyberChef/releases/tag/v8.0.0
[7.0.0]: https://github.com/gchq/CyberChef/releases/tag/v7.0.0 [7.0.0]: https://github.com/gchq/CyberChef/releases/tag/v7.0.0
[6.0.0]: https://github.com/gchq/CyberChef/releases/tag/v6.0.0 [6.0.0]: https://github.com/gchq/CyberChef/releases/tag/v6.0.0
[5.0.0]: https://github.com/gchq/CyberChef/releases/tag/v5.0.0 [5.0.0]: https://github.com/gchq/CyberChef/releases/tag/v5.0.0
[4.0.0]: https://github.com/gchq/CyberChef/commit/b1d73a725dc7ab9fb7eb789296efd2b7e4b08306 [4.0.0]: https://github.com/gchq/CyberChef/commit/b1d73a725dc7ab9fb7eb789296efd2b7e4b08306
[@n1474335]: https://github.com/n1474335
[@d98762625]: https://github.com/d98762625
[@GCHQ77703]: https://github.com/GCHQ77703
[@artemisbot]: https://github.com/artemisbot
[@picapi]: https://github.com/picapi
[@Dachande663]: https://github.com/Dachande663
[@JustAnotherMark]: https://github.com/JustAnotherMark
[@sevzero]: https://github.com/sevzero
[@PenguinGeorge]: https://github.com/PenguinGeorge
[@arnydo]: https://github.com/arnydo
[@klaxon1]: https://github.com/klaxon1
[#95]: https://github.com/gchq/CyberChef/pull/299
[#173]: https://github.com/gchq/CyberChef/pull/173
[#224]: https://github.com/gchq/CyberChef/pull/224
[#239]: https://github.com/gchq/CyberChef/pull/239
[#248]: https://github.com/gchq/CyberChef/pull/248
[#255]: https://github.com/gchq/CyberChef/issues/255
[#281]: https://github.com/gchq/CyberChef/pull/281
[#284]: https://github.com/gchq/CyberChef/pull/284
[#294]: https://github.com/gchq/CyberChef/pull/294
[#296]: https://github.com/gchq/CyberChef/pull/296
[#298]: https://github.com/gchq/CyberChef/pull/298
[#311]: https://github.com/gchq/CyberChef/pull/311
[#325]: https://github.com/gchq/CyberChef/pull/325
[#338]: https://github.com/gchq/CyberChef/pull/338
[#340]: https://github.com/gchq/CyberChef/pull/340
[#344]: https://github.com/gchq/CyberChef/pull/344
[#348]: https://github.com/gchq/CyberChef/pull/348
[#351]: https://github.com/gchq/CyberChef/pull/351
[#387]: https://github.com/gchq/CyberChef/pull/387
[#394]: https://github.com/gchq/CyberChef/pull/394

View File

@@ -22,7 +22,7 @@ module.exports = function (grunt) {
// Tasks // Tasks
grunt.registerTask("dev", grunt.registerTask("dev",
"A persistent task which creates a development build whenever source files are modified.", "A persistent task which creates a development build whenever source files are modified.",
["clean:dev", "exec:generateConfig", "concurrent:dev"]); ["clean:dev", "clean:config", "exec:generateConfig", "concurrent:dev"]);
grunt.registerTask("node", grunt.registerTask("node",
"Compiles CyberChef into a single NodeJS module.", "Compiles CyberChef into a single NodeJS module.",
@@ -38,7 +38,7 @@ module.exports = function (grunt) {
grunt.registerTask("prod", grunt.registerTask("prod",
"Creates a production-ready build. Use the --msg flag to add a compile message.", "Creates a production-ready build. Use the --msg flag to add a compile message.",
["eslint", "clean:prod", "exec:generateConfig", "webpack:web", "inline", "chmod"]); ["eslint", "clean:prod", "clean:config", "exec:generateConfig", "webpack:web", "inline", "chmod"]);
grunt.registerTask("default", grunt.registerTask("default",
"Lints the code base", "Lints the code base",
@@ -280,7 +280,11 @@ module.exports = function (grunt) {
chunks: false, chunks: false,
modules: false, modules: false,
entrypoints: false, entrypoints: false,
warningsFilter: [/source-map/, /dependency is an expression/], warningsFilter: [
/source-map/,
/dependency is an expression/,
/export 'default'/
],
} }
}, },
start: { start: {
@@ -382,13 +386,13 @@ module.exports = function (grunt) {
"mkdir -p src/core/config/modules", "mkdir -p src/core/config/modules",
"echo 'export default {};\n' > src/core/config/modules/OpModules.mjs", "echo 'export default {};\n' > src/core/config/modules/OpModules.mjs",
"echo '[]\n' > src/core/config/OperationConfig.json", "echo '[]\n' > src/core/config/OperationConfig.json",
"node --experimental-modules src/core/config/scripts/generateOpsIndex.mjs", "node --experimental-modules --no-warnings --no-deprecation src/core/config/scripts/generateOpsIndex.mjs",
"node --experimental-modules src/core/config/scripts/generateConfig.mjs", "node --experimental-modules --no-warnings --no-deprecation src/core/config/scripts/generateConfig.mjs",
"echo '--- Config scripts finished. ---\n'" "echo '--- Config scripts finished. ---\n'"
].join(";") ].join(";")
}, },
tests: { tests: {
command: "node --experimental-modules test/index.mjs" command: "node --experimental-modules --no-warnings --no-deprecation test/index.mjs"
} }
}, },
}); });

View File

@@ -88,9 +88,8 @@ Contributing a new operation to CyberChef is super easy! There is a quickstart s
An installation walkthrough, how-to guides for adding new operations and themes, descriptions of the repository structure, available data types and coding conventions can all be found in the project [wiki pages](https://github.com/gchq/CyberChef/wiki). An installation walkthrough, how-to guides for adding new operations and themes, descriptions of the repository structure, available data types and coding conventions can all be found in the project [wiki pages](https://github.com/gchq/CyberChef/wiki).
- Sign the [GCHQ Contributor Licence Agreement](https://github.com/gchq/Gaffer/wiki/GCHQ-OSS-Contributor-License-Agreement-V1.0)
- Push your changes to your fork. - Push your changes to your fork.
- Submit a pull request. - Submit a pull request. If you are doing this for the first time, you will be prompted to sign the [GCHQ Contributor Licence Agreement](https://cla-assistant.io/gchq/CyberChef) via the CLA assistant on the pull request. This will also ask whether you are happy for GCHQ to contact you about a token of thanks for your contribution, or about job opportunities at GCHQ.
## Licencing ## Licencing

4294
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{ {
"name": "cyberchef", "name": "cyberchef",
"version": "8.0.0", "version": "8.10.2",
"description": "The Cyber Swiss Army Knife for encryption, encoding, compression and data analysis.", "description": "The Cyber Swiss Army Knife for encryption, encoding, compression and data analysis.",
"author": "n1474335 <n1474335@gmail.com>", "author": "n1474335 <n1474335@gmail.com>",
"homepage": "https://gchq.github.io/CyberChef", "homepage": "https://gchq.github.io/CyberChef",
@@ -30,45 +30,44 @@
"main": "build/node/CyberChef.js", "main": "build/node/CyberChef.js",
"bugs": "https://github.com/gchq/CyberChef/issues", "bugs": "https://github.com/gchq/CyberChef/issues",
"devDependencies": { "devDependencies": {
"autoprefixer": "^9.1.0", "@babel/core": "^7.1.5",
"babel-core": "^6.26.3", "@babel/preset-env": "^7.1.5",
"babel-loader": "^7.1.5", "autoprefixer": "^9.3.1",
"babel-preset-env": "^1.7.0", "babel-loader": "^8.0.4",
"bootstrap": "^4.1.3", "bootstrap": "^4.1.3",
"colors": "^1.3.1", "colors": "^1.3.2",
"css-loader": "^1.0.0", "css-loader": "^1.0.1",
"eslint": "^5.3.0", "eslint": "^5.8.0",
"exports-loader": "^0.7.0", "exports-loader": "^0.7.0",
"extract-text-webpack-plugin": "^4.0.0-alpha0", "extract-text-webpack-plugin": "^4.0.0-alpha0",
"file-loader": "^1.1.11", "file-loader": "^2.0.0",
"grunt": "^1.0.3", "grunt": "^1.0.3",
"grunt-accessibility": "~6.0.0", "grunt-accessibility": "~6.0.0",
"grunt-chmod": "~1.1.1", "grunt-chmod": "~1.1.1",
"grunt-concurrent": "^2.3.1", "grunt-concurrent": "^2.3.1",
"grunt-contrib-clean": "~1.1.0", "grunt-contrib-clean": "~2.0.0",
"grunt-contrib-copy": "~1.0.0", "grunt-contrib-copy": "~1.0.0",
"grunt-contrib-watch": "^1.1.0", "grunt-contrib-watch": "^1.1.0",
"grunt-eslint": "^21.0.0", "grunt-eslint": "^21.0.0",
"grunt-exec": "~3.0.0", "grunt-exec": "~3.0.0",
"grunt-jsdoc": "^2.2.1", "grunt-jsdoc": "^2.3.0",
"grunt-webpack": "^3.1.2", "grunt-webpack": "^3.1.3",
"html-webpack-plugin": "^3.2.0", "html-webpack-plugin": "^3.2.0",
"imports-loader": "^0.8.0", "imports-loader": "^0.8.0",
"ink-docstrap": "^1.3.2", "ink-docstrap": "^1.3.2",
"js-to-mjs": "^0.2.0", "jsdoc-babel": "^0.5.0",
"jsdoc-babel": "^0.4.0", "node-sass": "^4.10.0",
"node-sass": "^4.9.2", "postcss-css-variables": "^0.11.0",
"postcss-css-variables": "^0.9.0", "postcss-import": "^12.0.1",
"postcss-import": "^12.0.0", "postcss-loader": "^3.0.0",
"postcss-loader": "^2.1.6",
"prompt": "^1.0.0", "prompt": "^1.0.0",
"sass-loader": "^7.1.0", "sass-loader": "^7.1.0",
"sitemap": "^1.13.0", "sitemap": "^2.1.0",
"style-loader": "^0.21.0", "style-loader": "^0.23.1",
"url-loader": "^1.0.1", "url-loader": "^1.1.2",
"web-resource-inliner": "^4.2.1", "web-resource-inliner": "^4.2.1",
"webpack": "^4.16.4", "webpack": "^4.25.1",
"webpack-dev-server": "^3.1.5", "webpack-dev-server": "^3.1.10",
"webpack-node-externals": "^1.7.2", "webpack-node-externals": "^1.7.2",
"worker-loader": "^2.0.0" "worker-loader": "^2.0.0"
}, },
@@ -77,46 +76,49 @@
"babel-plugin-transform-builtin-extend": "1.1.2", "babel-plugin-transform-builtin-extend": "1.1.2",
"babel-polyfill": "^6.26.0", "babel-polyfill": "^6.26.0",
"bcryptjs": "^2.4.3", "bcryptjs": "^2.4.3",
"bignumber.js": "^7.2.1", "bignumber.js": "^8.0.1",
"bootstrap-colorpicker": "^2.5.3", "bootstrap-colorpicker": "^2.5.3",
"bootstrap-material-design": "^4.1.1", "bootstrap-material-design": "^4.1.1",
"bson": "^3.0.2", "bson": "^3.0.2",
"chi-squared": "^1.1.0", "chi-squared": "^1.1.0",
"crypto-api": "^0.8.0", "crypto-api": "^0.8.3",
"crypto-js": "^3.1.9-1", "crypto-js": "^3.1.9-1",
"ctph.js": "0.0.5", "ctph.js": "0.0.5",
"diff": "^3.5.0", "diff": "^3.5.0",
"es6-promisify": "^6.0.0", "es6-promisify": "^6.0.1",
"escodegen": "^1.11.0", "escodegen": "^1.11.0",
"esmangle": "^1.0.1", "esmangle": "^1.0.1",
"esprima": "^4.0.1", "esprima": "^4.0.1",
"exif-parser": "^0.1.12", "exif-parser": "^0.1.12",
"file-saver": "^1.3.8", "file-saver": "^2.0.0-rc.4",
"highlight.js": "^9.12.0", "highlight.js": "^9.13.1",
"jquery": "^3.3.1", "jquery": "^3.3.1",
"js-crc": "^0.2.0", "js-crc": "^0.2.0",
"js-sha3": "^0.7.0", "js-sha3": "^0.8.0",
"jsbn": "^1.1.0", "jsbn": "^1.1.0",
"jsesc": "^2.5.1", "jsesc": "^2.5.1",
"jsonpath": "^1.0.0", "jsonpath": "^1.0.0",
"jsonwebtoken": "^8.3.0",
"jsrsasign": "8.0.12", "jsrsasign": "8.0.12",
"kbpgp": "^2.0.77", "kbpgp": "^2.0.82",
"lodash": "^4.17.10", "lodash": "^4.17.11",
"loglevel": "^1.6.1", "loglevel": "^1.6.1",
"loglevel-message-prefix": "^3.0.0", "loglevel-message-prefix": "^3.0.0",
"moment": "^2.22.2", "moment": "^2.22.2",
"moment-timezone": "^0.5.21", "moment-timezone": "^0.5.23",
"node-forge": "^0.7.5", "ngeohash": "^0.6.0",
"node-forge": "^0.7.6",
"node-md6": "^0.1.0", "node-md6": "^0.1.0",
"notepack.io": "^2.1.3",
"nwmatcher": "^1.4.4", "nwmatcher": "^1.4.4",
"otp": "^0.1.3", "otp": "^0.1.3",
"popper.js": "^1.14.4", "popper.js": "^1.14.4",
"scryptsy": "^2.0.0", "scryptsy": "^2.0.0",
"snackbarjs": "^1.1.0", "snackbarjs": "^1.1.0",
"sortablejs": "^1.7.0", "sortablejs": "^1.7.0",
"split.js": "^1.3.5", "split.js": "^1.5.9",
"ssdeep.js": "0.0.2", "ssdeep.js": "0.0.2",
"ua-parser-js": "^0.7.18", "ua-parser-js": "^0.7.19",
"utf8": "^3.0.0", "utf8": "^3.0.0",
"vkbeautify": "^0.99.3", "vkbeautify": "^0.99.3",
"xmldom": "^0.1.27", "xmldom": "^0.1.27",
@@ -130,7 +132,6 @@
"test": "grunt test", "test": "grunt test",
"docs": "grunt docs", "docs": "grunt docs",
"lint": "grunt lint", "lint": "grunt lint",
"newop": "node --experimental-modules src/core/config/scripts/newOperation.mjs", "newop": "node --experimental-modules src/core/config/scripts/newOperation.mjs"
"postinstall": "[ -f node_modules/crypto-api/src/crypto-api.mjs ] || npx j2m node_modules/crypto-api/src/crypto-api.js"
} }
} }

View File

@@ -96,7 +96,7 @@ class Chef {
const returnType = this.dish.size > threshold ? Dish.ARRAY_BUFFER : Dish.STRING; const returnType = this.dish.size > threshold ? Dish.ARRAY_BUFFER : Dish.STRING;
// Create a raw version of the dish, unpresented // Create a raw version of the dish, unpresented
const rawDish = new Dish(this.dish); const rawDish = this.dish.clone();
// Present the raw result // Present the raw result
await recipe.present(this.dish); await recipe.present(this.dish);

View File

@@ -169,7 +169,7 @@ class Dish {
this.value = this.value instanceof BigNumber ? Utils.strToByteArray(this.value.toFixed()) : []; this.value = this.value instanceof BigNumber ? Utils.strToByteArray(this.value.toFixed()) : [];
break; break;
case Dish.JSON: case Dish.JSON:
this.value = this.value ? Utils.strToByteArray(JSON.stringify(this.value)) : []; this.value = this.value ? Utils.strToByteArray(JSON.stringify(this.value, null, 4)) : [];
break; break;
case Dish.FILE: case Dish.FILE:
this.value = await Utils.readFile(this.value); this.value = await Utils.readFile(this.value);
@@ -300,6 +300,69 @@ class Dish {
} }
} }
/**
* Returns a deep clone of the current Dish.
*
* @returns {Dish}
*/
clone() {
const newDish = new Dish();
switch (this.type) {
case Dish.STRING:
case Dish.HTML:
case Dish.NUMBER:
case Dish.BIG_NUMBER:
// These data types are immutable so it is acceptable to copy them by reference
newDish.set(
this.value,
this.type
);
break;
case Dish.BYTE_ARRAY:
case Dish.JSON:
// These data types are mutable so they need to be copied by value
newDish.set(
JSON.parse(JSON.stringify(this.value)),
this.type
);
break;
case Dish.ARRAY_BUFFER:
// Slicing an ArrayBuffer returns a new ArrayBuffer with a copy its contents
newDish.set(
this.value.slice(0),
this.type
);
break;
case Dish.FILE:
// A new file can be created by copying over all the values from the original
newDish.set(
new File([this.value], this.value.name, {
"type": this.value.type,
"lastModified": this.value.lastModified
}),
this.type
);
break;
case Dish.LIST_FILE:
newDish.set(
this.value.map(f =>
new File([f], f.name, {
"type": f.type,
"lastModified": f.lastModified
})
),
this.type
);
break;
default:
throw new Error("Cannot clone Dish, unknown type");
}
return newDish;
}
} }

View File

@@ -29,6 +29,7 @@ class Operation {
this.name = ""; this.name = "";
this.module = ""; this.module = "";
this.description = ""; this.description = "";
this.infoURL = null;
} }

View File

@@ -8,6 +8,8 @@ import utf8 from "utf8";
import moment from "moment-timezone"; import moment from "moment-timezone";
import {fromBase64} from "./lib/Base64"; import {fromBase64} from "./lib/Base64";
import {fromHex} from "./lib/Hex"; import {fromHex} from "./lib/Hex";
import {fromDecimal} from "./lib/Decimal";
import {fromBinary} from "./lib/Binary";
/** /**
@@ -297,7 +299,7 @@ class Utils {
* Accepts hex, Base64, UTF8 and Latin1 strings. * Accepts hex, Base64, UTF8 and Latin1 strings.
* *
* @param {string} str * @param {string} str
* @param {string} type - One of "Hex", "Base64", "UTF8" or "Latin1" * @param {string} type - One of "Binary", "Hex", "Decimal", "Base64", "UTF8" or "Latin1"
* @returns {byteArray} * @returns {byteArray}
* *
* @example * @example
@@ -312,8 +314,12 @@ class Utils {
*/ */
static convertToByteArray(str, type) { static convertToByteArray(str, type) {
switch (type.toLowerCase()) { switch (type.toLowerCase()) {
case "binary":
return fromBinary(str);
case "hex": case "hex":
return fromHex(str); return fromHex(str);
case "decimal":
return fromDecimal(str);
case "base64": case "base64":
return fromBase64(str, null, "byteArray"); return fromBase64(str, null, "byteArray");
case "utf8": case "utf8":
@@ -330,7 +336,7 @@ class Utils {
* Accepts hex, Base64, UTF8 and Latin1 strings. * Accepts hex, Base64, UTF8 and Latin1 strings.
* *
* @param {string} str * @param {string} str
* @param {string} type - One of "Hex", "Base64", "UTF8" or "Latin1" * @param {string} type - One of "Binary", "Hex", "Decimal", "Base64", "UTF8" or "Latin1"
* @returns {string} * @returns {string}
* *
* @example * @example
@@ -345,8 +351,12 @@ class Utils {
*/ */
static convertToByteString(str, type) { static convertToByteString(str, type) {
switch (type.toLowerCase()) { switch (type.toLowerCase()) {
case "binary":
return Utils.byteArrayToChars(fromBinary(str));
case "hex": case "hex":
return Utils.byteArrayToChars(fromHex(str)); return Utils.byteArrayToChars(fromHex(str));
case "decimal":
return Utils.byteArrayToChars(fromDecimal(str));
case "base64": case "base64":
return Utils.byteArrayToChars(fromBase64(str, null, "byteArray")); return Utils.byteArrayToChars(fromBase64(str, null, "byteArray"));
case "utf8": case "utf8":
@@ -550,8 +560,6 @@ class Utils {
if (renderNext) { if (renderNext) {
cell += b; cell += b;
renderNext = false; renderNext = false;
} else if (b === "\\") {
renderNext = true;
} else if (b === "\"" && !inString) { } else if (b === "\"" && !inString) {
inString = true; inString = true;
} else if (b === "\"" && inString) { } else if (b === "\"" && inString) {
@@ -769,7 +777,7 @@ class Utils {
args = m[2] args = m[2]
.replace(/"/g, '\\"') // Escape double quotes .replace(/"/g, '\\"') // Escape double quotes
.replace(/(^|,|{|:)'/g, '$1"') // Replace opening ' with " .replace(/(^|,|{|:)'/g, '$1"') // Replace opening ' with "
.replace(/([^\\])'(,|:|}|$)/g, '$1"$2') // Replace closing ' with " .replace(/([^\\]|[^\\]\\\\)'(,|:|}|$)/g, '$1"$2') // Replace closing ' with "
.replace(/\\'/g, "'"); // Unescape single quotes .replace(/\\'/g, "'"); // Unescape single quotes
args = "[" + args + "]"; args = "[" + args + "]";

View File

@@ -25,6 +25,8 @@
"From Base32", "From Base32",
"To Base58", "To Base58",
"From Base58", "From Base58",
"To Base85",
"From Base85",
"To Base", "To Base",
"From Base", "From Base",
"To BCD", "To BCD",
@@ -47,7 +49,12 @@
"Change IP format", "Change IP format",
"Encode text", "Encode text",
"Decode text", "Decode text",
"Swap endianness" "Swap endianness",
"To MessagePack",
"From MessagePack",
"To Braille",
"From Braille",
"Parse TLV"
] ]
}, },
{ {
@@ -83,6 +90,9 @@
"Derive EVP key", "Derive EVP key",
"Bcrypt", "Bcrypt",
"Scrypt", "Scrypt",
"JWT Sign",
"JWT Verify",
"JWT Decode",
"Pseudo-Random Number Generator" "Pseudo-Random Number Generator"
] ]
}, },
@@ -137,6 +147,7 @@
"ops": [ "ops": [
"HTTP request", "HTTP request",
"Strip HTTP headers", "Strip HTTP headers",
"Dechunk HTTP response",
"Parse User Agent", "Parse User Agent",
"Parse IP range", "Parse IP range",
"Parse IPv6 address", "Parse IPv6 address",
@@ -148,7 +159,8 @@
"Change IP format", "Change IP format",
"Group IP addresses", "Group IP addresses",
"Encode NetBIOS Name", "Encode NetBIOS Name",
"Decode NetBIOS Name" "Decode NetBIOS Name",
"Defang URL"
] ]
}, },
{ {
@@ -156,6 +168,7 @@
"ops": [ "ops": [
"Encode text", "Encode text",
"Decode text", "Decode text",
"Remove Diacritics",
"Unescape Unicode Characters" "Unescape Unicode Characters"
] ]
}, },
@@ -282,7 +295,9 @@
"Adler-32 Checksum", "Adler-32 Checksum",
"CRC-16 Checksum", "CRC-16 Checksum",
"CRC-32 Checksum", "CRC-32 Checksum",
"TCP/IP Checksum" "TCP/IP Checksum",
"To Geohash",
"From Geohash"
] ]
}, },
{ {
@@ -312,7 +327,9 @@
"To Camel case", "To Camel case",
"To Kebab case", "To Kebab case",
"BSON serialise", "BSON serialise",
"BSON deserialise" "BSON deserialise",
"To MessagePack",
"From MessagePack"
] ]
}, },
{ {

View File

@@ -35,12 +35,13 @@ for (const opObj in Ops) {
const op = new Ops[opObj](); const op = new Ops[opObj]();
operationConfig[op.name] = { operationConfig[op.name] = {
module: op.module, module: op.module,
description: op.description, description: op.description,
inputType: op.inputType, infoURL: op.infoURL,
outputType: op.presentType, inputType: op.inputType,
outputType: op.presentType,
flowControl: op.flowControl, flowControl: op.flowControl,
args: op.args args: op.args
}; };
if (op.hasOwnProperty("patterns")) { if (op.hasOwnProperty("patterns")) {

View File

@@ -53,6 +53,12 @@ If your operation does not rely on a library, just leave this blank and it will
prompt: "Description", prompt: "Description",
type: "string" type: "string"
}, },
infoURL: {
description: "An optional URL for an external site can be added to give more information about the operation. Wikipedia links are often suitable. If linking to Wikipedia, use an international link (e.g. https://wikipedia.org/...) rather than a localised link (e.g. https://en.wikipedia.org/...).",
example: "https://wikipedia.org/wiki/Percent-encoding",
prompt: "Information URL",
type: "string",
},
inputType: { inputType: {
description: `The input type defines how the input data will be presented to your operation. Check the project wiki for a full description of each type. The options are: ${ioTypes.join(", ")}.`, description: `The input type defines how the input data will be presented to your operation. Check the project wiki for a full description of each type. The options are: ${ioTypes.join(", ")}.`,
example: "string", example: "string",
@@ -141,6 +147,7 @@ class ${moduleName} extends Operation {
this.name = "${result.opName}"; this.name = "${result.opName}";
this.module = "${result.module}"; this.module = "${result.module}";
this.description = "${(new EscapeString).run(result.description, ["Special chars", "Double"])}"; this.description = "${(new EscapeString).run(result.description, ["Special chars", "Double"])}";
this.infoURL = "${result.infoURL}";
this.inputType = "${result.inputType}"; this.inputType = "${result.inputType}";
this.outputType = "${result.outputType}"; this.outputType = "${result.outputType}";
this.args = [ this.args = [

View File

@@ -81,6 +81,7 @@ export function fromBase64(data, alphabet="A-Za-z0-9+/=", returnType="string", r
return returnType === "string" ? "" : []; return returnType === "string" ? "" : [];
} }
alphabet = alphabet || "A-Za-z0-9+/=";
alphabet = Utils.expandAlphRange(alphabet).join(""); alphabet = Utils.expandAlphRange(alphabet).join("");
const output = []; const output = [];

45
src/core/lib/Base85.mjs Normal file
View File

@@ -0,0 +1,45 @@
/**
* Base85 resources.
*
* @author PenguinGeorge [george@penguingeorge.com]
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
/**
* Base85 alphabet options.
*/
export const ALPHABET_OPTIONS = [
{
name: "Standard",
value: "!-u",
},
{
name: "Z85 (ZeroMQ)",
value: "0-9a-zA-Z.\\-:+=^!/*?&<>()[]{}@%$#",
},
{
name: "IPv6",
value: "0-9A-Za-z!#$%&()*+\\-;<=>?@^_`{|~}",
}
];
/**
* Returns the name of the alphabet, when given the alphabet.
*
* @param {string} alphabet
* @returns {string}
*/
export function alphabetName(alphabet) {
alphabet = alphabet.replace("'", "&apos;");
alphabet = alphabet.replace("\"", "&quot;");
alphabet = alphabet.replace("\\", "&bsol;");
let name;
ALPHABET_OPTIONS.forEach(function(a) {
if (escape(alphabet) === escape(a.value)) name = a.name;
});
return name;
}

70
src/core/lib/Binary.mjs Normal file
View File

@@ -0,0 +1,70 @@
/**
* Binary functions.
*
* @author n1474335 [n1474335@gmail.com]
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import Utils from "../Utils";
/**
* Convert a byte array into a binary string.
*
* @param {Uint8Array|byteArray} data
* @param {string} [delim="Space"]
* @param {number} [padding=8]
* @returns {string}
*
* @example
* // returns "00010000 00100000 00110000"
* toHex([10,20,30]);
*
* // returns "00010000 00100000 00110000"
* toHex([10,20,30], ":");
*/
export function toBinary(data, delim="Space", padding=8) {
if (!data) return "";
delim = Utils.charRep(delim);
let output = "";
for (let i = 0; i < data.length; i++) {
output += data[i].toString(2).padStart(padding, "0") + delim;
}
if (delim.length) {
return output.slice(0, -delim.length);
} else {
return output;
}
}
/**
* Convert a binary string into a byte array.
*
* @param {string} data
* @param {string} [delim]
* @param {number} [byteLen=8]
* @returns {byteArray}
*
* @example
* // returns [10,20,30]
* fromBinary("00010000 00100000 00110000");
*
* // returns [10,20,30]
* fromBinary("00010000:00100000:00110000", "Colon");
*/
export function fromBinary(data, delim="Space", byteLen=8) {
const delimRegex = Utils.regexRep(delim);
data = data.replace(delimRegex, "");
const output = [];
for (let i = 0; i < data.length; i += byteLen) {
output.push(parseInt(data.substr(i, byteLen), 2));
}
return output;
}

View File

@@ -25,6 +25,7 @@ export function bitOp (input, key, func, nullPreserving, scheme) {
for (let i = 0; i < input.length; i++) { for (let i = 0; i < input.length; i++) {
k = key[i % key.length]; k = key[i % key.length];
if (scheme === "Cascade") k = input[i + 1] || 0;
o = input[i]; o = input[i];
x = nullPreserving && (o === 0 || o === k) ? o : func(o, k); x = nullPreserving && (o === 0 || o === k) ? o : func(o, k);
result.push(x); result.push(x);
@@ -115,3 +116,9 @@ export function sub(operand, key) {
const result = operand - key; const result = operand - key;
return (result < 0) ? 256 + result : result; return (result < 0) ? 256 + result : result;
} }
/**
* Delimiter options for bitwise operations
*/
export const BITWISE_OP_DELIMS = ["Hex", "Decimal", "Binary", "Base64", "UTF8", "Latin1"];

15
src/core/lib/Braille.mjs Normal file
View File

@@ -0,0 +1,15 @@
/**
* Braille resources.
*
* @author n1474335 [n1474335@gmail.com]
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
/**
* Braille lookup table.
*/
export const BRAILLE_LOOKUP = {
ascii: " A1B'K2L@CIF/MSP\"E3H9O6R^DJG>NTQ,*5<-U8V.%[$+X!&;:4\\0Z7(_?W]#Y)=",
dot6: "⠀⠁⠂⠃⠄⠅⠆⠇⠈⠉⠊⠋⠌⠍⠎⠏⠐⠑⠒⠓⠔⠕⠖⠗⠘⠙⠚⠛⠜⠝⠞⠟⠠⠡⠢⠣⠤⠥⠦⠧⠨⠩⠪⠫⠬⠭⠮⠯⠰⠱⠲⠳⠴⠵⠶⠷⠸⠹⠺⠻⠼⠽⠾⠿"
};

37
src/core/lib/Decimal.mjs Normal file
View File

@@ -0,0 +1,37 @@
/**
* Decimal functions.
*
* @author n1474335 [n1474335@gmail.com]
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import Utils from "../Utils";
/**
* Convert a string of decimal values into a byte array.
*
* @param {string} data
* @param {string} [delim]
* @returns {byteArray}
*
* @example
* // returns [10,20,30]
* fromDecimal("10 20 30");
*
* // returns [10,20,30]
* fromDecimal("10:20:30", "Colon");
*/
export function fromDecimal(data, delim="Auto") {
delim = Utils.charRep(delim);
const output = [];
let byteStr = data.split(delim);
if (byteStr[byteStr.length-1] === "")
byteStr = byteStr.slice(0, byteStr.length-1);
for (let i = 0; i < byteStr.length; i++) {
output[i] = parseInt(byteStr[i], 10);
}
return output;
}

View File

@@ -39,3 +39,21 @@ export function search (input, searchRegex, removeRegex, includeTotal) {
return output; return output;
} }
/**
* URL regular expression
*/
const protocol = "[A-Z]+://",
hostname = "[-\\w]+(?:\\.\\w[-\\w]*)+",
port = ":\\d+",
path = "/[^.!,?\"<>\\[\\]{}\\s\\x7F-\\xFF]*" +
"(?:[.!,?]+[^.!,?\"<>\\[\\]{}\\s\\x7F-\\xFF]+)*";
export const URL_REGEX = new RegExp(protocol + hostname + "(?:" + port + ")?(?:" + path + ")?", "ig");
/**
* Domain name regular expression
*/
export const DOMAIN_REGEX = /\b((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}\b/ig;

View File

@@ -1,5 +1,5 @@
/** /**
* Byte representation functions. * Hexadecimal functions.
* *
* @author n1474335 [n1474335@gmail.com] * @author n1474335 [n1474335@gmail.com]
* @copyright Crown Copyright 2016 * @copyright Crown Copyright 2016
@@ -83,8 +83,7 @@ export function toHexFast(data) {
* // returns [10,20,30] * // returns [10,20,30]
* fromHex("0a:14:1e", "Colon"); * fromHex("0a:14:1e", "Colon");
*/ */
export function fromHex(data, delim, byteLen=2) { export function fromHex(data, delim="Auto", byteLen=2) {
delim = delim || "Auto";
if (delim !== "None") { if (delim !== "None") {
const delimRegex = delim === "Auto" ? /[^a-f\d]/gi : Utils.regexRep(delim); const delimRegex = delim === "Auto" ? /[^a-f\d]/gi : Utils.regexRep(delim);
data = data.replace(delimRegex, ""); data = data.replace(delimRegex, "");

View File

@@ -3,6 +3,7 @@
* *
* @author picapi * @author picapi
* @author n1474335 [n1474335@gmail.com] * @author n1474335 [n1474335@gmail.com]
* @author Klaxon [klaxon@veyr.com]
* @copyright Crown Copyright 2016 * @copyright Crown Copyright 2016
* @license Apache-2.0 * @license Apache-2.0
*/ */
@@ -109,8 +110,8 @@ export function ipv6CidrRange(cidr, includeNetworkInfo) {
* @returns {string} * @returns {string}
*/ */
export function ipv4HyphenatedRange(range, includeNetworkInfo, enumerateAddresses, allowLargeList) { export function ipv4HyphenatedRange(range, includeNetworkInfo, enumerateAddresses, allowLargeList) {
const ip1 = strToIpv4(range[1]), const ip1 = strToIpv4(range[0].split("-")[0].trim()),
ip2 = strToIpv4(range[2]); ip2 = strToIpv4(range[0].split("-")[1].trim());
let output = ""; let output = "";
@@ -162,8 +163,8 @@ Total addresses in range: ${(((ip2 - ip1) >>> 0) + 1)}
* @returns {string} * @returns {string}
*/ */
export function ipv6HyphenatedRange(range, includeNetworkInfo) { export function ipv6HyphenatedRange(range, includeNetworkInfo) {
const ip1 = strToIpv6(range[1]), const ip1 = strToIpv6(range[0].split("-")[0].trim()),
ip2 = strToIpv6(range[14]), ip2 = strToIpv6(range[0].split("-")[1].trim()),
total = new Array(128).fill(); total = new Array(128).fill();
let output = "", let output = "",
@@ -188,6 +189,93 @@ export function ipv6HyphenatedRange(range, includeNetworkInfo) {
return output; return output;
} }
/**
* Parses a list of IPv4 addresses separated by a new line (\n) and displays information
* about it.
*
* @param {RegExp} list
* @param {boolean} includeNetworkInfo
* @param {boolean} enumerateAddresses
* @param {boolean} allowLargeList
* @returns {string}
*/
export function ipv4ListedRange(match, includeNetworkInfo, enumerateAddresses, allowLargeList) {
let ipv4List = match[0].split("\n");
ipv4List = ipv4List.filter(Boolean);
const ipv4CidrList = ipv4List.filter(function(a) {
return a.includes("/");
});
for (let i = 0; i < ipv4CidrList.length; i++) {
const network = strToIpv4(ipv4CidrList[i].split("/")[0]);
const cidrRange = parseInt(ipv4CidrList[i].split("/")[1], 10);
if (cidrRange < 0 || cidrRange > 31) {
return "IPv4 CIDR must be less than 32";
}
const mask = ~(0xFFFFFFFF >>> cidrRange),
cidrIp1 = network & mask,
cidrIp2 = cidrIp1 | ~mask;
ipv4List.splice(ipv4List.indexOf(ipv4CidrList[i]), 1);
ipv4List.push(ipv4ToStr(cidrIp1), ipv4ToStr(cidrIp2));
}
ipv4List = ipv4List.sort(ipv4Compare);
const ip1 = ipv4List[0];
const ip2 = ipv4List[ipv4List.length - 1];
const range = [ip1 + " - " + ip2];
return ipv4HyphenatedRange(range, includeNetworkInfo, enumerateAddresses, allowLargeList);
}
/**
* Parses a list of IPv6 addresses separated by a new line (\n) and displays information
* about it.
*
* @param {RegExp} list
* @param {boolean} includeNetworkInfo
* @returns {string}
*/
export function ipv6ListedRange(match, includeNetworkInfo) {
let ipv6List = match[0].split("\n");
ipv6List = ipv6List.filter(function(str) {
return str.trim();
});
for (let i =0; i < ipv6List.length; i++){
ipv6List[i] = ipv6List[i].trim();
}
const ipv6CidrList = ipv6List.filter(function(a) {
return a.includes("/");
});
for (let i = 0; i < ipv6CidrList.length; i++) {
const network = strToIpv6(ipv6CidrList[i].split("/")[0]);
const cidrRange = parseInt(ipv6CidrList[i].split("/")[1], 10);
if (cidrRange < 0 || cidrRange > 127) {
return "IPv6 CIDR must be less than 128";
}
const cidrIp1 = new Array(8),
cidrIp2 = new Array(8);
const mask = genIpv6Mask(cidrRange);
for (let j = 0; j < 8; j++) {
cidrIp1[j] = network[j] & mask[j];
cidrIp2[j] = cidrIp1[j] | (~mask[j] & 0x0000FFFF);
}
ipv6List.splice(ipv6List.indexOf(ipv6CidrList[i]), 1);
ipv6List.push(ipv6ToStr(cidrIp1), ipv6ToStr(cidrIp2));
}
ipv6List = ipv6List.sort(ipv6Compare);
const ip1 = ipv6List[0];
const ip2 = ipv6List[ipv6List.length - 1];
const range = [ip1 + " - " + ip2];
return ipv6HyphenatedRange(range, includeNetworkInfo);
}
/** /**
* Converts an IPv4 address from string format to numerical format. * Converts an IPv4 address from string format to numerical format.
* *
@@ -391,6 +479,37 @@ export function genIpv6Mask(cidr) {
return mask; return mask;
} }
/**
* Comparison operation for sorting of IPv4 addresses.
*
* @param {string} a
* @param {string} b
* @returns {number}
*/
export function ipv4Compare(a, b) {
return strToIpv4(a) - strToIpv4(b);
}
/**
* Comparison operation for sorting of IPv6 addresses.
*
* @param {string} a
* @param {string} b
* @returns {number}
*/
export function ipv6Compare(a, b) {
const a_ = strToIpv6(a),
b_ = strToIpv6(b);
for (let i = 0; i < a_.length; i++){
if (a_[i] !== b_[i]){
return a_[i] - b_[i];
}
}
return 0;
}
const _LARGE_RANGE_ERROR = "The specified range contains more than 65,536 addresses. Running this query could crash your browser. If you want to run it, select the \"Allow large queries\" option. You are advised to turn off \"Auto Bake\" whilst editing large ranges."; const _LARGE_RANGE_ERROR = "The specified range contains more than 65,536 addresses. Running this query could crash your browser. If you want to run it, select the \"Allow large queries\" option. You are advised to turn off \"Auto Bake\" whilst editing large ranges.";
/** /**

View File

@@ -287,6 +287,8 @@ class Magic {
useful: useful useful: useful
}); });
const prevOp = recipeConfig[recipeConfig.length - 1];
// Execute each of the matching operations, then recursively call the speculativeExecution() // Execute each of the matching operations, then recursively call the speculativeExecution()
// method on the resulting data, recording the properties of each option. // method on the resulting data, recording the properties of each option.
await Promise.all(matchingOps.map(async op => { await Promise.all(matchingOps.map(async op => {
@@ -294,8 +296,14 @@ class Magic {
op: op.op, op: op.op,
args: op.args args: op.args
}, },
output = await this._runRecipe([opConfig]), output = await this._runRecipe([opConfig]);
magic = new Magic(output, this.opPatterns),
// If the recipe is repeating and returning the same data, do not continue
if (prevOp && op.op === prevOp.op && _buffersEqual(output, this.inputBuffer)) {
return;
}
const magic = new Magic(output, this.opPatterns),
speculativeResults = await magic.speculativeExecution( speculativeResults = await magic.speculativeExecution(
depth-1, extLang, intensive, [...recipeConfig, opConfig], op.useful); depth-1, extLang, intensive, [...recipeConfig, opConfig], op.useful);
@@ -315,13 +323,16 @@ class Magic {
})); }));
} }
// Prune branches that do not match anything // Prune branches that result in unhelpful outputs
results = results.filter(r => results = results.filter(r =>
r.languageScores[0].probability > 0 || (r.useful || r.data.length > 0) && // The operation resulted in ""
r.fileType || ( // One of the following must be true
r.isUTF8 || r.languageScores[0].probability > 0 || // Some kind of language was found
r.matchingOps.length || r.fileType || // A file was found
r.useful); r.isUTF8 || // UTF-8 was found
r.matchingOps.length // A matching op was found
)
);
// Return a sorted list of possible recipes along with their properties // Return a sorted list of possible recipes along with their properties
return results.sort((a, b) => { return results.sort((a, b) => {
@@ -374,7 +385,7 @@ class Magic {
const recipe = new Recipe(recipeConfig); const recipe = new Recipe(recipeConfig);
try { try {
await recipe.execute(dish, 0); await recipe.execute(dish);
return dish.get(Dish.ARRAY_BUFFER); return dish.get(Dish.ARRAY_BUFFER);
} catch (err) { } catch (err) {
// If there are errors, return an empty buffer // If there are errors, return an empty buffer
@@ -395,7 +406,10 @@ class Magic {
let i = len; let i = len;
const counts = new Array(256).fill(0); const counts = new Array(256).fill(0);
if (!len) return counts; if (!len) {
this.freqDist = counts;
return this.freqDist;
}
while (i--) { while (i--) {
counts[this.inputBuffer[i]]++; counts[this.inputBuffer[i]]++;

View File

@@ -0,0 +1,78 @@
/**
* Parser for Type-length-value data.
*
* @author gchq77703 []
* @author n1474335 [n1474335@gmail.com]
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
const defaults = {
location: 0,
bytesInLength: 1,
basicEncodingRules: false
};
/**
* TLVParser library
*/
export default class TLVParser {
/**
* TLVParser constructor
*
* @param {byteArray} input
* @param {Object} options
*/
constructor(input, options) {
this.input = input;
Object.assign(this, defaults, options);
}
/**
* @returns {number}
*/
getLength() {
if (this.basicEncodingRules) {
const bit = this.input[this.location];
if (bit & 0x80) {
this.bytesInLength = bit & ~0x80;
} else {
this.location++;
return bit & ~0x80;
}
}
let length = 0;
for (let i = 0; i < this.bytesInLength; i++) {
length += this.input[this.location] * Math.pow(Math.pow(2, 8), i);
this.location++;
}
return length;
}
/**
* @param {number} length
* @returns {number[]}
*/
getValue(length) {
const value = [];
for (let i = 0; i < length; i++) {
if (this.location > this.input.length) return value;
value.push(this.input[this.location]);
this.location++;
}
return value;
}
/**
* @returns {boolean}
*/
atEnd() {
return this.input.length <= this.location;
}
}

View File

@@ -6,7 +6,7 @@
import Operation from "../Operation"; import Operation from "../Operation";
import Utils from "../Utils"; import Utils from "../Utils";
import { bitOp, add } from "../lib/BitwiseOp"; import { bitOp, add, BITWISE_OP_DELIMS } from "../lib/BitwiseOp";
/** /**
* ADD operation * ADD operation
@@ -22,6 +22,7 @@ class ADD extends Operation {
this.name = "ADD"; this.name = "ADD";
this.module = "Default"; this.module = "Default";
this.description = "ADD the input with the given key (e.g. <code>fe023da5</code>), MOD 255"; this.description = "ADD the input with the given key (e.g. <code>fe023da5</code>), MOD 255";
this.infoURL = "https://wikipedia.org/wiki/Bitwise_operation#Bitwise_operators";
this.inputType = "byteArray"; this.inputType = "byteArray";
this.outputType = "byteArray"; this.outputType = "byteArray";
this.args = [ this.args = [
@@ -29,7 +30,7 @@ class ADD extends Operation {
"name": "Key", "name": "Key",
"type": "toggleString", "type": "toggleString",
"value": "", "value": "",
"toggleValues": ["Hex", "Base64", "UTF8", "Latin1"] "toggleValues": BITWISE_OP_DELIMS
} }
]; ];
} }

View File

@@ -23,6 +23,7 @@ class AESDecrypt extends Operation {
this.name = "AES Decrypt"; this.name = "AES Decrypt";
this.module = "Ciphers"; this.module = "Ciphers";
this.description = "Advanced Encryption Standard (AES) is a U.S. Federal Information Processing Standard (FIPS). It was selected after a 5-year process where 15 competing designs were evaluated.<br><br><b>Key:</b> The following algorithms will be used based on the size of the key:<ul><li>16 bytes = AES-128</li><li>24 bytes = AES-192</li><li>32 bytes = AES-256</li></ul><br><br><b>IV:</b> The Initialization Vector should be 16 bytes long. If not entered, it will default to 16 null bytes.<br><br><b>Padding:</b> In CBC and ECB mode, PKCS#7 padding will be used.<br><br><b>GCM Tag:</b> This field is ignored unless 'GCM' mode is used."; this.description = "Advanced Encryption Standard (AES) is a U.S. Federal Information Processing Standard (FIPS). It was selected after a 5-year process where 15 competing designs were evaluated.<br><br><b>Key:</b> The following algorithms will be used based on the size of the key:<ul><li>16 bytes = AES-128</li><li>24 bytes = AES-192</li><li>32 bytes = AES-256</li></ul><br><br><b>IV:</b> The Initialization Vector should be 16 bytes long. If not entered, it will default to 16 null bytes.<br><br><b>Padding:</b> In CBC and ECB mode, PKCS#7 padding will be used.<br><br><b>GCM Tag:</b> This field is ignored unless 'GCM' mode is used.";
this.infoURL = "https://wikipedia.org/wiki/Advanced_Encryption_Standard";
this.inputType = "string"; this.inputType = "string";
this.outputType = "string"; this.outputType = "string";
this.args = [ this.args = [

View File

@@ -23,6 +23,7 @@ class AESEncrypt extends Operation {
this.name = "AES Encrypt"; this.name = "AES Encrypt";
this.module = "Ciphers"; this.module = "Ciphers";
this.description = "Advanced Encryption Standard (AES) is a U.S. Federal Information Processing Standard (FIPS). It was selected after a 5-year process where 15 competing designs were evaluated.<br><br><b>Key:</b> The following algorithms will be used based on the size of the key:<ul><li>16 bytes = AES-128</li><li>24 bytes = AES-192</li><li>32 bytes = AES-256</li></ul>You can generate a password-based key using one of the KDF operations.<br><br><b>IV:</b> The Initialization Vector should be 16 bytes long. If not entered, it will default to 16 null bytes.<br><br><b>Padding:</b> In CBC and ECB mode, PKCS#7 padding will be used."; this.description = "Advanced Encryption Standard (AES) is a U.S. Federal Information Processing Standard (FIPS). It was selected after a 5-year process where 15 competing designs were evaluated.<br><br><b>Key:</b> The following algorithms will be used based on the size of the key:<ul><li>16 bytes = AES-128</li><li>24 bytes = AES-192</li><li>32 bytes = AES-256</li></ul>You can generate a password-based key using one of the KDF operations.<br><br><b>IV:</b> The Initialization Vector should be 16 bytes long. If not entered, it will default to 16 null bytes.<br><br><b>Padding:</b> In CBC and ECB mode, PKCS#7 padding will be used.";
this.infoURL = "https://wikipedia.org/wiki/Advanced_Encryption_Standard";
this.inputType = "string"; this.inputType = "string";
this.outputType = "string"; this.outputType = "string";
this.args = [ this.args = [

View File

@@ -6,7 +6,7 @@
import Operation from "../Operation"; import Operation from "../Operation";
import Utils from "../Utils"; import Utils from "../Utils";
import { bitOp, and } from "../lib/BitwiseOp"; import { bitOp, and, BITWISE_OP_DELIMS } from "../lib/BitwiseOp";
/** /**
* AND operation * AND operation
@@ -22,6 +22,7 @@ class AND extends Operation {
this.name = "AND"; this.name = "AND";
this.module = "Default"; this.module = "Default";
this.description = "AND the input with the given key.<br>e.g. <code>fe023da5</code>"; this.description = "AND the input with the given key.<br>e.g. <code>fe023da5</code>";
this.infoURL = "https://wikipedia.org/wiki/Bitwise_operation#AND";
this.inputType = "byteArray"; this.inputType = "byteArray";
this.outputType = "byteArray"; this.outputType = "byteArray";
this.args = [ this.args = [
@@ -29,7 +30,7 @@ class AND extends Operation {
"name": "Key", "name": "Key",
"type": "toggleString", "type": "toggleString",
"value": "", "value": "",
"toggleValues": ["Hex", "Base64", "UTF8", "Latin1"] "toggleValues": BITWISE_OP_DELIMS
} }
]; ];
} }

View File

@@ -21,6 +21,7 @@ class Adler32Checksum extends Operation {
this.name = "Adler-32 Checksum"; this.name = "Adler-32 Checksum";
this.module = "Hashing"; this.module = "Hashing";
this.description = "Adler-32 is a checksum algorithm which was invented by Mark Adler in 1995, and is a modification of the Fletcher checksum. Compared to a cyclic redundancy check of the same length, it trades reliability for speed (preferring the latter).<br><br>Adler-32 is more reliable than Fletcher-16, and slightly less reliable than Fletcher-32."; this.description = "Adler-32 is a checksum algorithm which was invented by Mark Adler in 1995, and is a modification of the Fletcher checksum. Compared to a cyclic redundancy check of the same length, it trades reliability for speed (preferring the latter).<br><br>Adler-32 is more reliable than Fletcher-16, and slightly less reliable than Fletcher-32.";
this.infoURL = "https://wikipedia.org/wiki/Adler-32";
this.inputType = "byteArray"; this.inputType = "byteArray";
this.outputType = "string"; this.outputType = "string";
this.args = []; this.args = [];

View File

@@ -22,6 +22,7 @@ class AffineCipherDecode extends Operation {
this.name = "Affine Cipher Decode"; this.name = "Affine Cipher Decode";
this.module = "Ciphers"; this.module = "Ciphers";
this.description = "The Affine cipher is a type of monoalphabetic substitution cipher. To decrypt, each letter in an alphabet is mapped to its numeric equivalent, decrypted by a mathematical function, and converted back to a letter."; this.description = "The Affine cipher is a type of monoalphabetic substitution cipher. To decrypt, each letter in an alphabet is mapped to its numeric equivalent, decrypted by a mathematical function, and converted back to a letter.";
this.infoURL = "https://wikipedia.org/wiki/Affine_cipher";
this.inputType = "string"; this.inputType = "string";
this.outputType = "string"; this.outputType = "string";
this.args = [ this.args = [

View File

@@ -21,6 +21,7 @@ class AffineCipherEncode extends Operation {
this.name = "Affine Cipher Encode"; this.name = "Affine Cipher Encode";
this.module = "Ciphers"; this.module = "Ciphers";
this.description = "The Affine cipher is a type of monoalphabetic substitution cipher, wherein each letter in an alphabet is mapped to its numeric equivalent, encrypted using simple mathematical function, <code>(ax + b) % 26</code>, and converted back to a letter."; this.description = "The Affine cipher is a type of monoalphabetic substitution cipher, wherein each letter in an alphabet is mapped to its numeric equivalent, encrypted using simple mathematical function, <code>(ax + b) % 26</code>, and converted back to a letter.";
this.infoURL = "https://wikipedia.org/wiki/Affine_cipher";
this.inputType = "string"; this.inputType = "string";
this.outputType = "string"; this.outputType = "string";
this.args = [ this.args = [

View File

@@ -21,6 +21,7 @@ class AnalyseHash extends Operation {
this.name = "Analyse hash"; this.name = "Analyse hash";
this.module = "Hashing"; this.module = "Hashing";
this.description = "Tries to determine information about a given hash and suggests which algorithm may have been used to generate it based on its length."; this.description = "Tries to determine information about a given hash and suggests which algorithm may have been used to generate it based on its length.";
this.infoURL = "https://wikipedia.org/wiki/Comparison_of_cryptographic_hash_functions";
this.inputType = "string"; this.inputType = "string";
this.outputType = "string"; this.outputType = "string";
this.args = []; this.args = [];

View File

@@ -21,6 +21,7 @@ class AtbashCipher extends Operation {
this.name = "Atbash Cipher"; this.name = "Atbash Cipher";
this.module = "Ciphers"; this.module = "Ciphers";
this.description = "Atbash is a mono-alphabetic substitution cipher originally used to encode the Hebrew alphabet. It has been modified here for use with the Latin alphabet."; this.description = "Atbash is a mono-alphabetic substitution cipher originally used to encode the Hebrew alphabet. It has been modified here for use with the Latin alphabet.";
this.infoURL = "https://wikipedia.org/wiki/Atbash";
this.inputType = "string"; this.inputType = "string";
this.outputType = "string"; this.outputType = "string";
this.args = []; this.args = [];

View File

@@ -22,6 +22,7 @@ class BSONDeserialise extends Operation {
this.name = "BSON deserialise"; this.name = "BSON deserialise";
this.module = "BSON"; this.module = "BSON";
this.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."; this.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.";
this.infoURL = "https://wikipedia.org/wiki/BSON";
this.inputType = "ArrayBuffer"; this.inputType = "ArrayBuffer";
this.outputType = "string"; this.outputType = "string";
this.args = []; this.args = [];

View File

@@ -22,6 +22,7 @@ class BSONSerialise extends Operation {
this.name = "BSON serialise"; this.name = "BSON serialise";
this.module = "BSON"; this.module = "BSON";
this.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."; this.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.";
this.infoURL = "https://wikipedia.org/wiki/BSON";
this.inputType = "string"; this.inputType = "string";
this.outputType = "ArrayBuffer"; this.outputType = "ArrayBuffer";
this.args = []; this.args = [];

View File

@@ -21,6 +21,7 @@ class Bcrypt extends Operation {
this.name = "Bcrypt"; this.name = "Bcrypt";
this.module = "Hashing"; this.module = "Hashing";
this.description = "bcrypt is a password hashing function designed by Niels Provos and David Mazi\xe8res, 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."; this.description = "bcrypt is a password hashing function designed by Niels Provos and David Mazi\xe8res, 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.";
this.infoURL = "https://wikipedia.org/wiki/Bcrypt";
this.inputType = "string"; this.inputType = "string";
this.outputType = "string"; this.outputType = "string";
this.args = [ this.args = [

View File

@@ -21,6 +21,7 @@ class BcryptCompare extends Operation {
this.name = "Bcrypt compare"; this.name = "Bcrypt compare";
this.module = "Hashing"; this.module = "Hashing";
this.description = "Tests whether the input matches the given bcrypt hash. To test multiple possible passwords, use the 'Fork' operation."; this.description = "Tests whether the input matches the given bcrypt hash. To test multiple possible passwords, use the 'Fork' operation.";
this.infoURL = "https://wikipedia.org/wiki/Bcrypt";
this.inputType = "string"; this.inputType = "string";
this.outputType = "string"; this.outputType = "string";
this.args = [ this.args = [

View File

@@ -22,6 +22,7 @@ class BcryptParse extends Operation {
this.name = "Bcrypt parse"; this.name = "Bcrypt parse";
this.module = "Hashing"; this.module = "Hashing";
this.description = "Parses a bcrypt hash to determine the number of rounds used, the salt, and the password hash."; this.description = "Parses a bcrypt hash to determine the number of rounds used, the salt, and the password hash.";
this.infoURL = "https://wikipedia.org/wiki/Bcrypt";
this.inputType = "string"; this.inputType = "string";
this.outputType = "string"; this.outputType = "string";
this.args = []; this.args = [];

View File

@@ -22,6 +22,7 @@ class BifidCipherDecode extends Operation {
this.name = "Bifid Cipher Decode"; this.name = "Bifid Cipher Decode";
this.module = "Ciphers"; this.module = "Ciphers";
this.description = "The Bifid cipher is a cipher which uses a Polybius square in conjunction with transposition, which can be fairly difficult to decipher without knowing the alphabet keyword."; this.description = "The Bifid cipher is a cipher which uses a Polybius square in conjunction with transposition, which can be fairly difficult to decipher without knowing the alphabet keyword.";
this.infoURL = "https://wikipedia.org/wiki/Bifid_cipher";
this.inputType = "string"; this.inputType = "string";
this.outputType = "string"; this.outputType = "string";
this.args = [ this.args = [

View File

@@ -22,6 +22,7 @@ class BifidCipherEncode extends Operation {
this.name = "Bifid Cipher Encode"; this.name = "Bifid Cipher Encode";
this.module = "Ciphers"; this.module = "Ciphers";
this.description = "The Bifid cipher is a cipher which uses a Polybius square in conjunction with transposition, which can be fairly difficult to decipher without knowing the alphabet keyword."; this.description = "The Bifid cipher is a cipher which uses a Polybius square in conjunction with transposition, which can be fairly difficult to decipher without knowing the alphabet keyword.";
this.infoURL = "https://wikipedia.org/wiki/Bifid_cipher";
this.inputType = "string"; this.inputType = "string";
this.outputType = "string"; this.outputType = "string";
this.args = [ this.args = [

View File

@@ -20,6 +20,7 @@ class BitShiftLeft extends Operation {
this.name = "Bit shift left"; this.name = "Bit shift left";
this.module = "Default"; this.module = "Default";
this.description = "Shifts the bits in each byte towards the left by the specified amount."; this.description = "Shifts the bits in each byte towards the left by the specified amount.";
this.infoURL = "https://wikipedia.org/wiki/Bitwise_operation#Bit_shifts";
this.inputType = "byteArray"; this.inputType = "byteArray";
this.outputType = "byteArray"; this.outputType = "byteArray";
this.args = [ this.args = [

View File

@@ -20,6 +20,7 @@ class BitShiftRight extends Operation {
this.name = "Bit shift right"; this.name = "Bit shift right";
this.module = "Default"; this.module = "Default";
this.description = "Shifts the bits in each byte towards the right by the specified amount.<br><br><i>Logical shifts</i> replace the leftmost bits with zeros.<br><i>Arithmetic shifts</i> preserve the most significant bit (MSB) of the original byte keeping the sign the same (positive or negative)."; this.description = "Shifts the bits in each byte towards the right by the specified amount.<br><br><i>Logical shifts</i> replace the leftmost bits with zeros.<br><i>Arithmetic shifts</i> preserve the most significant bit (MSB) of the original byte keeping the sign the same (positive or negative).";
this.infoURL = "https://wikipedia.org/wiki/Bitwise_operation#Bit_shifts";
this.inputType = "byteArray"; this.inputType = "byteArray";
this.outputType = "byteArray"; this.outputType = "byteArray";
this.args = [ this.args = [

View File

@@ -38,6 +38,7 @@ class BlowfishDecrypt extends Operation {
this.name = "Blowfish Decrypt"; this.name = "Blowfish Decrypt";
this.module = "Ciphers"; this.module = "Ciphers";
this.description = "Blowfish is a symmetric-key block cipher designed in 1993 by Bruce Schneier and included in a large number of cipher suites and encryption products. AES now receives more attention.<br><br><b>IV:</b> The Initialization Vector should be 8 bytes long. If not entered, it will default to 8 null bytes."; this.description = "Blowfish is a symmetric-key block cipher designed in 1993 by Bruce Schneier and included in a large number of cipher suites and encryption products. AES now receives more attention.<br><br><b>IV:</b> The Initialization Vector should be 8 bytes long. If not entered, it will default to 8 null bytes.";
this.infoURL = "https://wikipedia.org/wiki/Blowfish_(cipher)";
this.inputType = "string"; this.inputType = "string";
this.outputType = "string"; this.outputType = "string";
this.args = [ this.args = [

View File

@@ -39,6 +39,7 @@ class BlowfishEncrypt extends Operation {
this.name = "Blowfish Encrypt"; this.name = "Blowfish Encrypt";
this.module = "Ciphers"; this.module = "Ciphers";
this.description = "Blowfish is a symmetric-key block cipher designed in 1993 by Bruce Schneier and included in a large number of cipher suites and encryption products. AES now receives more attention.<br><br><b>IV:</b> The Initialization Vector should be 8 bytes long. If not entered, it will default to 8 null bytes."; this.description = "Blowfish is a symmetric-key block cipher designed in 1993 by Bruce Schneier and included in a large number of cipher suites and encryption products. AES now receives more attention.<br><br><b>IV:</b> The Initialization Vector should be 8 bytes long. If not entered, it will default to 8 null bytes.";
this.infoURL = "https://wikipedia.org/wiki/Blowfish_(cipher)";
this.inputType = "string"; this.inputType = "string";
this.outputType = "string"; this.outputType = "string";
this.args = [ this.args = [

View File

@@ -5,7 +5,7 @@
*/ */
import Operation from "../Operation"; import Operation from "../Operation";
import bzip2 from "../vendor/bzip2.js"; import bzip2 from "../vendor/bzip2";
import OperationError from "../errors/OperationError"; import OperationError from "../errors/OperationError";
/** /**
@@ -22,6 +22,7 @@ class Bzip2Decompress extends Operation {
this.name = "Bzip2 Decompress"; this.name = "Bzip2 Decompress";
this.module = "Compression"; this.module = "Compression";
this.description = "Decompresses data using the Bzip2 algorithm."; this.description = "Decompresses data using the Bzip2 algorithm.";
this.infoURL = "https://wikipedia.org/wiki/Bzip2";
this.inputType = "byteArray"; this.inputType = "byteArray";
this.outputType = "string"; this.outputType = "string";
this.args = []; this.args = [];

View File

@@ -21,6 +21,7 @@ class CRC16Checksum extends Operation {
this.name = "CRC-16 Checksum"; this.name = "CRC-16 Checksum";
this.module = "Hashing"; this.module = "Hashing";
this.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."; this.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.";
this.infoURL = "https://wikipedia.org/wiki/Cyclic_redundancy_check";
this.inputType = "ArrayBuffer"; this.inputType = "ArrayBuffer";
this.outputType = "string"; this.outputType = "string";
this.args = []; this.args = [];

View File

@@ -21,6 +21,7 @@ class CRC32Checksum extends Operation {
this.name = "CRC-32 Checksum"; this.name = "CRC-32 Checksum";
this.module = "Hashing"; this.module = "Hashing";
this.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."; this.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.";
this.infoURL = "https://wikipedia.org/wiki/Cyclic_redundancy_check";
this.inputType = "ArrayBuffer"; this.inputType = "ArrayBuffer";
this.outputType = "string"; this.outputType = "string";
this.args = []; this.args = [];

View File

@@ -23,6 +23,7 @@ class CSSSelector extends Operation {
this.name = "CSS selector"; this.name = "CSS selector";
this.module = "Code"; this.module = "Code";
this.description = "Extract information from an HTML document with a CSS selector"; this.description = "Extract information from an HTML document with a CSS selector";
this.infoURL = "https://wikipedia.org/wiki/Cascading_Style_Sheets#Selector";
this.inputType = "string"; this.inputType = "string";
this.outputType = "string"; this.outputType = "string";
this.args = [ this.args = [

View File

@@ -21,6 +21,7 @@ class CTPH extends Operation {
this.name = "CTPH"; this.name = "CTPH";
this.module = "Hashing"; this.module = "Hashing";
this.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'."; this.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'.";
this.infoURL = "https://forensicswiki.org/wiki/Context_Triggered_Piecewise_Hashing";
this.inputType = "string"; this.inputType = "string";
this.outputType = "string"; this.outputType = "string";
this.args = []; this.args = [];

View File

@@ -21,6 +21,7 @@ class CartesianProduct extends Operation {
this.name = "Cartesian Product"; this.name = "Cartesian Product";
this.module = "Default"; this.module = "Default";
this.description = "Calculates the cartesian product of multiple sets of data, returning all possible combinations."; this.description = "Calculates the cartesian product of multiple sets of data, returning all possible combinations.";
this.infoURL = "https://wikipedia.org/wiki/Cartesian_product";
this.inputType = "string"; this.inputType = "string";
this.outputType = "string"; this.outputType = "string";
this.args = [ this.args = [

View File

@@ -21,7 +21,7 @@ class ChangeIPFormat extends Operation {
super(); super();
this.name = "Change IP format"; this.name = "Change IP format";
this.module = "JSBN"; this.module = "Default";
this.description = "Convert an IP address from one format to another, e.g. <code>172.20.23.54</code> to <code>ac141736</code>"; this.description = "Convert an IP address from one format to another, e.g. <code>172.20.23.54</code> to <code>ac141736</code>";
this.inputType = "string"; this.inputType = "string";
this.outputType = "string"; this.outputType = "string";
@@ -29,12 +29,12 @@ class ChangeIPFormat extends Operation {
{ {
"name": "Input format", "name": "Input format",
"type": "option", "type": "option",
"value": ["Hex", "Raw"] "value": ["Dotted Decimal", "Decimal", "Hex"]
}, },
{ {
"name": "Output format", "name": "Output format",
"type": "option", "type": "option",
"value": ["Hex", "Raw"] "value": ["Dotted Decimal", "Decimal", "Hex"]
} }
]; ];
} }

View File

@@ -20,6 +20,7 @@ class ChiSquare extends Operation {
this.name = "Chi Square"; this.name = "Chi Square";
this.module = "Default"; this.module = "Default";
this.description = "Calculates the Chi Square distribution of values."; this.description = "Calculates the Chi Square distribution of values.";
this.infoURL = "https://wikipedia.org/wiki/Chi-squared_distribution";
this.inputType = "ArrayBuffer"; this.inputType = "ArrayBuffer";
this.outputType = "number"; this.outputType = "number";
this.args = []; this.args = [];

View File

@@ -24,6 +24,7 @@ class CompareCTPHHashes extends Operation {
this.name = "Compare CTPH hashes"; this.name = "Compare CTPH hashes";
this.module = "Hashing"; this.module = "Hashing";
this.description = "Compares two Context Triggered Piecewise Hashing (CTPH) fuzzy hashes to determine the similarity between them on a scale of 0 to 100."; this.description = "Compares two Context Triggered Piecewise Hashing (CTPH) fuzzy hashes to determine the similarity between them on a scale of 0 to 100.";
this.infoURL = "https://forensicswiki.org/wiki/Context_Triggered_Piecewise_Hashing";
this.inputType = "string"; this.inputType = "string";
this.outputType = "Number"; this.outputType = "Number";
this.args = [ this.args = [

View File

@@ -24,6 +24,7 @@ class CompareSSDEEPHashes extends Operation {
this.name = "Compare SSDEEP hashes"; this.name = "Compare SSDEEP hashes";
this.module = "Hashing"; this.module = "Hashing";
this.description = "Compares two SSDEEP fuzzy hashes to determine the similarity between them on a scale of 0 to 100."; this.description = "Compares two SSDEEP fuzzy hashes to determine the similarity between them on a scale of 0 to 100.";
this.infoURL = "https://forensicswiki.org/wiki/Ssdeep";
this.inputType = "string"; this.inputType = "string";
this.outputType = "Number"; this.outputType = "Number";
this.args = [ this.args = [

View File

@@ -20,6 +20,7 @@ class ConvertArea extends Operation {
this.name = "Convert area"; this.name = "Convert area";
this.module = "Default"; this.module = "Default";
this.description = "Converts a unit of area to another format."; this.description = "Converts a unit of area to another format.";
this.infoURL = "https://wikipedia.org/wiki/Orders_of_magnitude_(area)";
this.inputType = "BigNumber"; this.inputType = "BigNumber";
this.outputType = "BigNumber"; this.outputType = "BigNumber";
this.args = [ this.args = [

View File

@@ -20,6 +20,7 @@ class ConvertDataUnits extends Operation {
this.name = "Convert data units"; this.name = "Convert data units";
this.module = "Default"; this.module = "Default";
this.description = "Converts a unit of data to another format."; this.description = "Converts a unit of data to another format.";
this.infoURL = "https://wikipedia.org/wiki/Orders_of_magnitude_(data)";
this.inputType = "BigNumber"; this.inputType = "BigNumber";
this.outputType = "BigNumber"; this.outputType = "BigNumber";
this.args = [ this.args = [

View File

@@ -20,6 +20,7 @@ class ConvertDistance extends Operation {
this.name = "Convert distance"; this.name = "Convert distance";
this.module = "Default"; this.module = "Default";
this.description = "Converts a unit of distance to another format."; this.description = "Converts a unit of distance to another format.";
this.infoURL = "https://wikipedia.org/wiki/Orders_of_magnitude_(length)";
this.inputType = "BigNumber"; this.inputType = "BigNumber";
this.outputType = "BigNumber"; this.outputType = "BigNumber";
this.args = [ this.args = [

View File

@@ -20,6 +20,7 @@ class ConvertMass extends Operation {
this.name = "Convert mass"; this.name = "Convert mass";
this.module = "Default"; this.module = "Default";
this.description = "Converts a unit of mass to another format."; this.description = "Converts a unit of mass to another format.";
this.infoURL = "https://wikipedia.org/wiki/Orders_of_magnitude_(mass)";
this.inputType = "BigNumber"; this.inputType = "BigNumber";
this.outputType = "BigNumber"; this.outputType = "BigNumber";
this.args = [ this.args = [

View File

@@ -20,6 +20,7 @@ class ConvertSpeed extends Operation {
this.name = "Convert speed"; this.name = "Convert speed";
this.module = "Default"; this.module = "Default";
this.description = "Converts a unit of speed to another format."; this.description = "Converts a unit of speed to another format.";
this.infoURL = "https://wikipedia.org/wiki/Orders_of_magnitude_(speed)";
this.inputType = "BigNumber"; this.inputType = "BigNumber";
this.outputType = "BigNumber"; this.outputType = "BigNumber";
this.args = [ this.args = [

View File

@@ -23,6 +23,7 @@ class DESDecrypt extends Operation {
this.name = "DES Decrypt"; this.name = "DES Decrypt";
this.module = "Ciphers"; this.module = "Ciphers";
this.description = "DES is a previously dominant algorithm for encryption, and was published as an official U.S. Federal Information Processing Standard (FIPS). It is now considered to be insecure due to its small key size.<br><br><b>Key:</b> DES uses a key length of 8 bytes (64 bits).<br>Triple DES uses a key length of 24 bytes (192 bits).<br><br><b>IV:</b> The Initialization Vector should be 8 bytes long. If not entered, it will default to 8 null bytes.<br><br><b>Padding:</b> In CBC and ECB mode, PKCS#7 padding will be used."; this.description = "DES is a previously dominant algorithm for encryption, and was published as an official U.S. Federal Information Processing Standard (FIPS). It is now considered to be insecure due to its small key size.<br><br><b>Key:</b> DES uses a key length of 8 bytes (64 bits).<br>Triple DES uses a key length of 24 bytes (192 bits).<br><br><b>IV:</b> The Initialization Vector should be 8 bytes long. If not entered, it will default to 8 null bytes.<br><br><b>Padding:</b> In CBC and ECB mode, PKCS#7 padding will be used.";
this.infoURL = "https://wikipedia.org/wiki/Data_Encryption_Standard";
this.inputType = "string"; this.inputType = "string";
this.outputType = "string"; this.outputType = "string";
this.args = [ this.args = [

View File

@@ -23,6 +23,7 @@ class DESEncrypt extends Operation {
this.name = "DES Encrypt"; this.name = "DES Encrypt";
this.module = "Ciphers"; this.module = "Ciphers";
this.description = "DES is a previously dominant algorithm for encryption, and was published as an official U.S. Federal Information Processing Standard (FIPS). It is now considered to be insecure due to its small key size.<br><br><b>Key:</b> DES uses a key length of 8 bytes (64 bits).<br>Triple DES uses a key length of 24 bytes (192 bits).<br><br>You can generate a password-based key using one of the KDF operations.<br><br><b>IV:</b> The Initialization Vector should be 8 bytes long. If not entered, it will default to 8 null bytes.<br><br><b>Padding:</b> In CBC and ECB mode, PKCS#7 padding will be used."; this.description = "DES is a previously dominant algorithm for encryption, and was published as an official U.S. Federal Information Processing Standard (FIPS). It is now considered to be insecure due to its small key size.<br><br><b>Key:</b> DES uses a key length of 8 bytes (64 bits).<br>Triple DES uses a key length of 24 bytes (192 bits).<br><br>You can generate a password-based key using one of the KDF operations.<br><br><b>IV:</b> The Initialization Vector should be 8 bytes long. If not entered, it will default to 8 null bytes.<br><br><b>Padding:</b> In CBC and ECB mode, PKCS#7 padding will be used.";
this.infoURL = "https://wikipedia.org/wiki/Data_Encryption_Standard";
this.inputType = "string"; this.inputType = "string";
this.outputType = "string"; this.outputType = "string";
this.args = [ this.args = [

View File

@@ -0,0 +1,51 @@
/**
* @author sevzero [sevzero@protonmail.com]
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import Operation from "../Operation";
/**
* Dechunk HTTP response operation
*/
class DechunkHTTPResponse extends Operation {
/**
* DechunkHTTPResponse constructor
*/
constructor() {
super();
this.name = "Dechunk HTTP response";
this.module = "Default";
this.description = "Parses an HTTP response transferred using Transfer-Encoding: Chunked";
this.infoURL = "https://wikipedia.org/wiki/Chunked_transfer_encoding";
this.inputType = "string";
this.outputType = "string";
this.args = [];
}
/**
* @param {string} input
* @param {Object[]} args
* @returns {string}
*/
run(input, args) {
const chunks = [];
let chunkSizeEnd = input.indexOf("\n") + 1;
const lineEndings = input.charAt(chunkSizeEnd - 2) === "\r" ? "\r\n" : "\n";
const lineEndingsLength = lineEndings.length;
let chunkSize = parseInt(input.slice(0, chunkSizeEnd), 16);
while (!isNaN(chunkSize)) {
chunks.push(input.slice(chunkSizeEnd, chunkSize + chunkSizeEnd));
input = input.slice(chunkSizeEnd + chunkSize + lineEndingsLength);
chunkSizeEnd = input.indexOf(lineEndings) + lineEndingsLength;
chunkSize = parseInt(input.slice(0, chunkSizeEnd), 16);
}
return chunks.join("") + input;
}
}
export default DechunkHTTPResponse;

View File

@@ -20,6 +20,7 @@ class DecodeNetBIOSName extends Operation {
this.name = "Decode NetBIOS Name"; this.name = "Decode NetBIOS Name";
this.module = "Default"; this.module = "Default";
this.description = "NetBIOS names as seen across the client interface to NetBIOS are exactly 16 bytes long. Within the NetBIOS-over-TCP protocols, a longer representation is used.<br><br>There are two levels of encoding. The first level maps a NetBIOS name into a domain system name. The second level maps the domain system name into the 'compressed' representation required for interaction with the domain name system.<br><br>This operation decodes the first level of encoding. See RFC 1001 for full details."; this.description = "NetBIOS names as seen across the client interface to NetBIOS are exactly 16 bytes long. Within the NetBIOS-over-TCP protocols, a longer representation is used.<br><br>There are two levels of encoding. The first level maps a NetBIOS name into a domain system name. The second level maps the domain system name into the 'compressed' representation required for interaction with the domain name system.<br><br>This operation decodes the first level of encoding. See RFC 1001 for full details.";
this.infoURL = "https://wikipedia.org/wiki/NetBIOS";
this.inputType = "byteArray"; this.inputType = "byteArray";
this.outputType = "byteArray"; this.outputType = "byteArray";
this.args = [ this.args = [

View File

@@ -29,6 +29,7 @@ class DecodeText extends Operation {
Object.keys(IO_FORMAT).map(e => `<li>${e}</li>`).join("\n"), Object.keys(IO_FORMAT).map(e => `<li>${e}</li>`).join("\n"),
"</ul>", "</ul>",
].join("\n"); ].join("\n");
this.infoURL = "https://wikipedia.org/wiki/Character_encoding";
this.inputType = "byteArray"; this.inputType = "byteArray";
this.outputType = "string"; this.outputType = "string";
this.args = [ this.args = [

View File

@@ -0,0 +1,102 @@
/**
* @author arnydo [arnydo@protonmail.com]
* @author n1474335 [n1474335@gmail.com]
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import Operation from "../Operation";
import {URL_REGEX, DOMAIN_REGEX} from "../lib/Extract";
/**
* DefangURL operation
*/
class DefangURL extends Operation {
/**
* DefangURL constructor
*/
constructor() {
super();
this.name = "Defang URL";
this.module = "Default";
this.description = "Takes a Universal Resource Locator (URL) and 'Defangs' it; meaning the URL becomes invalid, neutralising the risk of accidentally clicking on a malicious link.<br><br>This is often used when dealing with malicious links or IOCs.<br><br>Works well when combined with the 'Extract URLs' operation.";
this.infoURL = "https://isc.sans.edu/forums/diary/Defang+all+the+things/22744/";
this.inputType = "string";
this.outputType = "string";
this.args = [
{
name: "Escape dots",
type: "boolean",
value: true
},
{
name: "Escape http",
type: "boolean",
value: true
},
{
name: "Escape ://",
type: "boolean",
value: true
},
{
name: "Process",
type: "option",
value: ["Valid domains and full URLs", "Only full URLs", "Everything"]
}
];
}
/**
* @param {string} input
* @param {Object[]} args
* @returns {string}
*/
run(input, args) {
const [dots, http, slashes, process] = args;
switch (process) {
case "Valid domains and full URLs":
input = input.replace(URL_REGEX, x => {
return defangURL(x, dots, http, slashes);
});
input = input.replace(DOMAIN_REGEX, x => {
return defangURL(x, dots, http, slashes);
});
break;
case "Only full URLs":
input = input.replace(URL_REGEX, x => {
return defangURL(x, dots, http, slashes);
});
break;
case "Everything":
input = defangURL(input, dots, http, slashes);
break;
}
return input;
}
}
/**
* Defangs a given URL
*
* @param {string} url
* @param {boolean} dots
* @param {boolean} http
* @param {boolean} slashes
* @returns {string}
*/
function defangURL(url, dots, http, slashes) {
if (dots) url = url.replace(/\./g, "[.]");
if (http) url = url.replace(/http/gi, "hxxp");
if (slashes) url = url.replace(/:\/\//g, "[://]");
return url;
}
export default DefangURL;

View File

@@ -21,7 +21,8 @@ class DeriveEVPKey extends Operation {
this.name = "Derive EVP key"; this.name = "Derive EVP key";
this.module = "Ciphers"; this.module = "Ciphers";
this.description = "EVP is a password-based key derivation function (PBKDF) used extensively in OpenSSL. In many applications of cryptography, user security is ultimately dependent on a password, and because a password usually can't be used directly as a cryptographic key, some processing is required.<br><br>A salt provides a large set of keys for any given password, and an iteration count increases the cost of producing keys from a password, thereby also increasing the difficulty of attack.<br><br>If you leave the salt argument empty, a random salt will be generated."; this.description = "This operation performs a password-based key derivation function (PBKDF) used extensively in OpenSSL. In many applications of cryptography, user security is ultimately dependent on a password, and because a password usually can't be used directly as a cryptographic key, some processing is required.<br><br>A salt provides a large set of keys for any given password, and an iteration count increases the cost of producing keys from a password, thereby also increasing the difficulty of attack.<br><br>If you leave the salt argument empty, a random salt will be generated.";
this.infoURL = "https://wikipedia.org/wiki/Key_derivation_function";
this.inputType = "string"; this.inputType = "string";
this.outputType = "string"; this.outputType = "string";
this.args = [ this.args = [

View File

@@ -22,6 +22,7 @@ class DerivePBKDF2Key extends Operation {
this.name = "Derive PBKDF2 key"; this.name = "Derive PBKDF2 key";
this.module = "Ciphers"; this.module = "Ciphers";
this.description = "PBKDF2 is a password-based key derivation function. It is part of RSA Laboratories' Public-Key Cryptography Standards (PKCS) series, specifically PKCS #5 v2.0, also published as Internet Engineering Task Force's RFC 2898.<br><br>In many applications of cryptography, user security is ultimately dependent on a password, and because a password usually can't be used directly as a cryptographic key, some processing is required.<br><br>A salt provides a large set of keys for any given password, and an iteration count increases the cost of producing keys from a password, thereby also increasing the difficulty of attack.<br><br>If you leave the salt argument empty, a random salt will be generated."; this.description = "PBKDF2 is a password-based key derivation function. It is part of RSA Laboratories' Public-Key Cryptography Standards (PKCS) series, specifically PKCS #5 v2.0, also published as Internet Engineering Task Force's RFC 2898.<br><br>In many applications of cryptography, user security is ultimately dependent on a password, and because a password usually can't be used directly as a cryptographic key, some processing is required.<br><br>A salt provides a large set of keys for any given password, and an iteration count increases the cost of producing keys from a password, thereby also increasing the difficulty of attack.<br><br>If you leave the salt argument empty, a random salt will be generated.";
this.infoURL = "https://wikipedia.org/wiki/PBKDF2";
this.inputType = "string"; this.inputType = "string";
this.outputType = "string"; this.outputType = "string";
this.args = [ this.args = [

View File

@@ -21,6 +21,7 @@ class DetectFileType extends Operation {
this.name = "Detect File Type"; this.name = "Detect File Type";
this.module = "Default"; this.module = "Default";
this.description = "Attempts to guess the MIME (Multipurpose Internet Mail Extensions) type of the data based on 'magic bytes'.<br><br>Currently supports the following file types: 7z, amr, avi, bmp, bz2, class, cr2, crx, dex, dmg, doc, elf, eot, epub, exe, flac, flv, gif, gz, ico, iso, jpg, jxr, m4a, m4v, mid, mkv, mov, mp3, mp4, mpg, ogg, otf, pdf, png, ppt, ps, psd, rar, rtf, sqlite, swf, tar, tar.z, tif, ttf, utf8, vmdk, wav, webm, webp, wmv, woff, woff2, xls, xz, zip."; this.description = "Attempts to guess the MIME (Multipurpose Internet Mail Extensions) type of the data based on 'magic bytes'.<br><br>Currently supports the following file types: 7z, amr, avi, bmp, bz2, class, cr2, crx, dex, dmg, doc, elf, eot, epub, exe, flac, flv, gif, gz, ico, iso, jpg, jxr, m4a, m4v, mid, mkv, mov, mp3, mp4, mpg, ogg, otf, pdf, png, ppt, ps, psd, rar, rtf, sqlite, swf, tar, tar.z, tif, ttf, utf8, vmdk, wav, webm, webp, wmv, woff, woff2, xls, xz, zip.";
this.infoURL = "https://wikipedia.org/wiki/List_of_file_signatures";
this.inputType = "ArrayBuffer"; this.inputType = "ArrayBuffer";
this.outputType = "string"; this.outputType = "string";
this.args = []; this.args = [];

View File

@@ -23,6 +23,7 @@ class Diff extends Operation {
this.name = "Diff"; this.name = "Diff";
this.module = "Diff"; this.module = "Diff";
this.description = "Compares two inputs (separated by the specified delimiter) and highlights the differences between them."; this.description = "Compares two inputs (separated by the specified delimiter) and highlights the differences between them.";
this.infoURL = "https://wikipedia.org/wiki/File_comparison";
this.inputType = "string"; this.inputType = "string";
this.outputType = "html"; this.outputType = "html";
this.args = [ this.args = [

View File

@@ -22,6 +22,7 @@ class DisassembleX86 extends Operation {
this.name = "Disassemble x86"; this.name = "Disassemble x86";
this.module = "Shellcode"; this.module = "Shellcode";
this.description = "Disassembly is the process of translating machine language into assembly language.<br><br>This operation supports 64-bit, 32-bit and 16-bit code written for Intel or AMD x86 processors. It is particularly useful for reverse engineering shellcode.<br><br>Input should be in hexadecimal."; this.description = "Disassembly is the process of translating machine language into assembly language.<br><br>This operation supports 64-bit, 32-bit and 16-bit code written for Intel or AMD x86 processors. It is particularly useful for reverse engineering shellcode.<br><br>Input should be in hexadecimal.";
this.infoURL = "https://wikipedia.org/wiki/X86";
this.inputType = "string"; this.inputType = "string";
this.outputType = "string"; this.outputType = "string";
this.args = [ this.args = [

View File

@@ -5,7 +5,6 @@
*/ */
import Operation from "../Operation"; import Operation from "../Operation";
import OperationError from "../errors/OperationError";
/** /**
* Drop bytes operation * Drop bytes operation
@@ -20,7 +19,7 @@ class DropBytes extends Operation {
this.name = "Drop bytes"; this.name = "Drop bytes";
this.module = "Default"; this.module = "Default";
this.description = "Cuts a slice of the specified number of bytes out of the data."; this.description = "Cuts a slice of the specified number of bytes out of the data. Negative values are allowed.";
this.inputType = "ArrayBuffer"; this.inputType = "ArrayBuffer";
this.outputType = "ArrayBuffer"; this.outputType = "ArrayBuffer";
this.args = [ this.args = [
@@ -50,14 +49,25 @@ class DropBytes extends Operation {
* @throws {OperationError} if invalid input * @throws {OperationError} if invalid input
*/ */
run(input, args) { run(input, args) {
const start = args[0], let start = args[0],
length = args[1], length = args[1];
applyToEachLine = args[2]; const applyToEachLine = args[2];
if (start < 0 || length < 0)
throw new OperationError("Error: Invalid value");
if (!applyToEachLine) { if (!applyToEachLine) {
if (start < 0) { // Take from the end
start = input.byteLength + start;
}
if (length < 0) { // Flip start point
start = start + length;
if (start < 0) {
start = input.byteLength + start;
length = start - length;
} else {
length = -length;
}
}
const left = input.slice(0, start), const left = input.slice(0, start),
right = input.slice(start + length, input.byteLength); right = input.slice(start + length, input.byteLength);
const result = new Uint8Array(left.byteLength + right.byteLength); const result = new Uint8Array(left.byteLength + right.byteLength);
@@ -82,10 +92,28 @@ class DropBytes extends Operation {
} }
lines.push(line); lines.push(line);
let output = []; let output = [],
s = start,
l = length;
for (i = 0; i < lines.length; i++) { for (i = 0; i < lines.length; i++) {
output = output.concat(lines[i].slice(0, start).concat(lines[i].slice(start+length, lines[i].length))); if (s < 0) { // Take from the end
s = lines[i].length + s;
}
if (l < 0) { // Flip start point
s = s + l;
if (s < 0) {
s = lines[i].length + s;
l = s - l;
} else {
l = -l;
}
}
output = output.concat(lines[i].slice(0, s).concat(lines[i].slice(s+l, lines[i].length)));
output.push(0x0a); output.push(0x0a);
s = start;
l = length;
} }
return new Uint8Array(output.slice(0, output.length-1)).buffer; return new Uint8Array(output.slice(0, output.length-1)).buffer;
} }

View File

@@ -20,6 +20,7 @@ class EncodeNetBIOSName extends Operation {
this.name = "Encode NetBIOS Name"; this.name = "Encode NetBIOS Name";
this.module = "Default"; this.module = "Default";
this.description = "NetBIOS names as seen across the client interface to NetBIOS are exactly 16 bytes long. Within the NetBIOS-over-TCP protocols, a longer representation is used.<br><br>There are two levels of encoding. The first level maps a NetBIOS name into a domain system name. The second level maps the domain system name into the 'compressed' representation required for interaction with the domain name system.<br><br>This operation carries out the first level of encoding. See RFC 1001 for full details."; this.description = "NetBIOS names as seen across the client interface to NetBIOS are exactly 16 bytes long. Within the NetBIOS-over-TCP protocols, a longer representation is used.<br><br>There are two levels of encoding. The first level maps a NetBIOS name into a domain system name. The second level maps the domain system name into the 'compressed' representation required for interaction with the domain name system.<br><br>This operation carries out the first level of encoding. See RFC 1001 for full details.";
this.infoURL = "https://wikipedia.org/wiki/NetBIOS";
this.inputType = "byteArray"; this.inputType = "byteArray";
this.outputType = "byteArray"; this.outputType = "byteArray";
this.args = [ this.args = [

View File

@@ -29,6 +29,7 @@ class EncodeText extends Operation {
Object.keys(IO_FORMAT).map(e => `<li>${e}</li>`).join("\n"), Object.keys(IO_FORMAT).map(e => `<li>${e}</li>`).join("\n"),
"</ul>", "</ul>",
].join("\n"); ].join("\n");
this.infoURL = "https://wikipedia.org/wiki/Character_encoding";
this.inputType = "string"; this.inputType = "string";
this.outputType = "byteArray"; this.outputType = "byteArray";
this.args = [ this.args = [

View File

@@ -21,6 +21,7 @@ class Entropy extends Operation {
this.name = "Entropy"; this.name = "Entropy";
this.module = "Default"; this.module = "Default";
this.description = "Shannon Entropy, in the context of information theory, is a measure of the rate at which information is produced by a source of data. It can be used, in a broad sense, to detect whether data is likely to be structured or unstructured. 8 is the maximum, representing highly unstructured, 'random' data. English language text usually falls somewhere between 3.5 and 5. Properly encrypted or compressed data should have an entropy of over 7.5."; this.description = "Shannon Entropy, in the context of information theory, is a measure of the rate at which information is produced by a source of data. It can be used, in a broad sense, to detect whether data is likely to be structured or unstructured. 8 is the maximum, representing highly unstructured, 'random' data. English language text usually falls somewhere between 3.5 and 5. Properly encrypted or compressed data should have an entropy of over 7.5.";
this.infoURL = "https://wikipedia.org/wiki/Entropy_(information_theory)";
this.inputType = "byteArray"; this.inputType = "byteArray";
this.outputType = "number"; this.outputType = "number";
this.presentType = "html"; this.presentType = "html";

View File

@@ -22,6 +22,7 @@ class EscapeString extends Operation {
this.name = "Escape string"; this.name = "Escape string";
this.module = "Default"; this.module = "Default";
this.description = "Escapes special characters in a string so that they do not cause conflicts. For example, <code>Don't stop me now</code> becomes <code>Don\\'t stop me now</code>.<br><br>Supports the following escape sequences:<ul><li><code>\\n</code> (Line feed/newline)</li><li><code>\\r</code> (Carriage return)</li><li><code>\\t</code> (Horizontal tab)</li><li><code>\\b</code> (Backspace)</li><li><code>\\f</code> (Form feed)</li><li><code>\\xnn</code> (Hex, where n is 0-f)</li><li><code>\\\\</code> (Backslash)</li><li><code>\\'</code> (Single quote)</li><li><code>\\&quot;</code> (Double quote)</li><li><code>\\unnnn</code> (Unicode character)</li><li><code>\\u{nnnnnn}</code> (Unicode code point)</li></ul>"; this.description = "Escapes special characters in a string so that they do not cause conflicts. For example, <code>Don't stop me now</code> becomes <code>Don\\'t stop me now</code>.<br><br>Supports the following escape sequences:<ul><li><code>\\n</code> (Line feed/newline)</li><li><code>\\r</code> (Carriage return)</li><li><code>\\t</code> (Horizontal tab)</li><li><code>\\b</code> (Backspace)</li><li><code>\\f</code> (Form feed)</li><li><code>\\xnn</code> (Hex, where n is 0-f)</li><li><code>\\\\</code> (Backslash)</li><li><code>\\'</code> (Single quote)</li><li><code>\\&quot;</code> (Double quote)</li><li><code>\\unnnn</code> (Unicode character)</li><li><code>\\u{nnnnnn}</code> (Unicode code point)</li></ul>";
this.infoURL = "https://wikipedia.org/wiki/Escape_sequence";
this.inputType = "string"; this.inputType = "string";
this.outputType = "string"; this.outputType = "string";
this.args = [ this.args = [

View File

@@ -5,7 +5,7 @@
*/ */
import Operation from "../Operation"; import Operation from "../Operation";
import { search } from "../lib/Extract"; import { search, DOMAIN_REGEX } from "../lib/Extract";
/** /**
* Extract domains operation * Extract domains operation
@@ -38,10 +38,8 @@ class ExtractDomains extends Operation {
* @returns {string} * @returns {string}
*/ */
run(input, args) { run(input, args) {
const displayTotal = args[0], const displayTotal = args[0];
regex = /\b((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}\b/ig; return search(input, DOMAIN_REGEX, null, displayTotal);
return search(input, regex, null, displayTotal);
} }
} }

View File

@@ -28,6 +28,7 @@ class ExtractEXIF extends Operation {
"<br><br>", "<br><br>",
"EXIF data from photos usually contains information about the image file itself as well as the device used to create it.", "EXIF data from photos usually contains information about the image file itself as well as the device used to create it.",
].join("\n"); ].join("\n");
this.infoURL = "https://wikipedia.org/wiki/Exif";
this.inputType = "ArrayBuffer"; this.inputType = "ArrayBuffer";
this.outputType = "string"; this.outputType = "string";
this.args = []; this.args = [];

View File

@@ -39,8 +39,8 @@ class ExtractEmailAddresses extends Operation {
*/ */
run(input, args) { run(input, args) {
const displayTotal = args[0], const displayTotal = args[0],
regex = /\b\w[-.\w]*@[-\w]+(?:\.[-\w]+)*\.[A-Z]{2,4}\b/ig; // email regex from: https://www.regextester.com/98066
regex = /(?:[\u00A0-\uD7FF\uE000-\uFFFF-a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[\u00A0-\uD7FF\uE000-\uFFFF-a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[\u00A0-\uD7FF\uE000-\uFFFF-a-z0-9](?:[\u00A0-\uD7FF\uE000-\uFFFF-a-z0-9-]*[\u00A0-\uD7FF\uE000-\uFFFF-a-z0-9])?\.)+[\u00A0-\uD7FF\uE000-\uFFFF-a-z0-9](?:[\u00A0-\uD7FF\uE000-\uFFFF-a-z0-9-]*[\u00A0-\uD7FF\uE000-\uFFFF-a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/ig;
return search(input, regex, null, displayTotal); return search(input, regex, null, displayTotal);
} }

View File

@@ -5,7 +5,7 @@
*/ */
import Operation from "../Operation"; import Operation from "../Operation";
import { search } from "../lib/Extract"; import { search, URL_REGEX } from "../lib/Extract";
/** /**
* Extract URLs operation * Extract URLs operation
@@ -38,16 +38,8 @@ class ExtractURLs extends Operation {
* @returns {string} * @returns {string}
*/ */
run(input, args) { run(input, args) {
const displayTotal = args[0], const displayTotal = args[0];
protocol = "[A-Z]+://", return search(input, URL_REGEX, null, displayTotal);
hostname = "[-\\w]+(?:\\.\\w[-\\w]*)+",
port = ":\\d+";
let path = "/[^.!,?\"<>\\[\\]{}\\s\\x7F-\\xFF]*";
path += "(?:[.!,?]+[^.!,?\"<>\\[\\]{}\\s\\x7F-\\xFF]+)*";
const regex = new RegExp(protocol + hostname + "(?:" + port +
")?(?:" + path + ")?", "ig");
return search(input, regex, null, displayTotal);
} }
} }

View File

@@ -8,6 +8,7 @@ import Operation from "../Operation";
import Utils from "../Utils"; import Utils from "../Utils";
import {INPUT_DELIM_OPTIONS} from "../lib/Delim"; import {INPUT_DELIM_OPTIONS} from "../lib/Delim";
import OperationError from "../errors/OperationError"; import OperationError from "../errors/OperationError";
import XRegExp from "xregexp";
/** /**
* Filter operation * Filter operation
@@ -21,7 +22,7 @@ class Filter extends Operation {
super(); super();
this.name = "Filter"; this.name = "Filter";
this.module = "Default"; this.module = "Regex";
this.description = "Splits up the input using the specified delimiter and then filters each branch based on a regular expression."; this.description = "Splits up the input using the specified delimiter and then filters each branch based on a regular expression.";
this.inputType = "string"; this.inputType = "string";
this.outputType = "string"; this.outputType = "string";
@@ -55,7 +56,7 @@ class Filter extends Operation {
let regex; let regex;
try { try {
regex = new RegExp(args[1]); regex = new XRegExp(args[1]);
} catch (err) { } catch (err) {
throw new OperationError(`Invalid regex. Details: ${err.message}`); throw new OperationError(`Invalid regex. Details: ${err.message}`);
} }

View File

@@ -6,6 +6,7 @@
import Operation from "../Operation"; import Operation from "../Operation";
import Utils from "../Utils"; import Utils from "../Utils";
import XRegExp from "xregexp";
/** /**
* Find / Replace operation * Find / Replace operation
@@ -21,6 +22,7 @@ class FindReplace extends Operation {
this.name = "Find / Replace"; this.name = "Find / Replace";
this.module = "Regex"; this.module = "Regex";
this.description = "Replaces all occurrences of the first string with the second.<br><br>Includes support for regular expressions (regex), simple strings and extended strings (which support \\n, \\r, \\t, \\b, \\f and escaped hex bytes using \\x notation, e.g. \\x00 for a null byte)."; this.description = "Replaces all occurrences of the first string with the second.<br><br>Includes support for regular expressions (regex), simple strings and extended strings (which support \\n, \\r, \\t, \\b, \\f and escaped hex bytes using \\x notation, e.g. \\x00 for a null byte).";
this.infoURL = "https://wikipedia.org/wiki/Regular_expression";
this.inputType = "string"; this.inputType = "string";
this.outputType = "string"; this.outputType = "string";
this.args = [ this.args = [
@@ -49,6 +51,11 @@ class FindReplace extends Operation {
"name": "Multiline matching", "name": "Multiline matching",
"type": "boolean", "type": "boolean",
"value": true "value": true
},
{
"name": "Dot matches all",
"type": "boolean",
"value": false
} }
]; ];
} }
@@ -59,16 +66,17 @@ class FindReplace extends Operation {
* @returns {string} * @returns {string}
*/ */
run(input, args) { run(input, args) {
const [{option: type}, replace, g, i, m] = args; const [{option: type}, replace, g, i, m, s] = args;
let find = args[0].string, let find = args[0].string,
modifiers = ""; modifiers = "";
if (g) modifiers += "g"; if (g) modifiers += "g";
if (i) modifiers += "i"; if (i) modifiers += "i";
if (m) modifiers += "m"; if (m) modifiers += "m";
if (s) modifiers += "s";
if (type === "Regex") { if (type === "Regex") {
find = new RegExp(find, modifiers); find = new XRegExp(find, modifiers);
return input.replace(find, replace); return input.replace(find, replace);
} }
@@ -76,7 +84,7 @@ class FindReplace extends Operation {
find = Utils.parseEscapedChars(find); find = Utils.parseEscapedChars(find);
} }
find = new RegExp(Utils.escapeRegex(find), modifiers); find = new XRegExp(Utils.escapeRegex(find), modifiers);
return input.replace(find, replace); return input.replace(find, replace);
} }

View File

@@ -21,6 +21,7 @@ class Fletcher16Checksum extends Operation {
this.name = "Fletcher-16 Checksum"; this.name = "Fletcher-16 Checksum";
this.module = "Hashing"; this.module = "Hashing";
this.description = "The Fletcher checksum is an algorithm for computing a position-dependent checksum devised by John Gould Fletcher at Lawrence Livermore Labs in the late 1970s.<br><br>The objective of the Fletcher checksum was to provide error-detection properties approaching those of a cyclic redundancy check but with the lower computational effort associated with summation techniques."; this.description = "The Fletcher checksum is an algorithm for computing a position-dependent checksum devised by John Gould Fletcher at Lawrence Livermore Labs in the late 1970s.<br><br>The objective of the Fletcher checksum was to provide error-detection properties approaching those of a cyclic redundancy check but with the lower computational effort associated with summation techniques.";
this.infoURL = "https://wikipedia.org/wiki/Fletcher%27s_checksum#Fletcher-16";
this.inputType = "byteArray"; this.inputType = "byteArray";
this.outputType = "string"; this.outputType = "string";
this.args = []; this.args = [];

View File

@@ -21,6 +21,7 @@ class Fletcher32Checksum extends Operation {
this.name = "Fletcher-32 Checksum"; this.name = "Fletcher-32 Checksum";
this.module = "Hashing"; this.module = "Hashing";
this.description = "The Fletcher checksum is an algorithm for computing a position-dependent checksum devised by John Gould Fletcher at Lawrence Livermore Labs in the late 1970s.<br><br>The objective of the Fletcher checksum was to provide error-detection properties approaching those of a cyclic redundancy check but with the lower computational effort associated with summation techniques."; this.description = "The Fletcher checksum is an algorithm for computing a position-dependent checksum devised by John Gould Fletcher at Lawrence Livermore Labs in the late 1970s.<br><br>The objective of the Fletcher checksum was to provide error-detection properties approaching those of a cyclic redundancy check but with the lower computational effort associated with summation techniques.";
this.infoURL = "https://wikipedia.org/wiki/Fletcher%27s_checksum#Fletcher-32";
this.inputType = "byteArray"; this.inputType = "byteArray";
this.outputType = "string"; this.outputType = "string";
this.args = []; this.args = [];

View File

@@ -21,6 +21,7 @@ class Fletcher64Checksum extends Operation {
this.name = "Fletcher-64 Checksum"; this.name = "Fletcher-64 Checksum";
this.module = "Hashing"; this.module = "Hashing";
this.description = "The Fletcher checksum is an algorithm for computing a position-dependent checksum devised by John Gould Fletcher at Lawrence Livermore Labs in the late 1970s.<br><br>The objective of the Fletcher checksum was to provide error-detection properties approaching those of a cyclic redundancy check but with the lower computational effort associated with summation techniques."; this.description = "The Fletcher checksum is an algorithm for computing a position-dependent checksum devised by John Gould Fletcher at Lawrence Livermore Labs in the late 1970s.<br><br>The objective of the Fletcher checksum was to provide error-detection properties approaching those of a cyclic redundancy check but with the lower computational effort associated with summation techniques.";
this.infoURL = "https://wikipedia.org/wiki/Fletcher%27s_checksum#Fletcher-64";
this.inputType = "byteArray"; this.inputType = "byteArray";
this.outputType = "string"; this.outputType = "string";
this.args = []; this.args = [];

View File

@@ -21,6 +21,7 @@ class Fletcher8Checksum extends Operation {
this.name = "Fletcher-8 Checksum"; this.name = "Fletcher-8 Checksum";
this.module = "Hashing"; this.module = "Hashing";
this.description = "The Fletcher checksum is an algorithm for computing a position-dependent checksum devised by John Gould Fletcher at Lawrence Livermore Labs in the late 1970s.<br><br>The objective of the Fletcher checksum was to provide error-detection properties approaching those of a cyclic redundancy check but with the lower computational effort associated with summation techniques."; this.description = "The Fletcher checksum is an algorithm for computing a position-dependent checksum devised by John Gould Fletcher at Lawrence Livermore Labs in the late 1970s.<br><br>The objective of the Fletcher checksum was to provide error-detection properties approaching those of a cyclic redundancy check but with the lower computational effort associated with summation techniques.";
this.infoURL = "https://wikipedia.org/wiki/Fletcher%27s_checksum";
this.inputType = "byteArray"; this.inputType = "byteArray";
this.outputType = "string"; this.outputType = "string";
this.args = []; this.args = [];

View File

@@ -20,6 +20,7 @@ class FormatMACAddresses extends Operation {
this.name = "Format MAC addresses"; this.name = "Format MAC addresses";
this.module = "Default"; this.module = "Default";
this.description = "Displays given MAC addresses in multiple different formats.<br><br>Expects addresses in a list separated by newlines, spaces or commas.<br><br>WARNING: There are no validity checks."; this.description = "Displays given MAC addresses in multiple different formats.<br><br>Expects addresses in a list separated by newlines, spaces or commas.<br><br>WARNING: There are no validity checks.";
this.infoURL = "https://wikipedia.org/wiki/MAC_address#Notational_conventions";
this.inputType = "string"; this.inputType = "string";
this.outputType = "string"; this.outputType = "string";
this.args = [ this.args = [

View File

@@ -22,6 +22,7 @@ class FrequencyDistribution extends Operation {
this.name = "Frequency distribution"; this.name = "Frequency distribution";
this.module = "Default"; this.module = "Default";
this.description = "Displays the distribution of bytes in the data as a graph."; this.description = "Displays the distribution of bytes in the data as a graph.";
this.infoURL = "https://wikipedia.org/wiki/Frequency_distribution";
this.inputType = "ArrayBuffer"; this.inputType = "ArrayBuffer";
this.outputType = "json"; this.outputType = "json";
this.presentType = "html"; this.presentType = "html";

View File

@@ -24,6 +24,7 @@ class FromBCD extends Operation {
this.name = "From BCD"; this.name = "From BCD";
this.module = "Default"; this.module = "Default";
this.description = "Binary-Coded Decimal (BCD) is a class of binary encodings of decimal numbers where each decimal digit is represented by a fixed number of bits, usually four or eight. Special bit patterns are sometimes used for a sign."; this.description = "Binary-Coded Decimal (BCD) is a class of binary encodings of decimal numbers where each decimal digit is represented by a fixed number of bits, usually four or eight. Special bit patterns are sometimes used for a sign.";
this.infoURL = "https://wikipedia.org/wiki/Binary-coded_decimal";
this.inputType = "string"; this.inputType = "string";
this.outputType = "BigNumber"; this.outputType = "BigNumber";
this.args = [ this.args = [

View File

@@ -22,6 +22,7 @@ class FromBase extends Operation {
this.name = "From Base"; this.name = "From Base";
this.module = "Default"; this.module = "Default";
this.description = "Converts a number to decimal from a given numerical base."; this.description = "Converts a number to decimal from a given numerical base.";
this.infoURL = "https://wikipedia.org/wiki/Radix";
this.inputType = "string"; this.inputType = "string";
this.outputType = "BigNumber"; this.outputType = "BigNumber";
this.args = [ this.args = [

View File

@@ -21,6 +21,7 @@ class FromBase32 extends Operation {
this.name = "From Base32"; this.name = "From Base32";
this.module = "Default"; this.module = "Default";
this.description = "Base32 is a notation for encoding arbitrary byte data using a restricted set of symbols that can be conveniently used by humans and processed by computers. It uses a smaller set of characters than Base64, usually the uppercase alphabet and the numbers 2 to 7."; this.description = "Base32 is a notation for encoding arbitrary byte data using a restricted set of symbols that can be conveniently used by humans and processed by computers. It uses a smaller set of characters than Base64, usually the uppercase alphabet and the numbers 2 to 7.";
this.infoURL = "https://wikipedia.org/wiki/Base32";
this.inputType = "string"; this.inputType = "string";
this.outputType = "byteArray"; this.outputType = "byteArray";
this.args = [ this.args = [

View File

@@ -23,6 +23,7 @@ class FromBase58 extends Operation {
this.name = "From Base58"; this.name = "From Base58";
this.module = "Default"; this.module = "Default";
this.description = "Base58 (similar to Base64) is a notation for encoding arbitrary byte data. It differs from Base64 by removing easily misread characters (i.e. l, I, 0 and O) to improve human readability.<br><br>This operation decodes data from an ASCII string (with an alphabet of your choosing, presets included) back into its raw form.<br><br>e.g. <code>StV1DL6CwTryKyV</code> becomes <code>hello world</code><br><br>Base58 is commonly used in cryptocurrencies (Bitcoin, Ripple, etc)."; this.description = "Base58 (similar to Base64) is a notation for encoding arbitrary byte data. It differs from Base64 by removing easily misread characters (i.e. l, I, 0 and O) to improve human readability.<br><br>This operation decodes data from an ASCII string (with an alphabet of your choosing, presets included) back into its raw form.<br><br>e.g. <code>StV1DL6CwTryKyV</code> becomes <code>hello world</code><br><br>Base58 is commonly used in cryptocurrencies (Bitcoin, Ripple, etc).";
this.infoURL = "https://wikipedia.org/wiki/Base58";
this.inputType = "string"; this.inputType = "string";
this.outputType = "byteArray"; this.outputType = "byteArray";
this.args = [ this.args = [
@@ -70,6 +71,11 @@ class FromBase58 extends Operation {
if (input.length === 0) return []; if (input.length === 0) return [];
let zeroPrefix = 0;
for (let i = 0; i < input.length && input[i] === alphabet[0]; i++) {
zeroPrefix++;
}
[].forEach.call(input, function(c, charIndex) { [].forEach.call(input, function(c, charIndex) {
const index = alphabet.indexOf(c); const index = alphabet.indexOf(c);
@@ -97,6 +103,10 @@ class FromBase58 extends Operation {
} }
}); });
while (zeroPrefix--) {
result.push(0);
}
return result.reverse(); return result.reverse();
} }

View File

@@ -21,6 +21,7 @@ class FromBase64 extends Operation {
this.name = "From Base64"; this.name = "From Base64";
this.module = "Default"; this.module = "Default";
this.description = "Base64 is a notation for encoding arbitrary byte data using a restricted set of symbols that can be conveniently used by humans and processed by computers.<br><br>This operation decodes data from an ASCII Base64 string back into its raw format.<br><br>e.g. <code>aGVsbG8=</code> becomes <code>hello</code>"; this.description = "Base64 is a notation for encoding arbitrary byte data using a restricted set of symbols that can be conveniently used by humans and processed by computers.<br><br>This operation decodes data from an ASCII Base64 string back into its raw format.<br><br>e.g. <code>aGVsbG8=</code> becomes <code>hello</code>";
this.infoURL = "https://wikipedia.org/wiki/Base64";
this.inputType = "string"; this.inputType = "string";
this.outputType = "byteArray"; this.outputType = "byteArray";
this.args = [ this.args = [

View File

@@ -0,0 +1,105 @@
/**
* @author PenguinGeorge [george@penguingeorge.com]
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import Operation from "../Operation";
import OperationError from "../errors/OperationError";
import Utils from "../Utils";
import {alphabetName, ALPHABET_OPTIONS} from "../lib/Base85";
/**
* From Base85 operation
*/
class FromBase85 extends Operation {
/**
* From Base85 constructor
*/
constructor() {
super();
this.name = "From Base85";
this.module = "Default";
this.description = "Base85 (also called Ascii85) is a notation for encoding arbitrary byte data. It is usually more efficient that Base64.<br><br>This operation decodes data from an ASCII string (with an alphabet of your choosing, presets included).<br><br>e.g. <code>BOu!rD]j7BEbo7</code> becomes <code>hello world</code><br><br>Base85 is commonly used in Adobe's PostScript and PDF file formats.";
this.infoURL = "https://wikipedia.org/wiki/Ascii85";
this.inputType = "string";
this.outputType = "byteArray";
this.args = [
{
name: "Alphabet",
type: "editableOption",
value: ALPHABET_OPTIONS
},
];
}
/**
* @param {string} input
* @param {Object[]} args
* @returns {byteArray}
*/
run(input, args) {
const alphabet = Utils.expandAlphRange(args[0]).join(""),
encoding = alphabetName(alphabet),
result = [];
if (alphabet.length !== 85 ||
[].unique.call(alphabet).length !== 85) {
throw new OperationError("Alphabet must be of length 85");
}
if (input.length === 0) return [];
const matches = input.match(/<~(.+?)~>/);
if (matches !== null) input = matches[1];
let i = 0;
let block, blockBytes;
while (i < input.length) {
if (encoding === "Standard" && input[i] === "z") {
result.push(0, 0, 0, 0);
i++;
} else {
let digits = [];
digits = input
.substr(i, 5)
.split("")
.map((chr, idx) => {
const digit = alphabet.indexOf(chr);
if (digit < 0 || digit > 84) {
throw `Invalid character '${chr}' at index ${idx}`;
}
return digit;
});
block =
digits[0] * 52200625 +
digits[1] * 614125 +
(i + 2 < input.length ? digits[2] : 84) * 7225 +
(i + 3 < input.length ? digits[3] : 84) * 85 +
(i + 4 < input.length ? digits[4] : 84);
blockBytes = [
(block >> 24) & 0xff,
(block >> 16) & 0xff,
(block >> 8) & 0xff,
block & 0xff
];
if (input.length < i + 5) {
blockBytes.splice(input.length - (i + 5), 5);
}
result.push.apply(result, blockBytes);
i += 5;
}
}
return result;
}
}
export default FromBase85;

View File

@@ -7,6 +7,7 @@
import Operation from "../Operation"; import Operation from "../Operation";
import Utils from "../Utils"; import Utils from "../Utils";
import {BIN_DELIM_OPTIONS} from "../lib/Delim"; import {BIN_DELIM_OPTIONS} from "../lib/Delim";
import {fromBinary} from "../lib/Binary";
/** /**
* From Binary operation * From Binary operation
@@ -22,6 +23,7 @@ class FromBinary extends Operation {
this.name = "From Binary"; this.name = "From Binary";
this.module = "Default"; this.module = "Default";
this.description = "Converts a binary string back into its raw form.<br><br>e.g. <code>01001000 01101001</code> becomes <code>Hi</code>"; this.description = "Converts a binary string back into its raw form.<br><br>e.g. <code>01001000 01101001</code> becomes <code>Hi</code>";
this.infoURL = "https://wikipedia.org/wiki/Binary_code";
this.inputType = "string"; this.inputType = "string";
this.outputType = "byteArray"; this.outputType = "byteArray";
this.args = [ this.args = [
@@ -76,15 +78,7 @@ class FromBinary extends Operation {
* @returns {byteArray} * @returns {byteArray}
*/ */
run(input, args) { run(input, args) {
const delimRegex = Utils.regexRep(args[0] || "Space"); return fromBinary(input, args[0]);
input = input.replace(delimRegex, "");
const output = [];
const byteLen = 8;
for (let i = 0; i < input.length; i += byteLen) {
output.push(parseInt(input.substr(i, byteLen), 2));
}
return output;
} }
/** /**

View File

@@ -0,0 +1,70 @@
/**
* @author n1474335 [n1474335@gmail.com]
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import Operation from "../Operation";
import {BRAILLE_LOOKUP} from "../lib/Braille";
/**
* From Braille operation
*/
class FromBraille extends Operation {
/**
* FromBraille constructor
*/
constructor() {
super();
this.name = "From Braille";
this.module = "Default";
this.description = "Converts six-dot braille symbols to text.";
this.infoURL = "https://wikipedia.org/wiki/Braille";
this.inputType = "string";
this.outputType = "string";
this.args = [];
}
/**
* @param {string} input
* @param {Object[]} args
* @returns {string}
*/
run(input, args) {
return input.split("").map(b => {
const idx = BRAILLE_LOOKUP.dot6.indexOf(b);
return idx < 0 ? b : BRAILLE_LOOKUP.ascii[idx];
}).join("");
}
/**
* Highlight From Braille
*
* @param {Object[]} pos
* @param {number} pos[].start
* @param {number} pos[].end
* @param {Object[]} args
* @returns {Object[]} pos
*/
highlight(pos, args) {
return pos;
}
/**
* Highlight From Braille in reverse
*
* @param {Object[]} pos
* @param {number} pos[].start
* @param {number} pos[].end
* @param {Object[]} args
* @returns {Object[]} pos
*/
highlightReverse(pos, args) {
return pos;
}
}
export default FromBraille;

View File

@@ -23,6 +23,7 @@ class FromCharcode extends Operation {
this.name = "From Charcode"; this.name = "From Charcode";
this.module = "Default"; this.module = "Default";
this.description = "Converts unicode character codes back into text.<br><br>e.g. <code>0393 03b5 03b9 03ac 20 03c3 03bf 03c5</code> becomes <code>Γειά σου</code>"; this.description = "Converts unicode character codes back into text.<br><br>e.g. <code>0393 03b5 03b9 03ac 20 03c3 03bf 03c5</code> becomes <code>Γειά σου</code>";
this.infoURL = "https://wikipedia.org/wiki/Plane_(Unicode)";
this.inputType = "string"; this.inputType = "string";
this.outputType = "byteArray"; this.outputType = "byteArray";
this.args = [ this.args = [

View File

@@ -5,8 +5,8 @@
*/ */
import Operation from "../Operation"; import Operation from "../Operation";
import Utils from "../Utils";
import {DELIM_OPTIONS} from "../lib/Delim"; import {DELIM_OPTIONS} from "../lib/Delim";
import {fromDecimal} from "../lib/Decimal";
/** /**
* From Decimal operation * From Decimal operation
@@ -29,38 +29,43 @@ class FromDecimal extends Operation {
"name": "Delimiter", "name": "Delimiter",
"type": "option", "type": "option",
"value": DELIM_OPTIONS "value": DELIM_OPTIONS
},
{
"name": "Support signed values",
"type": "boolean",
"value": false
} }
]; ];
this.patterns = [ this.patterns = [
{ {
match: "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?: (?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5]))*$", match: "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?: (?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5]))*$",
flags: "", flags: "",
args: ["Space"] args: ["Space", false]
}, },
{ {
match: "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?:,(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5]))*$", match: "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?:,(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5]))*$",
flags: "", flags: "",
args: ["Comma"] args: ["Comma", false]
}, },
{ {
match: "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?:;(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5]))*$", match: "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?:;(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5]))*$",
flags: "", flags: "",
args: ["Semi-colon"] args: ["Semi-colon", false]
}, },
{ {
match: "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?::(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5]))*$", match: "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?::(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5]))*$",
flags: "", flags: "",
args: ["Colon"] args: ["Colon", false]
}, },
{ {
match: "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?:\\n(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5]))*$", match: "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?:\\n(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5]))*$",
flags: "", flags: "",
args: ["Line feed"] args: ["Line feed", false]
}, },
{ {
match: "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?:\\r\\n(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5]))*$", match: "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?:\\r\\n(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5]))*$",
flags: "", flags: "",
args: ["CRLF"] args: ["CRLF", false]
}, },
]; ];
} }
@@ -71,16 +76,11 @@ class FromDecimal extends Operation {
* @returns {byteArray} * @returns {byteArray}
*/ */
run(input, args) { run(input, args) {
const delim = Utils.charRep(args[0]), let data = fromDecimal(input, args[0]);
output = []; if (args[1]) { // Convert negatives
let byteStr = input.split(delim); data = data.map(v => v < 0 ? 0xFF + v + 1 : v);
if (byteStr[byteStr.length-1] === "")
byteStr = byteStr.slice(0, byteStr.length-1);
for (let i = 0; i < byteStr.length; i++) {
output[i] = parseInt(byteStr[i], 10);
} }
return output; return data;
} }
} }

View File

@@ -0,0 +1,44 @@
/**
* @author gchq77703 []
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import Operation from "../Operation";
import geohash from "ngeohash";
/**
* From Geohash operation
*/
class FromGeohash extends Operation {
/**
* FromGeohash constructor
*/
constructor() {
super();
this.name = "From Geohash";
this.module = "Hashing";
this.description = "Converts Geohash strings into Lat/Long coordinates. For example, <code>ww8p1r4t8</code> becomes <code>37.8324,112.5584</code>.";
this.infoURL = "https://wikipedia.org/wiki/Geohash";
this.inputType = "string";
this.outputType = "string";
this.args = [];
}
/**
* @param {string} input
* @param {Object[]} args
* @returns {string}
*/
run(input, args) {
return input.split("\n").map(line => {
const coords = geohash.decode(line);
return [coords.latitude, coords.longitude].join(",");
}).join("\n");
}
}
export default FromGeohash;

View File

@@ -21,6 +21,7 @@ class FromHTMLEntity extends Operation {
this.name = "From HTML Entity"; this.name = "From HTML Entity";
this.module = "Default"; this.module = "Default";
this.description = "Converts HTML entities back to characters<br><br>e.g. <code>&amp;<span>amp;</span></code> becomes <code>&amp;</code>"; this.description = "Converts HTML entities back to characters<br><br>e.g. <code>&amp;<span>amp;</span></code> becomes <code>&amp;</code>";
this.infoURL = "https://wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references";
this.inputType = "string"; this.inputType = "string";
this.outputType = "string"; this.outputType = "string";
this.args = []; this.args = [];

Some files were not shown because too many files have changed in this diff Show More