mirror of
https://github.com/gchq/CyberChef
synced 2025-12-19 17:53:34 +00:00
Compare commits
134 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
51229d85cb | ||
|
|
b979b051cb | ||
|
|
17cf154bc2 | ||
|
|
c7f6954b97 | ||
|
|
9ccc1613cf | ||
|
|
9730ce1f6a | ||
|
|
55a7981547 | ||
|
|
2d99c365dd | ||
|
|
59d8be511a | ||
|
|
8349ffc001 | ||
|
|
c1368c4ecb | ||
|
|
c6935e040d | ||
|
|
f79c3ae91a | ||
|
|
bc27cd2772 | ||
|
|
2b02c44ca4 | ||
|
|
59fe8d1c4b | ||
|
|
9a5d62c4c3 | ||
|
|
9fa82150ee | ||
|
|
d7561ec208 | ||
|
|
743b834f6d | ||
|
|
0658836f87 | ||
|
|
a4e20c7059 | ||
|
|
c04f409d23 | ||
|
|
1a9833132d | ||
|
|
9c3ddca269 | ||
|
|
72889d1c20 | ||
|
|
6c5433b226 | ||
|
|
31a7f83b82 | ||
|
|
39143fa6a1 | ||
|
|
1e83e0e935 | ||
|
|
2255c5b360 | ||
|
|
c046cf5695 | ||
|
|
3086c25079 | ||
|
|
3700780d14 | ||
|
|
58b1fb8de5 | ||
|
|
ed8bd34915 | ||
|
|
5c72791279 | ||
|
|
142f91425c | ||
|
|
d6344760ec | ||
|
|
64c009f266 | ||
|
|
a73decc792 | ||
|
|
f332ca4617 | ||
|
|
937791d33d | ||
|
|
a63a130723 | ||
|
|
0f1175bf15 | ||
|
|
e4db23f857 | ||
|
|
32e7dd030e | ||
|
|
e33950961e | ||
|
|
5d65cb419f | ||
|
|
536053d5f9 | ||
|
|
04ef095b88 | ||
|
|
66277cd71f | ||
|
|
58f01d0464 | ||
|
|
9ba9c56361 | ||
|
|
11902e3220 | ||
|
|
c3f79c4b2c | ||
|
|
576905e8b8 | ||
|
|
77a3b91afe | ||
|
|
40b58aa144 | ||
|
|
d5bcdc8eed | ||
|
|
674649ca7f | ||
|
|
1a9a070c3b | ||
|
|
32bee35f85 | ||
|
|
a68ce5a5af | ||
|
|
026e9ca9c3 | ||
|
|
f1ce67d79b | ||
|
|
312be4772c | ||
|
|
be97a0062e | ||
|
|
00f0101723 | ||
|
|
f450240094 | ||
|
|
a7b8378736 | ||
|
|
98a70c2dd2 | ||
|
|
d502dd9857 | ||
|
|
1ec7033d46 | ||
|
|
28ec56a27f | ||
|
|
bf2afcd2ef | ||
|
|
8f710461da | ||
|
|
c2cf535f88 | ||
|
|
ced9ab68fa | ||
|
|
cdb197a9c3 | ||
|
|
c8eacb9942 | ||
|
|
1c8e37cb64 | ||
|
|
1b0ced9f9b | ||
|
|
7b245b084a | ||
|
|
b00f64518f | ||
|
|
c3434e894d | ||
|
|
dd66f728b3 | ||
|
|
e40142b8c5 | ||
|
|
1dd1b839b8 | ||
|
|
d90d845f27 | ||
|
|
8c9ad81039 | ||
|
|
cef7a7b27d | ||
|
|
3e715ef21a | ||
|
|
86b43b4ffa | ||
|
|
65d883496b | ||
|
|
69e59916e2 | ||
|
|
475282984b | ||
|
|
2f89130f41 | ||
|
|
e9dd7eceb8 | ||
|
|
037590f831 | ||
|
|
85496684d8 | ||
|
|
4200ed4eb9 | ||
|
|
6b16f11d3b | ||
|
|
683bd3e5db | ||
|
|
6a10e94bfd | ||
|
|
25086386c6 | ||
|
|
d99ee32cc4 | ||
|
|
f1d318f229 | ||
|
|
a7fc455e05 | ||
|
|
c02c4a72e4 | ||
|
|
f97ce18ff9 | ||
|
|
dfd9afc2c4 | ||
|
|
eb5663a1ed | ||
|
|
418a7962a5 | ||
|
|
2ffce23c67 | ||
|
|
b828b50ccc | ||
|
|
a6aa40db97 | ||
|
|
45ede4beaf | ||
|
|
98a95c8bbf | ||
|
|
74bb8d92dc | ||
|
|
6cccc2c786 | ||
|
|
99a0a05947 | ||
|
|
94700dab89 | ||
|
|
e712af33b7 | ||
|
|
578a61d331 | ||
|
|
671ae6558f | ||
|
|
e8f91316ff | ||
|
|
667dfd820e | ||
|
|
3e3c526a62 | ||
|
|
e91e993fb5 | ||
|
|
e71794d362 | ||
|
|
6fd929160d | ||
|
|
5cdd062ed9 | ||
|
|
0259ed8314 |
6
.github/workflows/codeql.yml
vendored
6
.github/workflows/codeql.yml
vendored
@@ -22,12 +22,12 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Initialize CodeQL
|
- name: Initialize CodeQL
|
||||||
uses: github/codeql-action/init@v1
|
uses: github/codeql-action/init@v2
|
||||||
with:
|
with:
|
||||||
languages: ${{ matrix.language }}
|
languages: ${{ matrix.language }}
|
||||||
|
|
||||||
- name: Perform CodeQL Analysis
|
- name: Perform CodeQL Analysis
|
||||||
uses: github/codeql-action/analyze@v1
|
uses: github/codeql-action/analyze@v2
|
||||||
|
|||||||
8
.github/workflows/master.yml
vendored
8
.github/workflows/master.yml
vendored
@@ -10,12 +10,12 @@ jobs:
|
|||||||
main:
|
main:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Set node version
|
- name: Set node version
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: '17.x'
|
node-version: '18.x'
|
||||||
|
|
||||||
- name: Install
|
- name: Install
|
||||||
run: |
|
run: |
|
||||||
@@ -47,7 +47,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Deploy to GitHub Pages
|
- name: Deploy to GitHub Pages
|
||||||
if: success() && github.ref == 'refs/heads/master'
|
if: success() && github.ref == 'refs/heads/master'
|
||||||
uses: crazy-max/ghaction-github-pages@v2
|
uses: crazy-max/ghaction-github-pages@v3
|
||||||
with:
|
with:
|
||||||
target_branch: gh-pages
|
target_branch: gh-pages
|
||||||
build_dir: ./build/prod
|
build_dir: ./build/prod
|
||||||
|
|||||||
6
.github/workflows/pull_requests.yml
vendored
6
.github/workflows/pull_requests.yml
vendored
@@ -9,12 +9,12 @@ jobs:
|
|||||||
main:
|
main:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Set node version
|
- name: Set node version
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: '17.x'
|
node-version: '18.x'
|
||||||
|
|
||||||
- name: Install
|
- name: Install
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
6
.github/workflows/releases.yml
vendored
6
.github/workflows/releases.yml
vendored
@@ -10,12 +10,12 @@ jobs:
|
|||||||
main:
|
main:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Set node version
|
- name: Set node version
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: '17.x'
|
node-version: '18.x'
|
||||||
|
|
||||||
- name: Install
|
- name: Install
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
61
CHANGELOG.md
61
CHANGELOG.md
@@ -13,6 +13,39 @@ All major and minor version changes will be documented in this file. Details of
|
|||||||
|
|
||||||
## Details
|
## Details
|
||||||
|
|
||||||
|
### [9.50.0] - 2022-11-25
|
||||||
|
- Added 'Shuffle' operation [@mikecat] | [#1472]
|
||||||
|
|
||||||
|
### [9.49.0] - 2022-11-11
|
||||||
|
- Added 'LZ4 Compress' and 'LZ4 Decompress' operations [@n1474335] | [31a7f83]
|
||||||
|
|
||||||
|
### [9.48.0] - 2022-10-14
|
||||||
|
- Added 'LM Hash' and 'NT Hash' operations [@n1474335] [@brun0ne] | [#1427]
|
||||||
|
|
||||||
|
### [9.47.0] - 2022-10-14
|
||||||
|
- Added 'LZMA Decompress' and 'LZMA Compress' operations [@mattnotmitt] | [#1421]
|
||||||
|
|
||||||
|
### [9.46.0] - 2022-07-08
|
||||||
|
- Added 'Cetacean Cipher Encode' and 'Cetacean Cipher Decode' operations [@valdelaseras] | [#1308]
|
||||||
|
|
||||||
|
### [9.45.0] - 2022-07-08
|
||||||
|
- Added 'ROT8000' operation [@thomasleplus] | [#1250]
|
||||||
|
|
||||||
|
### [9.44.0] - 2022-07-08
|
||||||
|
- Added 'LZString Compress' and 'LZString Decompress' operations [@crespyl] | [#1266]
|
||||||
|
|
||||||
|
### [9.43.0] - 2022-07-08
|
||||||
|
- Added 'ROT13 Brute Force' and 'ROT47 Brute Force' operations [@mikecat] | [#1264]
|
||||||
|
|
||||||
|
### [9.42.0] - 2022-07-08
|
||||||
|
- Added 'LS47 Encrypt' and 'LS47 Decrypt' operations [@n1073645] | [#951]
|
||||||
|
|
||||||
|
### [9.41.0] - 2022-07-08
|
||||||
|
- Added 'Caesar Box Cipher' operation [@n1073645] | [#1066]
|
||||||
|
|
||||||
|
### [9.40.0] - 2022-07-08
|
||||||
|
- Added 'P-list Viewer' operation [@n1073645] | [#906]
|
||||||
|
|
||||||
### [9.39.0] - 2022-06-09
|
### [9.39.0] - 2022-06-09
|
||||||
- Added 'ELF Info' operation [@n1073645] | [#1364]
|
- Added 'ELF Info' operation [@n1073645] | [#1364]
|
||||||
|
|
||||||
@@ -294,6 +327,17 @@ All major and minor version changes will be documented in this file. Details of
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[9.50.0]: https://github.com/gchq/CyberChef/releases/tag/v9.50.0
|
||||||
|
[9.49.0]: https://github.com/gchq/CyberChef/releases/tag/v9.49.0
|
||||||
|
[9.48.0]: https://github.com/gchq/CyberChef/releases/tag/v9.48.0
|
||||||
|
[9.47.0]: https://github.com/gchq/CyberChef/releases/tag/v9.47.0
|
||||||
|
[9.46.0]: https://github.com/gchq/CyberChef/releases/tag/v9.46.0
|
||||||
|
[9.45.0]: https://github.com/gchq/CyberChef/releases/tag/v9.45.0
|
||||||
|
[9.44.0]: https://github.com/gchq/CyberChef/releases/tag/v9.44.0
|
||||||
|
[9.43.0]: https://github.com/gchq/CyberChef/releases/tag/v9.43.0
|
||||||
|
[9.42.0]: https://github.com/gchq/CyberChef/releases/tag/v9.42.0
|
||||||
|
[9.41.0]: https://github.com/gchq/CyberChef/releases/tag/v9.41.0
|
||||||
|
[9.40.0]: https://github.com/gchq/CyberChef/releases/tag/v9.40.0
|
||||||
[9.39.0]: https://github.com/gchq/CyberChef/releases/tag/v9.39.0
|
[9.39.0]: https://github.com/gchq/CyberChef/releases/tag/v9.39.0
|
||||||
[9.38.0]: https://github.com/gchq/CyberChef/releases/tag/v9.38.0
|
[9.38.0]: https://github.com/gchq/CyberChef/releases/tag/v9.38.0
|
||||||
[9.37.0]: https://github.com/gchq/CyberChef/releases/tag/v9.37.0
|
[9.37.0]: https://github.com/gchq/CyberChef/releases/tag/v9.37.0
|
||||||
@@ -418,6 +462,11 @@ All major and minor version changes will be documented in this file. Details of
|
|||||||
[@t-8ch]: https://github.com/t-8ch
|
[@t-8ch]: https://github.com/t-8ch
|
||||||
[@hettysymes]: https://github.com/hettysymes
|
[@hettysymes]: https://github.com/hettysymes
|
||||||
[@swesven]: https://github.com/swesven
|
[@swesven]: https://github.com/swesven
|
||||||
|
[@mikecat]: https://github.com/mikecat
|
||||||
|
[@crespyl]: https://github.com/crespyl
|
||||||
|
[@thomasleplus]: https://github.com/thomasleplus
|
||||||
|
[@valdelaseras]: https://github.com/valdelaseras
|
||||||
|
[@brun0ne]: https://github.com/brun0ne
|
||||||
|
|
||||||
[8ad18b]: https://github.com/gchq/CyberChef/commit/8ad18bc7db6d9ff184ba3518686293a7685bf7b7
|
[8ad18b]: https://github.com/gchq/CyberChef/commit/8ad18bc7db6d9ff184ba3518686293a7685bf7b7
|
||||||
[9a33498]: https://github.com/gchq/CyberChef/commit/9a33498fed26a8df9c9f35f39a78a174bf50a513
|
[9a33498]: https://github.com/gchq/CyberChef/commit/9a33498fed26a8df9c9f35f39a78a174bf50a513
|
||||||
@@ -425,6 +474,7 @@ All major and minor version changes will be documented in this file. Details of
|
|||||||
[e9ca4dc]: https://github.com/gchq/CyberChef/commit/e9ca4dc9caf98f33fd986431cd400c88082a42b8
|
[e9ca4dc]: https://github.com/gchq/CyberChef/commit/e9ca4dc9caf98f33fd986431cd400c88082a42b8
|
||||||
[dd18e52]: https://github.com/gchq/CyberChef/commit/dd18e529939078b89867297b181a584e8b2cc7da
|
[dd18e52]: https://github.com/gchq/CyberChef/commit/dd18e529939078b89867297b181a584e8b2cc7da
|
||||||
[a895d1d]: https://github.com/gchq/CyberChef/commit/a895d1d82a2f92d440a0c5eca2bc7c898107b737
|
[a895d1d]: https://github.com/gchq/CyberChef/commit/a895d1d82a2f92d440a0c5eca2bc7c898107b737
|
||||||
|
[31a7f83]: https://github.com/gchq/CyberChef/commit/31a7f83b82e78927f89689f323fcb9185144d6ff
|
||||||
|
|
||||||
[#95]: https://github.com/gchq/CyberChef/pull/299
|
[#95]: https://github.com/gchq/CyberChef/pull/299
|
||||||
[#173]: https://github.com/gchq/CyberChef/pull/173
|
[#173]: https://github.com/gchq/CyberChef/pull/173
|
||||||
@@ -491,10 +541,12 @@ All major and minor version changes will be documented in this file. Details of
|
|||||||
[#674]: https://github.com/gchq/CyberChef/pull/674
|
[#674]: https://github.com/gchq/CyberChef/pull/674
|
||||||
[#683]: https://github.com/gchq/CyberChef/pull/683
|
[#683]: https://github.com/gchq/CyberChef/pull/683
|
||||||
[#865]: https://github.com/gchq/CyberChef/pull/865
|
[#865]: https://github.com/gchq/CyberChef/pull/865
|
||||||
|
[#906]: https://github.com/gchq/CyberChef/pull/906
|
||||||
[#912]: https://github.com/gchq/CyberChef/pull/912
|
[#912]: https://github.com/gchq/CyberChef/pull/912
|
||||||
[#917]: https://github.com/gchq/CyberChef/pull/917
|
[#917]: https://github.com/gchq/CyberChef/pull/917
|
||||||
[#934]: https://github.com/gchq/CyberChef/pull/934
|
[#934]: https://github.com/gchq/CyberChef/pull/934
|
||||||
[#948]: https://github.com/gchq/CyberChef/pull/948
|
[#948]: https://github.com/gchq/CyberChef/pull/948
|
||||||
|
[#951]: https://github.com/gchq/CyberChef/pull/951
|
||||||
[#952]: https://github.com/gchq/CyberChef/pull/952
|
[#952]: https://github.com/gchq/CyberChef/pull/952
|
||||||
[#965]: https://github.com/gchq/CyberChef/pull/965
|
[#965]: https://github.com/gchq/CyberChef/pull/965
|
||||||
[#966]: https://github.com/gchq/CyberChef/pull/966
|
[#966]: https://github.com/gchq/CyberChef/pull/966
|
||||||
@@ -506,6 +558,7 @@ All major and minor version changes will be documented in this file. Details of
|
|||||||
[#1045]: https://github.com/gchq/CyberChef/pull/1045
|
[#1045]: https://github.com/gchq/CyberChef/pull/1045
|
||||||
[#1049]: https://github.com/gchq/CyberChef/pull/1049
|
[#1049]: https://github.com/gchq/CyberChef/pull/1049
|
||||||
[#1065]: https://github.com/gchq/CyberChef/pull/1065
|
[#1065]: https://github.com/gchq/CyberChef/pull/1065
|
||||||
|
[#1066]: https://github.com/gchq/CyberChef/pull/1066
|
||||||
[#1083]: https://github.com/gchq/CyberChef/pull/1083
|
[#1083]: https://github.com/gchq/CyberChef/pull/1083
|
||||||
[#1189]: https://github.com/gchq/CyberChef/pull/1189
|
[#1189]: https://github.com/gchq/CyberChef/pull/1189
|
||||||
[#1242]: https://github.com/gchq/CyberChef/pull/1242
|
[#1242]: https://github.com/gchq/CyberChef/pull/1242
|
||||||
@@ -513,3 +566,11 @@ All major and minor version changes will be documented in this file. Details of
|
|||||||
[#1313]: https://github.com/gchq/CyberChef/pull/1313
|
[#1313]: https://github.com/gchq/CyberChef/pull/1313
|
||||||
[#1326]: https://github.com/gchq/CyberChef/pull/1326
|
[#1326]: https://github.com/gchq/CyberChef/pull/1326
|
||||||
[#1364]: https://github.com/gchq/CyberChef/pull/1364
|
[#1364]: https://github.com/gchq/CyberChef/pull/1364
|
||||||
|
[#1264]: https://github.com/gchq/CyberChef/pull/1264
|
||||||
|
[#1266]: https://github.com/gchq/CyberChef/pull/1266
|
||||||
|
[#1250]: https://github.com/gchq/CyberChef/pull/1250
|
||||||
|
[#1308]: https://github.com/gchq/CyberChef/pull/1308
|
||||||
|
[#1421]: https://github.com/gchq/CyberChef/pull/1421
|
||||||
|
[#1427]: https://github.com/gchq/CyberChef/pull/1427
|
||||||
|
[#1472]: https://github.com/gchq/CyberChef/pull/1472
|
||||||
|
|
||||||
|
|||||||
10
README.md
10
README.md
@@ -54,7 +54,7 @@ You can use as many operations as you like in simple or complex ways. Some examp
|
|||||||
- Whenever you modify the input or the recipe, CyberChef will automatically "bake" for you and produce the output immediately.
|
- Whenever you modify the input or the recipe, CyberChef will automatically "bake" for you and produce the output immediately.
|
||||||
- This can be turned off and operated manually if it is affecting performance (if the input is very large, for instance).
|
- This can be turned off and operated manually if it is affecting performance (if the input is very large, for instance).
|
||||||
- Automated encoding detection
|
- Automated encoding detection
|
||||||
- CyberChef uses [a number of techniques](https://github.com/gchq/CyberChef/wiki/Automatic-detection-of-encoded-data-using-CyberChef-Magic) to attempt to automatically detect which encodings your data is under. If it finds a suitable operation which can make sense of your data, it displays the 'magic' icon in the Output field which you can click to decode your data.
|
- CyberChef uses [a number of techniques](https://github.com/gchq/CyberChef/wiki/Automatic-detection-of-encoded-data-using-CyberChef-Magic) to attempt to automatically detect which encodings your data is under. If it finds a suitable operation that make sense of your data, it displays the 'magic' icon in the Output field which you can click to decode your data.
|
||||||
- Breakpoints
|
- Breakpoints
|
||||||
- You can set breakpoints on any operation in your recipe to pause execution before running it.
|
- You can set breakpoints on any operation in your recipe to pause execution before running it.
|
||||||
- You can also step through the recipe one operation at a time to see what the data looks like at each stage.
|
- You can also step through the recipe one operation at a time to see what the data looks like at each stage.
|
||||||
@@ -66,7 +66,7 @@ You can use as many operations as you like in simple or complex ways. Some examp
|
|||||||
- Highlighting
|
- Highlighting
|
||||||
- When you highlight text in the input or output, the offset and length values will be displayed and, if possible, the corresponding data will be highlighted in the output or input respectively (example: [highlight the word 'question' in the input to see where it appears in the output][11]).
|
- When you highlight text in the input or output, the offset and length values will be displayed and, if possible, the corresponding data will be highlighted in the output or input respectively (example: [highlight the word 'question' in the input to see where it appears in the output][11]).
|
||||||
- Save to file and load from file
|
- Save to file and load from file
|
||||||
- You can save the output to a file at any time or load a file by dragging and dropping it into the input field. Files up to around 2GB are supported (depending on your browser), however some operations may take a very long time to run over this much data.
|
- You can save the output to a file at any time or load a file by dragging and dropping it into the input field. Files up to around 2GB are supported (depending on your browser), however, some operations may take a very long time to run over this much data.
|
||||||
- CyberChef is entirely client-side
|
- CyberChef is entirely client-side
|
||||||
- It should be noted that none of your recipe configuration or input (either text or files) is ever sent to the CyberChef web server - all processing is carried out within your browser, on your own computer.
|
- It should be noted that none of your recipe configuration or input (either text or files) is ever sent to the CyberChef web server - all processing is carried out within your browser, on your own computer.
|
||||||
- Due to this feature, CyberChef can be downloaded and run locally. You can use the link in the top left corner of the app to download a full copy of CyberChef and drop it into a virtual machine, share it with other people, or host it in a closed network.
|
- Due to this feature, CyberChef can be downloaded and run locally. You can use the link in the top left corner of the app to download a full copy of CyberChef and drop it into a virtual machine, share it with other people, or host it in a closed network.
|
||||||
@@ -74,7 +74,7 @@ You can use as many operations as you like in simple or complex ways. Some examp
|
|||||||
|
|
||||||
## Deep linking
|
## Deep linking
|
||||||
|
|
||||||
By manipulation of CyberChef's URL hash, you can change the initial settings with which the page opens.
|
By manipulating CyberChef's URL hash, you can change the initial settings with which the page opens.
|
||||||
The format is `https://gchq.github.io/CyberChef/#recipe=Operation()&input=...`
|
The format is `https://gchq.github.io/CyberChef/#recipe=Operation()&input=...`
|
||||||
|
|
||||||
Supported arguments are `recipe`, `input` (encoded in Base64), and `theme`.
|
Supported arguments are `recipe`, `input` (encoded in Base64), and `theme`.
|
||||||
@@ -90,12 +90,12 @@ CyberChef is built to support
|
|||||||
|
|
||||||
## Node.js support
|
## Node.js support
|
||||||
|
|
||||||
CyberChef is built to fully support Node.js `v10` and partially supports `v12`. Named imports using a deep import specifier does not work in `v12`. For more information, see the Node API page in the project [wiki pages](https://github.com/gchq/CyberChef/wiki)
|
CyberChef is built to fully support Node.js `v16`. For more information, see the Node API page in the project [wiki pages](https://github.com/gchq/CyberChef/wiki)
|
||||||
|
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
Contributing a new operation to CyberChef is super easy! There is a quickstart script which will walk you through the process. If you can write basic JavaScript, you can write a CyberChef operation.
|
Contributing a new operation to CyberChef is super easy! The quickstart script will walk you through the process. If you can write basic JavaScript, you can write a CyberChef operation.
|
||||||
|
|
||||||
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).
|
||||||
|
|
||||||
|
|||||||
3605
package-lock.json
generated
3605
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
19
package.json
19
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "cyberchef",
|
"name": "cyberchef",
|
||||||
"version": "9.40.0",
|
"version": "9.50.6",
|
||||||
"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",
|
||||||
@@ -49,7 +49,7 @@
|
|||||||
"babel-loader": "^8.2.5",
|
"babel-loader": "^8.2.5",
|
||||||
"babel-plugin-dynamic-import-node": "^2.3.3",
|
"babel-plugin-dynamic-import-node": "^2.3.3",
|
||||||
"babel-plugin-transform-builtin-extend": "1.1.2",
|
"babel-plugin-transform-builtin-extend": "1.1.2",
|
||||||
"chromedriver": "^101.0.0",
|
"chromedriver": "^103.0.0",
|
||||||
"cli-progress": "^3.11.1",
|
"cli-progress": "^3.11.1",
|
||||||
"colors": "^1.4.0",
|
"colors": "^1.4.0",
|
||||||
"copy-webpack-plugin": "^11.0.0",
|
"copy-webpack-plugin": "^11.0.0",
|
||||||
@@ -77,7 +77,6 @@
|
|||||||
"postcss-import": "^14.1.0",
|
"postcss-import": "^14.1.0",
|
||||||
"postcss-loader": "^7.0.0",
|
"postcss-loader": "^7.0.0",
|
||||||
"prompt": "^1.3.0",
|
"prompt": "^1.3.0",
|
||||||
"sass-loader": "^13.0.0",
|
|
||||||
"sitemap": "^7.1.1",
|
"sitemap": "^7.1.1",
|
||||||
"terser": "^5.14.0",
|
"terser": "^5.14.0",
|
||||||
"webpack": "^5.73.0",
|
"webpack": "^5.73.0",
|
||||||
@@ -88,6 +87,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/polyfill": "^7.12.1",
|
"@babel/polyfill": "^7.12.1",
|
||||||
|
"@blu3r4y/lzma": "^2.3.3",
|
||||||
"arrive": "^2.4.1",
|
"arrive": "^2.4.1",
|
||||||
"avsc": "^5.7.4",
|
"avsc": "^5.7.4",
|
||||||
"bcryptjs": "^2.4.3",
|
"bcryptjs": "^2.4.3",
|
||||||
@@ -123,25 +123,27 @@
|
|||||||
"js-sha3": "^0.8.0",
|
"js-sha3": "^0.8.0",
|
||||||
"jsesc": "^3.0.2",
|
"jsesc": "^3.0.2",
|
||||||
"json5": "^2.2.1",
|
"json5": "^2.2.1",
|
||||||
"jsonpath": "^1.1.1",
|
"jsonpath-plus": "^7.2.0",
|
||||||
"jsonwebtoken": "^8.5.1",
|
"jsonwebtoken": "^8.5.1",
|
||||||
"jsqr": "^1.4.0",
|
"jsqr": "^1.4.0",
|
||||||
"jsrsasign": "^10.5.23",
|
"jsrsasign": "^10.5.23",
|
||||||
"kbpgp": "2.1.15",
|
"kbpgp": "2.1.15",
|
||||||
"libbzip2-wasm": "0.0.4",
|
"libbzip2-wasm": "0.0.4",
|
||||||
"libyara-wasm": "^1.1.0",
|
"libyara-wasm": "^1.2.1",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"loglevel": "^1.8.0",
|
"loglevel": "^1.8.0",
|
||||||
"loglevel-message-prefix": "^3.0.0",
|
"loglevel-message-prefix": "^3.0.0",
|
||||||
|
"lz-string": "^1.4.4",
|
||||||
|
"lz4js": "^0.2.0",
|
||||||
"markdown-it": "^13.0.1",
|
"markdown-it": "^13.0.1",
|
||||||
"moment": "^2.29.3",
|
"moment": "^2.29.3",
|
||||||
"moment-timezone": "^0.5.34",
|
"moment-timezone": "^0.5.34",
|
||||||
"ngeohash": "^0.6.3",
|
"ngeohash": "^0.6.3",
|
||||||
"node-forge": "^1.3.1",
|
"node-forge": "^1.3.1",
|
||||||
"node-md6": "^0.1.0",
|
"node-md6": "^0.1.0",
|
||||||
"node-sass": "^7.0.1",
|
|
||||||
"nodom": "^2.4.0",
|
"nodom": "^2.4.0",
|
||||||
"notepack.io": "^3.0.1",
|
"notepack.io": "^3.0.1",
|
||||||
|
"ntlm": "^0.1.3",
|
||||||
"nwmatcher": "^1.4.4",
|
"nwmatcher": "^1.4.4",
|
||||||
"otp": "0.1.3",
|
"otp": "0.1.3",
|
||||||
"path": "^0.12.7",
|
"path": "^0.12.7",
|
||||||
@@ -155,7 +157,7 @@
|
|||||||
"split.js": "^1.6.5",
|
"split.js": "^1.6.5",
|
||||||
"ssdeep.js": "0.0.3",
|
"ssdeep.js": "0.0.3",
|
||||||
"stream-browserify": "^3.0.0",
|
"stream-browserify": "^3.0.0",
|
||||||
"tesseract.js": "2.1.5",
|
"tesseract.js": "3.0.2",
|
||||||
"ua-parser-js": "^1.0.2",
|
"ua-parser-js": "^1.0.2",
|
||||||
"unorm": "^1.6.0",
|
"unorm": "^1.6.0",
|
||||||
"utf8": "^3.0.0",
|
"utf8": "^3.0.0",
|
||||||
@@ -168,8 +170,9 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "npx grunt dev",
|
"start": "npx grunt dev",
|
||||||
"build": "npx grunt prod",
|
"build": "npx grunt prod",
|
||||||
|
"node": "npx grunt node",
|
||||||
"repl": "node --experimental-modules --experimental-json-modules --experimental-specifier-resolution=node --no-warnings src/node/repl.mjs",
|
"repl": "node --experimental-modules --experimental-json-modules --experimental-specifier-resolution=node --no-warnings src/node/repl.mjs",
|
||||||
"test": "npx grunt configTests && node --experimental-modules --experimental-json-modules --no-warnings --no-deprecation tests/node/index.mjs && node --experimental-modules --experimental-json-modules --no-warnings --no-deprecation tests/operations/index.mjs",
|
"test": "npx grunt configTests && node --experimental-modules --experimental-json-modules --no-warnings --no-deprecation --openssl-legacy-provider tests/node/index.mjs && node --experimental-modules --experimental-json-modules --no-warnings --no-deprecation --openssl-legacy-provider tests/operations/index.mjs",
|
||||||
"testnodeconsumer": "npx grunt testnodeconsumer",
|
"testnodeconsumer": "npx grunt testnodeconsumer",
|
||||||
"testui": "npx grunt testui",
|
"testui": "npx grunt testui",
|
||||||
"testuidev": "npx nightwatch --env=dev",
|
"testuidev": "npx nightwatch --env=dev",
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ class Utils {
|
|||||||
* Utils.parseEscapedChars("\\n");
|
* Utils.parseEscapedChars("\\n");
|
||||||
*/
|
*/
|
||||||
static parseEscapedChars(str) {
|
static parseEscapedChars(str) {
|
||||||
return str.replace(/\\([bfnrtv'"]|[0-3][0-7]{2}|[0-7]{1,2}|x[\da-fA-F]{2}|u[\da-fA-F]{4}|u\{[\da-fA-F]{1,6}\}|\\)/g, function(m, a) {
|
return str.replace(/\\([abfnrtv'"]|[0-3][0-7]{2}|[0-7]{1,2}|x[\da-fA-F]{2}|u[\da-fA-F]{4}|u\{[\da-fA-F]{1,6}\}|\\)/g, function(m, a) {
|
||||||
switch (a[0]) {
|
switch (a[0]) {
|
||||||
case "\\":
|
case "\\":
|
||||||
return "\\";
|
return "\\";
|
||||||
@@ -219,6 +219,8 @@ class Utils {
|
|||||||
case "6":
|
case "6":
|
||||||
case "7":
|
case "7":
|
||||||
return String.fromCharCode(parseInt(a, 8));
|
return String.fromCharCode(parseInt(a, 8));
|
||||||
|
case "a":
|
||||||
|
return String.fromCharCode(7);
|
||||||
case "b":
|
case "b":
|
||||||
return "\b";
|
return "\b";
|
||||||
case "t":
|
case "t":
|
||||||
|
|||||||
@@ -79,6 +79,8 @@
|
|||||||
"DES Decrypt",
|
"DES Decrypt",
|
||||||
"Triple DES Encrypt",
|
"Triple DES Encrypt",
|
||||||
"Triple DES Decrypt",
|
"Triple DES Decrypt",
|
||||||
|
"LS47 Encrypt",
|
||||||
|
"LS47 Decrypt",
|
||||||
"RC2 Encrypt",
|
"RC2 Encrypt",
|
||||||
"RC2 Decrypt",
|
"RC2 Decrypt",
|
||||||
"RC4",
|
"RC4",
|
||||||
@@ -86,7 +88,10 @@
|
|||||||
"SM4 Encrypt",
|
"SM4 Encrypt",
|
||||||
"SM4 Decrypt",
|
"SM4 Decrypt",
|
||||||
"ROT13",
|
"ROT13",
|
||||||
|
"ROT13 Brute Force",
|
||||||
"ROT47",
|
"ROT47",
|
||||||
|
"ROT47 Brute Force",
|
||||||
|
"ROT8000",
|
||||||
"XOR",
|
"XOR",
|
||||||
"XOR Brute Force",
|
"XOR Brute Force",
|
||||||
"Vigenère Encode",
|
"Vigenère Encode",
|
||||||
@@ -97,6 +102,7 @@
|
|||||||
"Bacon Cipher Decode",
|
"Bacon Cipher Decode",
|
||||||
"Bifid Cipher Encode",
|
"Bifid Cipher Encode",
|
||||||
"Bifid Cipher Decode",
|
"Bifid Cipher Decode",
|
||||||
|
"Caesar Box Cipher",
|
||||||
"Affine Cipher Encode",
|
"Affine Cipher Encode",
|
||||||
"Affine Cipher Decode",
|
"Affine Cipher Decode",
|
||||||
"A1Z26 Cipher Encode",
|
"A1Z26 Cipher Encode",
|
||||||
@@ -106,6 +112,8 @@
|
|||||||
"Atbash Cipher",
|
"Atbash Cipher",
|
||||||
"CipherSaber2 Encrypt",
|
"CipherSaber2 Encrypt",
|
||||||
"CipherSaber2 Decrypt",
|
"CipherSaber2 Decrypt",
|
||||||
|
"Cetacean Cipher Encode",
|
||||||
|
"Cetacean Cipher Decode",
|
||||||
"Substitute",
|
"Substitute",
|
||||||
"Derive PBKDF2 key",
|
"Derive PBKDF2 key",
|
||||||
"Derive EVP key",
|
"Derive EVP key",
|
||||||
@@ -176,7 +184,8 @@
|
|||||||
"Bit shift right",
|
"Bit shift right",
|
||||||
"Rotate left",
|
"Rotate left",
|
||||||
"Rotate right",
|
"Rotate right",
|
||||||
"ROT13"
|
"ROT13",
|
||||||
|
"ROT8000"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -240,6 +249,7 @@
|
|||||||
"To Table",
|
"To Table",
|
||||||
"Reverse",
|
"Reverse",
|
||||||
"Sort",
|
"Sort",
|
||||||
|
"Shuffle",
|
||||||
"Unique",
|
"Unique",
|
||||||
"Split",
|
"Split",
|
||||||
"Filter",
|
"Filter",
|
||||||
@@ -320,7 +330,13 @@
|
|||||||
"Bzip2 Decompress",
|
"Bzip2 Decompress",
|
||||||
"Bzip2 Compress",
|
"Bzip2 Compress",
|
||||||
"Tar",
|
"Tar",
|
||||||
"Untar"
|
"Untar",
|
||||||
|
"LZString Decompress",
|
||||||
|
"LZString Compress",
|
||||||
|
"LZMA Decompress",
|
||||||
|
"LZMA Compress",
|
||||||
|
"LZ4 Decompress",
|
||||||
|
"LZ4 Compress"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -356,6 +372,8 @@
|
|||||||
"Bcrypt compare",
|
"Bcrypt compare",
|
||||||
"Bcrypt parse",
|
"Bcrypt parse",
|
||||||
"Scrypt",
|
"Scrypt",
|
||||||
|
"NT Hash",
|
||||||
|
"LM Hash",
|
||||||
"Fletcher-8 Checksum",
|
"Fletcher-8 Checksum",
|
||||||
"Fletcher-16 Checksum",
|
"Fletcher-16 Checksum",
|
||||||
"Fletcher-32 Checksum",
|
"Fletcher-32 Checksum",
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ const getFeature = function() {
|
|||||||
|
|
||||||
fs.writeFileSync(path.join(process.cwd(), "CHANGELOG.md"), changelogData);
|
fs.writeFileSync(path.join(process.cwd(), "CHANGELOG.md"), changelogData);
|
||||||
|
|
||||||
console.log("Written CHANGELOG.md");
|
console.log("Written CHANGELOG.md\nCommit changes and then run `npm version minor`.");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -105,13 +105,17 @@ export function fromHex(data, delim="Auto", byteLen=2) {
|
|||||||
throw new OperationError("Byte length must be a positive integer");
|
throw new OperationError("Byte length must be a positive integer");
|
||||||
|
|
||||||
if (delim !== "None") {
|
if (delim !== "None") {
|
||||||
const delimRegex = delim === "Auto" ? /[^a-f\d]|(0x)/gi : Utils.regexRep(delim);
|
const delimRegex = delim === "Auto" ? /[^a-f\d]|0x/gi : Utils.regexRep(delim);
|
||||||
data = data.replace(delimRegex, "");
|
data = data.split(delimRegex);
|
||||||
|
} else {
|
||||||
|
data = [data];
|
||||||
}
|
}
|
||||||
|
|
||||||
const output = [];
|
const output = [];
|
||||||
for (let i = 0; i < data.length; i += byteLen) {
|
for (let i = 0; i < data.length; i++) {
|
||||||
output.push(parseInt(data.substr(i, byteLen), 16));
|
for (let j = 0; j < data[i].length; j += byteLen) {
|
||||||
|
output.push(parseInt(data[i].substr(j, byteLen), 16));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|||||||
244
src/core/lib/LS47.mjs
Normal file
244
src/core/lib/LS47.mjs
Normal file
@@ -0,0 +1,244 @@
|
|||||||
|
/**
|
||||||
|
* @author n1073645 [n1073645@gmail.com]
|
||||||
|
* @copyright Crown Copyright 2020
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
import OperationError from "../errors/OperationError.mjs";
|
||||||
|
|
||||||
|
const letters = "_abcdefghijklmnopqrstuvwxyz.0123456789,-+*/:?!'()";
|
||||||
|
const tiles = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialises the tiles with values and positions.
|
||||||
|
*/
|
||||||
|
export function initTiles() {
|
||||||
|
for (let i = 0; i < 49; i++)
|
||||||
|
tiles.push([letters.charAt(i), [Math.floor(i/7), i % 7]]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rotates the key "down".
|
||||||
|
*
|
||||||
|
* @param {string} key
|
||||||
|
* @param {number} col
|
||||||
|
* @param {number} n
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
function rotateDown(key, col, n) {
|
||||||
|
const lines = [];
|
||||||
|
for (let i = 0; i < 7; i++)
|
||||||
|
lines.push(key.slice(i*7, (i + 1) * 7));
|
||||||
|
const lefts = [];
|
||||||
|
let mids = [];
|
||||||
|
const rights = [];
|
||||||
|
lines.forEach((element) => {
|
||||||
|
lefts.push(element.slice(0, col));
|
||||||
|
mids.push(element.charAt(col));
|
||||||
|
rights.push(element.slice(col+1));
|
||||||
|
});
|
||||||
|
n = (7 - n % 7) % 7;
|
||||||
|
mids = mids.slice(n).concat(mids.slice(0, n));
|
||||||
|
let result = "";
|
||||||
|
for (let i = 0; i < 7; i++)
|
||||||
|
result += lefts[i] + mids[i] + rights[i];
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rotates the key "right".
|
||||||
|
*
|
||||||
|
* @param {string} key
|
||||||
|
* @param {number} row
|
||||||
|
* @param {number} n
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
function rotateRight(key, row, n) {
|
||||||
|
const mid = key.slice(row * 7, (row + 1) * 7);
|
||||||
|
n = (7 - n % 7) % 7;
|
||||||
|
return key.slice(0, 7 * row) + mid.slice(n) + mid.slice(0, n) + key.slice(7 * (row + 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds the position of a letter in the tiles.
|
||||||
|
*
|
||||||
|
* @param {string} letter
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
function findIx(letter) {
|
||||||
|
for (let i = 0; i < tiles.length; i++)
|
||||||
|
if (tiles[i][0] === letter)
|
||||||
|
return tiles[i][1];
|
||||||
|
throw new OperationError("Letter " + letter + " is not included in LS47");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Derives key from the input password.
|
||||||
|
*
|
||||||
|
* @param {string} password
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
export function deriveKey(password) {
|
||||||
|
let i = 0;
|
||||||
|
let k = letters;
|
||||||
|
for (const c of password) {
|
||||||
|
const [row, col] = findIx(c);
|
||||||
|
k = rotateDown(rotateRight(k, i, col), i, row);
|
||||||
|
i = (i + 1) % 7;
|
||||||
|
}
|
||||||
|
return k;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks the key is a valid key.
|
||||||
|
*
|
||||||
|
* @param {string} key
|
||||||
|
*/
|
||||||
|
function checkKey(key) {
|
||||||
|
if (key.length !== letters.length)
|
||||||
|
throw new OperationError("Wrong key size");
|
||||||
|
const counts = new Array();
|
||||||
|
for (let i = 0; i < letters.length; i++)
|
||||||
|
counts[letters.charAt(i)] = 0;
|
||||||
|
for (const elem of letters) {
|
||||||
|
if (letters.indexOf(elem) === -1)
|
||||||
|
throw new OperationError("Letter " + elem + " not in LS47");
|
||||||
|
counts[elem]++;
|
||||||
|
if (counts[elem] > 1)
|
||||||
|
throw new OperationError("Letter duplicated in the key");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds the position of a letter in they key.
|
||||||
|
*
|
||||||
|
* @param {letter} key
|
||||||
|
* @param {string} letter
|
||||||
|
* @returns {object}
|
||||||
|
*/
|
||||||
|
function findPos (key, letter) {
|
||||||
|
const index = key.indexOf(letter);
|
||||||
|
if (index >= 0 && index < 49)
|
||||||
|
return [Math.floor(index/7), index%7];
|
||||||
|
throw new OperationError("Letter " + letter + " is not in the key");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the character at the position on the tiles.
|
||||||
|
*
|
||||||
|
* @param {string} key
|
||||||
|
* @param {object} coord
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
function findAtPos(key, coord) {
|
||||||
|
return key.charAt(coord[1] + (coord[0] * 7));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns new position by adding two positions.
|
||||||
|
*
|
||||||
|
* @param {object} a
|
||||||
|
* @param {object} b
|
||||||
|
* @returns {object}
|
||||||
|
*/
|
||||||
|
function addPos(a, b) {
|
||||||
|
return [(a[0] + b[0]) % 7, (a[1] + b[1]) % 7];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns new position by subtracting two positions.
|
||||||
|
* Note: We have to manually do the remainder division, since JS does not
|
||||||
|
* operate correctly on negative numbers (e.g. -3 % 4 = -3 when it should be 1).
|
||||||
|
*
|
||||||
|
* @param {object} a
|
||||||
|
* @param {object} b
|
||||||
|
* @returns {object}
|
||||||
|
*/
|
||||||
|
function subPos(a, b) {
|
||||||
|
const asub = a[0] - b[0];
|
||||||
|
const bsub = a[1] - b[1];
|
||||||
|
return [asub - (Math.floor(asub/7) * 7), bsub - (Math.floor(bsub/7) * 7)];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encrypts the plaintext string.
|
||||||
|
*
|
||||||
|
* @param {string} key
|
||||||
|
* @param {string} plaintext
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
function encrypt(key, plaintext) {
|
||||||
|
checkKey(key);
|
||||||
|
let mp = [0, 0];
|
||||||
|
let ciphertext = "";
|
||||||
|
for (const p of plaintext) {
|
||||||
|
const pp = findPos(key, p);
|
||||||
|
const mix = findIx(findAtPos(key, mp));
|
||||||
|
let cp = addPos(pp, mix);
|
||||||
|
const c = findAtPos(key, cp);
|
||||||
|
ciphertext += c;
|
||||||
|
key = rotateRight(key, pp[0], 1);
|
||||||
|
cp = findPos(key, c);
|
||||||
|
key = rotateDown(key, cp[1], 1);
|
||||||
|
mp = addPos(mp, findIx(c));
|
||||||
|
}
|
||||||
|
return ciphertext;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decrypts the ciphertext string.
|
||||||
|
*
|
||||||
|
* @param {string} key
|
||||||
|
* @param {string} ciphertext
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
function decrypt(key, ciphertext) {
|
||||||
|
checkKey(key);
|
||||||
|
let mp = [0, 0];
|
||||||
|
let plaintext = "";
|
||||||
|
for (const c of ciphertext) {
|
||||||
|
let cp = findPos(key, c);
|
||||||
|
const mix = findIx(findAtPos(key, mp));
|
||||||
|
const pp = subPos(cp, mix);
|
||||||
|
const p = findAtPos(key, pp);
|
||||||
|
plaintext += p;
|
||||||
|
key = rotateRight(key, pp[0], 1);
|
||||||
|
cp = findPos(key, c);
|
||||||
|
key = rotateDown(key, cp[1], 1);
|
||||||
|
mp = addPos(mp, findIx(c));
|
||||||
|
}
|
||||||
|
return plaintext;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds padding to the input.
|
||||||
|
*
|
||||||
|
* @param {string} key
|
||||||
|
* @param {string} plaintext
|
||||||
|
* @param {string} signature
|
||||||
|
* @param {number} paddingSize
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
export function encryptPad(key, plaintext, signature, paddingSize) {
|
||||||
|
initTiles();
|
||||||
|
checkKey(key);
|
||||||
|
let padding = "";
|
||||||
|
for (let i = 0; i < paddingSize; i++) {
|
||||||
|
padding += letters.charAt(Math.floor(Math.random() * letters.length));
|
||||||
|
}
|
||||||
|
return encrypt(key, padding+plaintext+"---"+signature);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes padding from the ouput.
|
||||||
|
*
|
||||||
|
* @param {string} key
|
||||||
|
* @param {string} ciphertext
|
||||||
|
* @param {number} paddingSize
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
export function decryptPad(key, ciphertext, paddingSize) {
|
||||||
|
initTiles();
|
||||||
|
checkKey(key);
|
||||||
|
return decrypt(key, ciphertext).slice(paddingSize);
|
||||||
|
}
|
||||||
21
src/core/lib/LZString.mjs
Normal file
21
src/core/lib/LZString.mjs
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
/**
|
||||||
|
* lz-string exports.
|
||||||
|
*
|
||||||
|
* @author crespyl [peter@crespyl.net]
|
||||||
|
* @copyright Peter Jacobs 2021
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
import LZString from "lz-string";
|
||||||
|
|
||||||
|
export const COMPRESSION_OUTPUT_FORMATS = ["default", "UTF16", "Base64"];
|
||||||
|
export const COMPRESSION_FUNCTIONS = {
|
||||||
|
"default": LZString.compress,
|
||||||
|
"UTF16": LZString.compressToUTF16,
|
||||||
|
"Base64": LZString.compressToBase64,
|
||||||
|
};
|
||||||
|
export const DECOMPRESSION_FUNCTIONS = {
|
||||||
|
"default": LZString.decompress,
|
||||||
|
"UTF16": LZString.decompressFromUTF16,
|
||||||
|
"Base64": LZString.decompressFromBase64,
|
||||||
|
};
|
||||||
@@ -184,7 +184,7 @@ class Protobuf {
|
|||||||
bytes: String,
|
bytes: String,
|
||||||
longs: Number,
|
longs: Number,
|
||||||
enums: String,
|
enums: String,
|
||||||
defualts: true
|
defaults: true
|
||||||
});
|
});
|
||||||
const output = {};
|
const output = {};
|
||||||
|
|
||||||
|
|||||||
61
src/core/operations/CaesarBoxCipher.mjs
Normal file
61
src/core/operations/CaesarBoxCipher.mjs
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
/**
|
||||||
|
* @author n1073645 [n1073645@gmail.com]
|
||||||
|
* @copyright Crown Copyright 2020
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Operation from "../Operation.mjs";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Caesar Box Cipher operation
|
||||||
|
*/
|
||||||
|
class CaesarBoxCipher extends Operation {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CaesarBoxCipher constructor
|
||||||
|
*/
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.name = "Caesar Box Cipher";
|
||||||
|
this.module = "Ciphers";
|
||||||
|
this.description = "Caesar Box is a transposition cipher used in the Roman Empire, in which letters of the message are written in rows in a square (or a rectangle) and then, read by column.";
|
||||||
|
this.infoURL = "https://www.dcode.fr/caesar-box-cipher";
|
||||||
|
this.inputType = "string";
|
||||||
|
this.outputType = "string";
|
||||||
|
this.args = [
|
||||||
|
{
|
||||||
|
name: "Box Height",
|
||||||
|
type: "number",
|
||||||
|
value: 1
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} input
|
||||||
|
* @param {Object[]} args
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
run(input, args) {
|
||||||
|
const tableHeight = args[0];
|
||||||
|
const tableWidth = Math.ceil(input.length / tableHeight);
|
||||||
|
while (input.indexOf(" ") !== -1)
|
||||||
|
input = input.replace(" ", "");
|
||||||
|
for (let i = 0; i < (tableHeight * tableWidth) - input.length; i++) {
|
||||||
|
input += "\x00";
|
||||||
|
}
|
||||||
|
let result = "";
|
||||||
|
for (let i = 0; i < tableHeight; i++) {
|
||||||
|
for (let j = i; j < input.length; j += tableHeight) {
|
||||||
|
if (input.charAt(j) !== "\x00") {
|
||||||
|
result += input.charAt(j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export default CaesarBoxCipher;
|
||||||
63
src/core/operations/CetaceanCipherDecode.mjs
Normal file
63
src/core/operations/CetaceanCipherDecode.mjs
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
/**
|
||||||
|
* @author dolphinOnKeys [robin@weird.io]
|
||||||
|
* @copyright Crown Copyright 2022
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Operation from "../Operation.mjs";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cetacean Cipher Decode operation
|
||||||
|
*/
|
||||||
|
class CetaceanCipherDecode extends Operation {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CetaceanCipherDecode constructor
|
||||||
|
*/
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.name = "Cetacean Cipher Decode";
|
||||||
|
this.module = "Ciphers";
|
||||||
|
this.description = "Decode Cetacean Cipher input. <br/><br/>e.g. <code>EEEEEEEEEeeEeEEEEEEEEEEEEeeEeEEe</code> becomes <code>hi</code>";
|
||||||
|
this.infoURL = "https://hitchhikers.fandom.com/wiki/Dolphins";
|
||||||
|
this.inputType = "string";
|
||||||
|
this.outputType = "string";
|
||||||
|
|
||||||
|
this.checks = [
|
||||||
|
{
|
||||||
|
pattern: "^(?:[eE]{16,})(?: [eE]{16,})*$",
|
||||||
|
flags: "",
|
||||||
|
args: []
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} input
|
||||||
|
* @param {Object[]} args
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
run(input, args) {
|
||||||
|
const binaryArray = [];
|
||||||
|
for (const char of input) {
|
||||||
|
if (char === " ") {
|
||||||
|
binaryArray.push(...[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]);
|
||||||
|
} else {
|
||||||
|
binaryArray.push(char === "e" ? 1 : 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const byteArray = [];
|
||||||
|
|
||||||
|
for (let i = 0; i < binaryArray.length; i += 16) {
|
||||||
|
byteArray.push(binaryArray.slice(i, i + 16).join(""));
|
||||||
|
}
|
||||||
|
|
||||||
|
return byteArray.map(byte =>
|
||||||
|
String.fromCharCode(parseInt(byte, 2))
|
||||||
|
).join("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default CetaceanCipherDecode;
|
||||||
51
src/core/operations/CetaceanCipherEncode.mjs
Normal file
51
src/core/operations/CetaceanCipherEncode.mjs
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
/**
|
||||||
|
* @author dolphinOnKeys [robin@weird.io]
|
||||||
|
* @copyright Crown Copyright 2022
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Operation from "../Operation.mjs";
|
||||||
|
import {toBinary} from "../lib/Binary.mjs";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cetacean Cipher Encode operation
|
||||||
|
*/
|
||||||
|
class CetaceanCipherEncode extends Operation {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CetaceanCipherEncode constructor
|
||||||
|
*/
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.name = "Cetacean Cipher Encode";
|
||||||
|
this.module = "Ciphers";
|
||||||
|
this.description = "Converts any input into Cetacean Cipher. <br/><br/>e.g. <code>hi</code> becomes <code>EEEEEEEEEeeEeEEEEEEEEEEEEeeEeEEe</code>";
|
||||||
|
this.infoURL = "https://hitchhikers.fandom.com/wiki/Dolphins";
|
||||||
|
this.inputType = "string";
|
||||||
|
this.outputType = "string";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} input
|
||||||
|
* @param {Object[]} args
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
run(input, args) {
|
||||||
|
const result = [];
|
||||||
|
const charArray = input.split("");
|
||||||
|
|
||||||
|
charArray.map(character => {
|
||||||
|
if (character === " ") {
|
||||||
|
result.push(character);
|
||||||
|
} else {
|
||||||
|
const binaryArray = toBinary(character.charCodeAt(0), "None", 16).split("");
|
||||||
|
result.push(binaryArray.map(str => str === "1" ? "e" : "E").join(""));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return result.join("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default CetaceanCipherEncode;
|
||||||
@@ -51,10 +51,27 @@ class DNSOverHTTPS extends Operation {
|
|||||||
value: [
|
value: [
|
||||||
"A",
|
"A",
|
||||||
"AAAA",
|
"AAAA",
|
||||||
"TXT",
|
"ANAME",
|
||||||
"MX",
|
"CERT",
|
||||||
|
"CNAME",
|
||||||
"DNSKEY",
|
"DNSKEY",
|
||||||
"NS"
|
"HTTPS",
|
||||||
|
"IPSECKEY",
|
||||||
|
"LOC",
|
||||||
|
"MX",
|
||||||
|
"NS",
|
||||||
|
"OPENPGPKEY",
|
||||||
|
"PTR",
|
||||||
|
"RRSIG",
|
||||||
|
"SIG",
|
||||||
|
"SOA",
|
||||||
|
"SPF",
|
||||||
|
"SRV",
|
||||||
|
"SSHFP",
|
||||||
|
"TA",
|
||||||
|
"TXT",
|
||||||
|
"URI",
|
||||||
|
"ANY"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* @author n1474335 [n1474335@gmail.com]
|
* @author n1474335 [n1474335@gmail.com]
|
||||||
|
* @author john19696 [john19696@protonmail.com]
|
||||||
* @copyright Crown Copyright 2016
|
* @copyright Crown Copyright 2016
|
||||||
* @license Apache-2.0
|
* @license Apache-2.0
|
||||||
*/
|
*/
|
||||||
@@ -33,6 +34,9 @@ import BLAKE2b from "./BLAKE2b.mjs";
|
|||||||
import BLAKE2s from "./BLAKE2s.mjs";
|
import BLAKE2s from "./BLAKE2s.mjs";
|
||||||
import Streebog from "./Streebog.mjs";
|
import Streebog from "./Streebog.mjs";
|
||||||
import GOSTHash from "./GOSTHash.mjs";
|
import GOSTHash from "./GOSTHash.mjs";
|
||||||
|
import LMHash from "./LMHash.mjs";
|
||||||
|
import NTHash from "./NTHash.mjs";
|
||||||
|
import OperationError from "../errors/OperationError.mjs";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate all hashes operation
|
* Generate all hashes operation
|
||||||
@@ -51,7 +55,75 @@ class GenerateAllHashes extends Operation {
|
|||||||
this.infoURL = "https://wikipedia.org/wiki/Comparison_of_cryptographic_hash_functions";
|
this.infoURL = "https://wikipedia.org/wiki/Comparison_of_cryptographic_hash_functions";
|
||||||
this.inputType = "ArrayBuffer";
|
this.inputType = "ArrayBuffer";
|
||||||
this.outputType = "string";
|
this.outputType = "string";
|
||||||
this.args = [];
|
this.args = [
|
||||||
|
{
|
||||||
|
name: "Length (bits)",
|
||||||
|
type: "option",
|
||||||
|
value: [
|
||||||
|
"All", "128", "160", "224", "256", "320", "384", "512"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Include names",
|
||||||
|
type: "boolean",
|
||||||
|
value: true
|
||||||
|
},
|
||||||
|
];
|
||||||
|
this.hashes = [
|
||||||
|
{name: "MD2", algo: (new MD2()), inputType: "arrayBuffer", params: []},
|
||||||
|
{name: "MD4", algo: (new MD4()), inputType: "arrayBuffer", params: []},
|
||||||
|
{name: "MD5", algo: (new MD5()), inputType: "arrayBuffer", params: []},
|
||||||
|
{name: "MD6", algo: (new MD6()), inputType: "str", params: []},
|
||||||
|
{name: "SHA0", algo: (new SHA0()), inputType: "arrayBuffer", params: []},
|
||||||
|
{name: "SHA1", algo: (new SHA1()), inputType: "arrayBuffer", params: []},
|
||||||
|
{name: "SHA2 224", algo: (new SHA2()), inputType: "arrayBuffer", params: ["224"]},
|
||||||
|
{name: "SHA2 256", algo: (new SHA2()), inputType: "arrayBuffer", params: ["256"]},
|
||||||
|
{name: "SHA2 384", algo: (new SHA2()), inputType: "arrayBuffer", params: ["384"]},
|
||||||
|
{name: "SHA2 512", algo: (new SHA2()), inputType: "arrayBuffer", params: ["512"]},
|
||||||
|
{name: "SHA3 224", algo: (new SHA3()), inputType: "arrayBuffer", params: ["224"]},
|
||||||
|
{name: "SHA3 256", algo: (new SHA3()), inputType: "arrayBuffer", params: ["256"]},
|
||||||
|
{name: "SHA3 384", algo: (new SHA3()), inputType: "arrayBuffer", params: ["384"]},
|
||||||
|
{name: "SHA3 512", algo: (new SHA3()), inputType: "arrayBuffer", params: ["512"]},
|
||||||
|
{name: "Keccak 224", algo: (new Keccak()), inputType: "arrayBuffer", params: ["224"]},
|
||||||
|
{name: "Keccak 256", algo: (new Keccak()), inputType: "arrayBuffer", params: ["256"]},
|
||||||
|
{name: "Keccak 384", algo: (new Keccak()), inputType: "arrayBuffer", params: ["384"]},
|
||||||
|
{name: "Keccak 512", algo: (new Keccak()), inputType: "arrayBuffer", params: ["512"]},
|
||||||
|
{name: "Shake 128", algo: (new Shake()), inputType: "arrayBuffer", params: ["128", 256]},
|
||||||
|
{name: "Shake 256", algo: (new Shake()), inputType: "arrayBuffer", params: ["256", 512]},
|
||||||
|
{name: "RIPEMD-128", algo: (new RIPEMD()), inputType: "arrayBuffer", params: ["128"]},
|
||||||
|
{name: "RIPEMD-160", algo: (new RIPEMD()), inputType: "arrayBuffer", params: ["160"]},
|
||||||
|
{name: "RIPEMD-256", algo: (new RIPEMD()), inputType: "arrayBuffer", params: ["256"]},
|
||||||
|
{name: "RIPEMD-320", algo: (new RIPEMD()), inputType: "arrayBuffer", params: ["320"]},
|
||||||
|
{name: "HAS-160", algo: (new HAS160()), inputType: "arrayBuffer", params: []},
|
||||||
|
{name: "Whirlpool-0", algo: (new Whirlpool()), inputType: "arrayBuffer", params: ["Whirlpool-0"]},
|
||||||
|
{name: "Whirlpool-T", algo: (new Whirlpool()), inputType: "arrayBuffer", params: ["Whirlpool-T"]},
|
||||||
|
{name: "Whirlpool", algo: (new Whirlpool()), inputType: "arrayBuffer", params: ["Whirlpool"]},
|
||||||
|
{name: "BLAKE2b-128", algo: (new BLAKE2b), inputType: "arrayBuffer", params: ["128", "Hex", {string: "", option: "UTF8"}]},
|
||||||
|
{name: "BLAKE2b-160", algo: (new BLAKE2b), inputType: "arrayBuffer", params: ["160", "Hex", {string: "", option: "UTF8"}]},
|
||||||
|
{name: "BLAKE2b-256", algo: (new BLAKE2b), inputType: "arrayBuffer", params: ["256", "Hex", {string: "", option: "UTF8"}]},
|
||||||
|
{name: "BLAKE2b-384", algo: (new BLAKE2b), inputType: "arrayBuffer", params: ["384", "Hex", {string: "", option: "UTF8"}]},
|
||||||
|
{name: "BLAKE2b-512", algo: (new BLAKE2b), inputType: "arrayBuffer", params: ["512", "Hex", {string: "", option: "UTF8"}]},
|
||||||
|
{name: "BLAKE2s-128", algo: (new BLAKE2s), inputType: "arrayBuffer", params: ["128", "Hex", {string: "", option: "UTF8"}]},
|
||||||
|
{name: "BLAKE2s-160", algo: (new BLAKE2s), inputType: "arrayBuffer", params: ["160", "Hex", {string: "", option: "UTF8"}]},
|
||||||
|
{name: "BLAKE2s-256", algo: (new BLAKE2s), inputType: "arrayBuffer", params: ["256", "Hex", {string: "", option: "UTF8"}]},
|
||||||
|
{name: "Streebog-256", algo: (new Streebog), inputType: "arrayBuffer", params: ["256"]},
|
||||||
|
{name: "Streebog-512", algo: (new Streebog), inputType: "arrayBuffer", params: ["512"]},
|
||||||
|
{name: "GOST", algo: (new GOSTHash), inputType: "arrayBuffer", params: ["D-A"]},
|
||||||
|
{name: "LM Hash", algo: (new LMHash), inputType: "str", params: []},
|
||||||
|
{name: "NT Hash", algo: (new NTHash), inputType: "str", params: []},
|
||||||
|
{name: "SSDEEP", algo: (new SSDEEP()), inputType: "str"},
|
||||||
|
{name: "CTPH", algo: (new CTPH()), inputType: "str"}
|
||||||
|
];
|
||||||
|
this.checksums = [
|
||||||
|
{name: "Fletcher-8", algo: (new Fletcher8Checksum), inputType: "byteArray", params: []},
|
||||||
|
{name: "Fletcher-16", algo: (new Fletcher16Checksum), inputType: "byteArray", params: []},
|
||||||
|
{name: "Fletcher-32", algo: (new Fletcher32Checksum), inputType: "byteArray", params: []},
|
||||||
|
{name: "Fletcher-64", algo: (new Fletcher64Checksum), inputType: "byteArray", params: []},
|
||||||
|
{name: "Adler-32", algo: (new Adler32Checksum), inputType: "byteArray", params: []},
|
||||||
|
{name: "CRC-8", algo: (new CRC8Checksum), inputType: "arrayBuffer", params: ["CRC-8"]},
|
||||||
|
{name: "CRC-16", algo: (new CRC16Checksum), inputType: "arrayBuffer", params: []},
|
||||||
|
{name: "CRC-32", algo: (new CRC32Checksum), inputType: "arrayBuffer", params: []}
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -60,63 +132,74 @@ class GenerateAllHashes extends Operation {
|
|||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
run(input, args) {
|
run(input, args) {
|
||||||
const arrayBuffer = input,
|
const [length, includeNames] = args;
|
||||||
str = Utils.arrayBufferToStr(arrayBuffer, false),
|
this.inputArrayBuffer = input;
|
||||||
byteArray = new Uint8Array(arrayBuffer),
|
this.inputStr = Utils.arrayBufferToStr(input, false);
|
||||||
output = "MD2: " + (new MD2()).run(arrayBuffer, []) +
|
this.inputByteArray = new Uint8Array(input);
|
||||||
"\nMD4: " + (new MD4()).run(arrayBuffer, []) +
|
|
||||||
"\nMD5: " + (new MD5()).run(arrayBuffer, []) +
|
let digest, output = "";
|
||||||
"\nMD6: " + (new MD6()).run(str, []) +
|
// iterate over each of the hashes
|
||||||
"\nSHA0: " + (new SHA0()).run(arrayBuffer, []) +
|
this.hashes.forEach(hash => {
|
||||||
"\nSHA1: " + (new SHA1()).run(arrayBuffer, []) +
|
digest = this.executeAlgo(hash.algo, hash.inputType, hash.params || []);
|
||||||
"\nSHA2 224: " + (new SHA2()).run(arrayBuffer, ["224"]) +
|
output += this.formatDigest(digest, length, includeNames, hash.name);
|
||||||
"\nSHA2 256: " + (new SHA2()).run(arrayBuffer, ["256"]) +
|
});
|
||||||
"\nSHA2 384: " + (new SHA2()).run(arrayBuffer, ["384"]) +
|
|
||||||
"\nSHA2 512: " + (new SHA2()).run(arrayBuffer, ["512"]) +
|
if (length === "All") {
|
||||||
"\nSHA3 224: " + (new SHA3()).run(arrayBuffer, ["224"]) +
|
output += "\nChecksums:\n";
|
||||||
"\nSHA3 256: " + (new SHA3()).run(arrayBuffer, ["256"]) +
|
this.checksums.forEach(checksum => {
|
||||||
"\nSHA3 384: " + (new SHA3()).run(arrayBuffer, ["384"]) +
|
digest = this.executeAlgo(checksum.algo, checksum.inputType, checksum.params || []);
|
||||||
"\nSHA3 512: " + (new SHA3()).run(arrayBuffer, ["512"]) +
|
output += this.formatDigest(digest, length, includeNames, checksum.name);
|
||||||
"\nKeccak 224: " + (new Keccak()).run(arrayBuffer, ["224"]) +
|
});
|
||||||
"\nKeccak 256: " + (new Keccak()).run(arrayBuffer, ["256"]) +
|
}
|
||||||
"\nKeccak 384: " + (new Keccak()).run(arrayBuffer, ["384"]) +
|
|
||||||
"\nKeccak 512: " + (new Keccak()).run(arrayBuffer, ["512"]) +
|
|
||||||
"\nShake 128: " + (new Shake()).run(arrayBuffer, ["128", 256]) +
|
|
||||||
"\nShake 256: " + (new Shake()).run(arrayBuffer, ["256", 512]) +
|
|
||||||
"\nRIPEMD-128: " + (new RIPEMD()).run(arrayBuffer, ["128"]) +
|
|
||||||
"\nRIPEMD-160: " + (new RIPEMD()).run(arrayBuffer, ["160"]) +
|
|
||||||
"\nRIPEMD-256: " + (new RIPEMD()).run(arrayBuffer, ["256"]) +
|
|
||||||
"\nRIPEMD-320: " + (new RIPEMD()).run(arrayBuffer, ["320"]) +
|
|
||||||
"\nHAS-160: " + (new HAS160()).run(arrayBuffer, []) +
|
|
||||||
"\nWhirlpool-0: " + (new Whirlpool()).run(arrayBuffer, ["Whirlpool-0"]) +
|
|
||||||
"\nWhirlpool-T: " + (new Whirlpool()).run(arrayBuffer, ["Whirlpool-T"]) +
|
|
||||||
"\nWhirlpool: " + (new Whirlpool()).run(arrayBuffer, ["Whirlpool"]) +
|
|
||||||
"\nBLAKE2b-128: " + (new BLAKE2b).run(arrayBuffer, ["128", "Hex", {string: "", option: "UTF8"}]) +
|
|
||||||
"\nBLAKE2b-160: " + (new BLAKE2b).run(arrayBuffer, ["160", "Hex", {string: "", option: "UTF8"}]) +
|
|
||||||
"\nBLAKE2b-256: " + (new BLAKE2b).run(arrayBuffer, ["256", "Hex", {string: "", option: "UTF8"}]) +
|
|
||||||
"\nBLAKE2b-384: " + (new BLAKE2b).run(arrayBuffer, ["384", "Hex", {string: "", option: "UTF8"}]) +
|
|
||||||
"\nBLAKE2b-512: " + (new BLAKE2b).run(arrayBuffer, ["512", "Hex", {string: "", option: "UTF8"}]) +
|
|
||||||
"\nBLAKE2s-128: " + (new BLAKE2s).run(arrayBuffer, ["128", "Hex", {string: "", option: "UTF8"}]) +
|
|
||||||
"\nBLAKE2s-160: " + (new BLAKE2s).run(arrayBuffer, ["160", "Hex", {string: "", option: "UTF8"}]) +
|
|
||||||
"\nBLAKE2s-256: " + (new BLAKE2s).run(arrayBuffer, ["256", "Hex", {string: "", option: "UTF8"}]) +
|
|
||||||
"\nStreebog-256: " + (new Streebog).run(arrayBuffer, ["256"]) +
|
|
||||||
"\nStreebog-512: " + (new Streebog).run(arrayBuffer, ["512"]) +
|
|
||||||
"\nGOST: " + (new GOSTHash).run(arrayBuffer, ["D-A"]) +
|
|
||||||
"\nSSDEEP: " + (new SSDEEP()).run(str) +
|
|
||||||
"\nCTPH: " + (new CTPH()).run(str) +
|
|
||||||
"\n\nChecksums:" +
|
|
||||||
"\nFletcher-8: " + (new Fletcher8Checksum).run(byteArray, []) +
|
|
||||||
"\nFletcher-16: " + (new Fletcher16Checksum).run(byteArray, []) +
|
|
||||||
"\nFletcher-32: " + (new Fletcher32Checksum).run(byteArray, []) +
|
|
||||||
"\nFletcher-64: " + (new Fletcher64Checksum).run(byteArray, []) +
|
|
||||||
"\nAdler-32: " + (new Adler32Checksum).run(byteArray, []) +
|
|
||||||
"\nCRC-8: " + (new CRC8Checksum).run(arrayBuffer, ["CRC-8"]) +
|
|
||||||
"\nCRC-16: " + (new CRC16Checksum).run(arrayBuffer, []) +
|
|
||||||
"\nCRC-32: " + (new CRC32Checksum).run(arrayBuffer, []);
|
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executes a hash or checksum algorithm
|
||||||
|
*
|
||||||
|
* @param {Function} algo - The hash or checksum algorithm
|
||||||
|
* @param {string} inputType
|
||||||
|
* @param {Object[]} [params=[]]
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
executeAlgo(algo, inputType, params=[]) {
|
||||||
|
let digest = null;
|
||||||
|
switch (inputType) {
|
||||||
|
case "arrayBuffer":
|
||||||
|
digest = algo.run(this.inputArrayBuffer, params);
|
||||||
|
break;
|
||||||
|
case "str":
|
||||||
|
digest = algo.run(this.inputStr, params);
|
||||||
|
break;
|
||||||
|
case "byteArray":
|
||||||
|
digest = algo.run(this.inputByteArray, params);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new OperationError("Unknown hash input type: " + inputType);
|
||||||
|
}
|
||||||
|
|
||||||
|
return digest;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Formats the digest depending on user-specified arguments
|
||||||
|
* @param {string} digest
|
||||||
|
* @param {string} length
|
||||||
|
* @param {boolean} includeNames
|
||||||
|
* @param {string} name
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
formatDigest(digest, length, includeNames, name) {
|
||||||
|
if (length !== "All" && (digest.length * 4) !== parseInt(length, 10))
|
||||||
|
return "";
|
||||||
|
|
||||||
|
if (!includeNames)
|
||||||
|
return digest + "\n";
|
||||||
|
|
||||||
|
return `${name}:${" ".repeat(13-name.length)}${digest}\n`;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default GenerateAllHashes;
|
export default GenerateAllHashes;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
* @license Apache-2.0
|
* @license Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import jpath from "jsonpath";
|
import {JSONPath} from "jsonpath-plus";
|
||||||
import Operation from "../Operation.mjs";
|
import Operation from "../Operation.mjs";
|
||||||
import OperationError from "../errors/OperationError.mjs";
|
import OperationError from "../errors/OperationError.mjs";
|
||||||
|
|
||||||
@@ -27,14 +27,20 @@ class JPathExpression extends Operation {
|
|||||||
this.outputType = "string";
|
this.outputType = "string";
|
||||||
this.args = [
|
this.args = [
|
||||||
{
|
{
|
||||||
"name": "Query",
|
name: "Query",
|
||||||
"type": "string",
|
type: "string",
|
||||||
"value": ""
|
value: ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Result delimiter",
|
name: "Result delimiter",
|
||||||
"type": "binaryShortString",
|
type: "binaryShortString",
|
||||||
"value": "\\n"
|
value: "\\n"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Prevent eval",
|
||||||
|
type: "boolean",
|
||||||
|
value: true,
|
||||||
|
description: "Evaluated expressions are disabled by default for security reasons"
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -45,18 +51,21 @@ class JPathExpression extends Operation {
|
|||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
run(input, args) {
|
run(input, args) {
|
||||||
const [query, delimiter] = args;
|
const [query, delimiter, preventEval] = args;
|
||||||
let results,
|
let results, jsonObj;
|
||||||
obj;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
obj = JSON.parse(input);
|
jsonObj = JSON.parse(input);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw new OperationError(`Invalid input JSON: ${err.message}`);
|
throw new OperationError(`Invalid input JSON: ${err.message}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
results = jpath.query(obj, query);
|
results = JSONPath({
|
||||||
|
path: query,
|
||||||
|
json: jsonObj,
|
||||||
|
preventEval: preventEval
|
||||||
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw new OperationError(`Invalid JPath expression: ${err.message}`);
|
throw new OperationError(`Invalid JPath expression: ${err.message}`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,8 +114,11 @@ class JSONToCSV extends Operation {
|
|||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
escapeCellContents(data, force=false) {
|
escapeCellContents(data, force=false) {
|
||||||
if (typeof data === "number") data = data.toString();
|
if (data !== "string") {
|
||||||
if (force && typeof data !== "string") data = JSON.stringify(data);
|
const isPrimitive = data == null || typeof data !== "object";
|
||||||
|
if (isPrimitive) data = `${data}`;
|
||||||
|
else if (force) data = JSON.stringify(data);
|
||||||
|
}
|
||||||
|
|
||||||
// Double quotes should be doubled up
|
// Double quotes should be doubled up
|
||||||
data = data.replace(/"/g, '""');
|
data = data.replace(/"/g, '""');
|
||||||
|
|||||||
@@ -26,6 +26,13 @@ class JWTDecode extends Operation {
|
|||||||
this.inputType = "string";
|
this.inputType = "string";
|
||||||
this.outputType = "JSON";
|
this.outputType = "JSON";
|
||||||
this.args = [];
|
this.args = [];
|
||||||
|
this.checks = [
|
||||||
|
{
|
||||||
|
pattern: "^ey([A-Za-z0-9_-]+)\\.ey([A-Za-z0-9_-]+)\\.([A-Za-z0-9_-]+)$",
|
||||||
|
flags: "",
|
||||||
|
args: []
|
||||||
|
},
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
41
src/core/operations/LMHash.mjs
Normal file
41
src/core/operations/LMHash.mjs
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
/**
|
||||||
|
* @author n1474335 [n1474335@gmail.com]
|
||||||
|
* @copyright Crown Copyright 2022
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Operation from "../Operation.mjs";
|
||||||
|
import {smbhash} from "ntlm";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LM Hash operation
|
||||||
|
*/
|
||||||
|
class LMHash extends Operation {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LMHash constructor
|
||||||
|
*/
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.name = "LM Hash";
|
||||||
|
this.module = "Crypto";
|
||||||
|
this.description = "An LM Hash, or LAN Manager Hash, is a deprecated way of storing passwords on old Microsoft operating systems. It is particularly weak and can be cracked in seconds on modern hardware using rainbow tables.";
|
||||||
|
this.infoURL = "https://wikipedia.org/wiki/LAN_Manager#Password_hashing_algorithm";
|
||||||
|
this.inputType = "string";
|
||||||
|
this.outputType = "string";
|
||||||
|
this.args = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} input
|
||||||
|
* @param {Object[]} args
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
run(input, args) {
|
||||||
|
return smbhash.lmhash(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export default LMHash;
|
||||||
57
src/core/operations/LS47Decrypt.mjs
Normal file
57
src/core/operations/LS47Decrypt.mjs
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
/**
|
||||||
|
* @author n1073645 [n1073645@gmail.com]
|
||||||
|
* @copyright Crown Copyright 2020
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Operation from "../Operation.mjs";
|
||||||
|
import * as LS47 from "../lib/LS47.mjs";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LS47 Decrypt operation
|
||||||
|
*/
|
||||||
|
class LS47Decrypt extends Operation {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LS47Decrypt constructor
|
||||||
|
*/
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.name = "LS47 Decrypt";
|
||||||
|
this.module = "Crypto";
|
||||||
|
this.description = "This is a slight improvement of the ElsieFour cipher as described by Alan Kaminsky. We use 7x7 characters instead of original (barely fitting) 6x6, to be able to encrypt some structured information. We also describe a simple key-expansion algorithm, because remembering passwords is popular. Similar security considerations as with ElsieFour hold.<br>The LS47 alphabet consists of following characters: <code>_abcdefghijklmnopqrstuvwxyz.0123456789,-+*/:?!'()</code><br>An LS47 key is a permutation of the alphabet that is then represented in a 7x7 grid used for the encryption or decryption.";
|
||||||
|
this.infoURL = "https://github.com/exaexa/ls47";
|
||||||
|
this.inputType = "string";
|
||||||
|
this.outputType = "string";
|
||||||
|
this.args = [
|
||||||
|
{
|
||||||
|
name: "Password",
|
||||||
|
type: "string",
|
||||||
|
value: ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Padding",
|
||||||
|
type: "number",
|
||||||
|
value: 10
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} input
|
||||||
|
* @param {Object[]} args
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
run(input, args) {
|
||||||
|
this.paddingSize = parseInt(args[1], 10);
|
||||||
|
|
||||||
|
LS47.initTiles();
|
||||||
|
|
||||||
|
const key = LS47.deriveKey(args[0]);
|
||||||
|
return LS47.decryptPad(key, input, this.paddingSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export default LS47Decrypt;
|
||||||
62
src/core/operations/LS47Encrypt.mjs
Normal file
62
src/core/operations/LS47Encrypt.mjs
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
/**
|
||||||
|
* @author n1073645 [n1073645@gmail.com]
|
||||||
|
* @copyright Crown Copyright 2020
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Operation from "../Operation.mjs";
|
||||||
|
import * as LS47 from "../lib/LS47.mjs";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LS47 Encrypt operation
|
||||||
|
*/
|
||||||
|
class LS47Encrypt extends Operation {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LS47Encrypt constructor
|
||||||
|
*/
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.name = "LS47 Encrypt";
|
||||||
|
this.module = "Crypto";
|
||||||
|
this.description = "This is a slight improvement of the ElsieFour cipher as described by Alan Kaminsky. We use 7x7 characters instead of original (barely fitting) 6x6, to be able to encrypt some structured information. We also describe a simple key-expansion algorithm, because remembering passwords is popular. Similar security considerations as with ElsieFour hold.<br>The LS47 alphabet consists of following characters: <code>_abcdefghijklmnopqrstuvwxyz.0123456789,-+*/:?!'()</code><br>A LS47 key is a permutation of the alphabet that is then represented in a 7x7 grid used for the encryption or decryption.";
|
||||||
|
this.infoURL = "https://github.com/exaexa/ls47";
|
||||||
|
this.inputType = "string";
|
||||||
|
this.outputType = "string";
|
||||||
|
this.args = [
|
||||||
|
{
|
||||||
|
name: "Password",
|
||||||
|
type: "string",
|
||||||
|
value: ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Padding",
|
||||||
|
type: "number",
|
||||||
|
value: 10
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Signature",
|
||||||
|
type: "string",
|
||||||
|
value: ""
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} input
|
||||||
|
* @param {Object[]} args
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
run(input, args) {
|
||||||
|
this.paddingSize = parseInt(args[1], 10);
|
||||||
|
|
||||||
|
LS47.initTiles();
|
||||||
|
|
||||||
|
const key = LS47.deriveKey(args[0]);
|
||||||
|
return LS47.encryptPad(key, input, args[2], this.paddingSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export default LS47Encrypt;
|
||||||
43
src/core/operations/LZ4Compress.mjs
Normal file
43
src/core/operations/LZ4Compress.mjs
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
/**
|
||||||
|
* @author n1474335 [n1474335@gmail.com]
|
||||||
|
* @copyright Crown Copyright 2022
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Operation from "../Operation.mjs";
|
||||||
|
import lz4 from "lz4js";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LZ4 Compress operation
|
||||||
|
*/
|
||||||
|
class LZ4Compress extends Operation {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LZ4Compress constructor
|
||||||
|
*/
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.name = "LZ4 Compress";
|
||||||
|
this.module = "Compression";
|
||||||
|
this.description = "LZ4 is a lossless data compression algorithm that is focused on compression and decompression speed. It belongs to the LZ77 family of byte-oriented compression schemes.";
|
||||||
|
this.infoURL = "https://wikipedia.org/wiki/LZ4_(compression_algorithm)";
|
||||||
|
this.inputType = "ArrayBuffer";
|
||||||
|
this.outputType = "ArrayBuffer";
|
||||||
|
this.args = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ArrayBuffer} input
|
||||||
|
* @param {Object[]} args
|
||||||
|
* @returns {ArrayBuffer}
|
||||||
|
*/
|
||||||
|
run(input, args) {
|
||||||
|
const inBuf = new Uint8Array(input);
|
||||||
|
const compressed = lz4.compress(inBuf);
|
||||||
|
return compressed.buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export default LZ4Compress;
|
||||||
43
src/core/operations/LZ4Decompress.mjs
Normal file
43
src/core/operations/LZ4Decompress.mjs
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
/**
|
||||||
|
* @author n1474335 [n1474335@gmail.com]
|
||||||
|
* @copyright Crown Copyright 2022
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Operation from "../Operation.mjs";
|
||||||
|
import lz4 from "lz4js";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LZ4 Decompress operation
|
||||||
|
*/
|
||||||
|
class LZ4Decompress extends Operation {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LZ4Decompress constructor
|
||||||
|
*/
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.name = "LZ4 Decompress";
|
||||||
|
this.module = "Compression";
|
||||||
|
this.description = "LZ4 is a lossless data compression algorithm that is focused on compression and decompression speed. It belongs to the LZ77 family of byte-oriented compression schemes.";
|
||||||
|
this.infoURL = "https://wikipedia.org/wiki/LZ4_(compression_algorithm)";
|
||||||
|
this.inputType = "ArrayBuffer";
|
||||||
|
this.outputType = "ArrayBuffer";
|
||||||
|
this.args = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ArrayBuffer} input
|
||||||
|
* @param {Object[]} args
|
||||||
|
* @returns {ArrayBuffer}
|
||||||
|
*/
|
||||||
|
run(input, args) {
|
||||||
|
const inBuf = new Uint8Array(input);
|
||||||
|
const decompressed = lz4.decompress(inBuf);
|
||||||
|
return decompressed.buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export default LZ4Decompress;
|
||||||
64
src/core/operations/LZMACompress.mjs
Normal file
64
src/core/operations/LZMACompress.mjs
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
/**
|
||||||
|
* @author Matt C [me@mitt.dev]
|
||||||
|
* @copyright Crown Copyright 2022
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Operation from "../Operation.mjs";
|
||||||
|
import OperationError from "../errors/OperationError.mjs";
|
||||||
|
|
||||||
|
import { compress } from "@blu3r4y/lzma";
|
||||||
|
import {isWorkerEnvironment} from "../Utils.mjs";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LZMA Compress operation
|
||||||
|
*/
|
||||||
|
class LZMACompress extends Operation {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LZMACompress constructor
|
||||||
|
*/
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.name = "LZMA Compress";
|
||||||
|
this.module = "Compression";
|
||||||
|
this.description = "Compresses data using the Lempel\u2013Ziv\u2013Markov chain algorithm. Compression mode determines the speed and effectiveness of the compression: 1 is fastest and less effective, 9 is slowest and most effective";
|
||||||
|
this.infoURL = "https://wikipedia.org/wiki/Lempel%E2%80%93Ziv%E2%80%93Markov_chain_algorithm";
|
||||||
|
this.inputType = "ArrayBuffer";
|
||||||
|
this.outputType = "ArrayBuffer";
|
||||||
|
this.args = [
|
||||||
|
{
|
||||||
|
name: "Compression Mode",
|
||||||
|
type: "option",
|
||||||
|
value: [
|
||||||
|
"1", "2", "3", "4", "5", "6", "7", "8", "9"
|
||||||
|
],
|
||||||
|
"defaultIndex": 6
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ArrayBuffer} input
|
||||||
|
* @param {Object[]} args
|
||||||
|
* @returns {ArrayBuffer}
|
||||||
|
*/
|
||||||
|
async run(input, args) {
|
||||||
|
const mode = Number(args[0]);
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
compress(new Uint8Array(input), mode, (result, error) => {
|
||||||
|
if (error) {
|
||||||
|
reject(new OperationError(`Failed to compress input: ${error.message}`));
|
||||||
|
}
|
||||||
|
// The compression returns as an Int8Array, but we can just get the unsigned data from the buffer
|
||||||
|
resolve(new Int8Array(result).buffer);
|
||||||
|
}, (percent) => {
|
||||||
|
if (isWorkerEnvironment()) self.sendStatusMessage(`Compressing input: ${(percent*100).toFixed(2)}%`);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export default LZMACompress;
|
||||||
57
src/core/operations/LZMADecompress.mjs
Normal file
57
src/core/operations/LZMADecompress.mjs
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
/**
|
||||||
|
* @author Matt C [me@mitt.dev]
|
||||||
|
* @copyright Crown Copyright 2022
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Operation from "../Operation.mjs";
|
||||||
|
import OperationError from "../errors/OperationError.mjs";
|
||||||
|
import {decompress} from "@blu3r4y/lzma";
|
||||||
|
import Utils, {isWorkerEnvironment} from "../Utils.mjs";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LZMA Decompress operation
|
||||||
|
*/
|
||||||
|
class LZMADecompress extends Operation {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LZMADecompress constructor
|
||||||
|
*/
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.name = "LZMA Decompress";
|
||||||
|
this.module = "Compression";
|
||||||
|
this.description = "Decompresses data using the Lempel-Ziv-Markov chain Algorithm.";
|
||||||
|
this.infoURL = "https://wikipedia.org/wiki/Lempel%E2%80%93Ziv%E2%80%93Markov_chain_algorithm";
|
||||||
|
this.inputType = "ArrayBuffer";
|
||||||
|
this.outputType = "ArrayBuffer";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ArrayBuffer} input
|
||||||
|
* @param {Object[]} args
|
||||||
|
* @returns {ArrayBuffer}
|
||||||
|
*/
|
||||||
|
async run(input, args) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
decompress(new Uint8Array(input), (result, error) => {
|
||||||
|
if (error) {
|
||||||
|
reject(new OperationError(`Failed to decompress input: ${error.message}`));
|
||||||
|
}
|
||||||
|
// The decompression returns either a String or an untyped unsigned int8 array, but we can just get the unsigned data from the buffer
|
||||||
|
|
||||||
|
if (typeof result == "string") {
|
||||||
|
resolve(Utils.strToArrayBuffer(result));
|
||||||
|
} else {
|
||||||
|
resolve(new Int8Array(result).buffer);
|
||||||
|
}
|
||||||
|
}, (percent) => {
|
||||||
|
if (isWorkerEnvironment()) self.sendStatusMessage(`Decompressing input: ${(percent*100).toFixed(2)}%`);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export default LZMADecompress;
|
||||||
55
src/core/operations/LZStringCompress.mjs
Normal file
55
src/core/operations/LZStringCompress.mjs
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
/**
|
||||||
|
* @author crespyl [peter@crespyl.net]
|
||||||
|
* @copyright Peter Jacobs 2021
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Operation from "../Operation.mjs";
|
||||||
|
import OperationError from "../errors/OperationError.mjs";
|
||||||
|
|
||||||
|
import {COMPRESSION_OUTPUT_FORMATS, COMPRESSION_FUNCTIONS} from "../lib/LZString.mjs";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LZString Compress operation
|
||||||
|
*/
|
||||||
|
class LZStringCompress extends Operation {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LZStringCompress constructor
|
||||||
|
*/
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.name = "LZString Compress";
|
||||||
|
this.module = "Compression";
|
||||||
|
this.description = "Compress the input with lz-string.";
|
||||||
|
this.infoURL = "https://pieroxy.net/blog/pages/lz-string/index.html";
|
||||||
|
this.inputType = "string";
|
||||||
|
this.outputType = "string";
|
||||||
|
this.args = [
|
||||||
|
{
|
||||||
|
name: "Compression Format",
|
||||||
|
type: "option",
|
||||||
|
defaultIndex: 0,
|
||||||
|
value: COMPRESSION_OUTPUT_FORMATS
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} input
|
||||||
|
* @param {Object[]} args
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
run(input, args) {
|
||||||
|
const compress = COMPRESSION_FUNCTIONS[args[0]];
|
||||||
|
if (compress) {
|
||||||
|
return compress(input);
|
||||||
|
} else {
|
||||||
|
throw new OperationError("Unable to find compression function");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export default LZStringCompress;
|
||||||
56
src/core/operations/LZStringDecompress.mjs
Normal file
56
src/core/operations/LZStringDecompress.mjs
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
/**
|
||||||
|
* @author crespyl [peter@crespyl.net]
|
||||||
|
* @copyright Peter Jacobs 2021
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Operation from "../Operation.mjs";
|
||||||
|
import OperationError from "../errors/OperationError.mjs";
|
||||||
|
|
||||||
|
import {COMPRESSION_OUTPUT_FORMATS, DECOMPRESSION_FUNCTIONS} from "../lib/LZString.mjs";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LZString Decompress operation
|
||||||
|
*/
|
||||||
|
class LZStringDecompress extends Operation {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LZStringDecompress constructor
|
||||||
|
*/
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.name = "LZString Decompress";
|
||||||
|
this.module = "Compression";
|
||||||
|
this.description = "Decompresses data that was compressed with lz-string.";
|
||||||
|
this.infoURL = "https://pieroxy.net/blog/pages/lz-string/index.html";
|
||||||
|
this.inputType = "string";
|
||||||
|
this.outputType = "string";
|
||||||
|
this.args = [
|
||||||
|
{
|
||||||
|
name: "Compression Format",
|
||||||
|
type: "option",
|
||||||
|
defaultIndex: 0,
|
||||||
|
value: COMPRESSION_OUTPUT_FORMATS
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} input
|
||||||
|
* @param {Object[]} args
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
run(input, args) {
|
||||||
|
const decompress = DECOMPRESSION_FUNCTIONS[args[0]];
|
||||||
|
if (decompress) {
|
||||||
|
return decompress(input);
|
||||||
|
} else {
|
||||||
|
throw new OperationError("Unable to find decompression function");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export default LZStringDecompress;
|
||||||
46
src/core/operations/NTHash.mjs
Normal file
46
src/core/operations/NTHash.mjs
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
/**
|
||||||
|
* @author brun0ne [brunonblok@gmail.com]
|
||||||
|
* @copyright Crown Copyright 2022
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Operation from "../Operation.mjs";
|
||||||
|
|
||||||
|
import cptable from "codepage";
|
||||||
|
import {runHash} from "../lib/Hash.mjs";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* NT Hash operation
|
||||||
|
*/
|
||||||
|
class NTHash extends Operation {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* NTHash constructor
|
||||||
|
*/
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.name = "NT Hash";
|
||||||
|
this.module = "Crypto";
|
||||||
|
this.description = "An NT Hash, sometimes referred to as an NTLM hash, is a method of storing passwords on Windows systems. It works by running MD4 on UTF-16LE encoded input. NTLM hashes are considered weak because they can be brute-forced very easily with modern hardware.";
|
||||||
|
this.infoURL = "https://wikipedia.org/wiki/NT_LAN_Manager";
|
||||||
|
this.inputType = "string";
|
||||||
|
this.outputType = "string";
|
||||||
|
this.args = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} input
|
||||||
|
* @param {Object[]} args
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
run(input, args) {
|
||||||
|
const format = 1200; // UTF-16LE
|
||||||
|
const encoded = cptable.utils.encode(format, input);
|
||||||
|
const hashed = runHash("md4", encoded);
|
||||||
|
|
||||||
|
return hashed.toUpperCase();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default NTHash;
|
||||||
@@ -12,10 +12,8 @@ import { isImage } from "../lib/FileType.mjs";
|
|||||||
import { toBase64 } from "../lib/Base64.mjs";
|
import { toBase64 } from "../lib/Base64.mjs";
|
||||||
import { isWorkerEnvironment } from "../Utils.mjs";
|
import { isWorkerEnvironment } from "../Utils.mjs";
|
||||||
|
|
||||||
import Tesseract from "tesseract.js";
|
|
||||||
const { createWorker } = Tesseract;
|
|
||||||
|
|
||||||
import process from "process";
|
import process from "process";
|
||||||
|
import { createWorker } from "tesseract.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optical Character Recognition operation
|
* Optical Character Recognition operation
|
||||||
@@ -55,7 +53,7 @@ class OpticalCharacterRecognition extends Operation {
|
|||||||
|
|
||||||
const type = isImage(input);
|
const type = isImage(input);
|
||||||
if (!type) {
|
if (!type) {
|
||||||
throw new OperationError("Invalid File Type");
|
throw new OperationError("Unsupported file type (supported: jpg,png,pbm,bmp) or no file provided");
|
||||||
}
|
}
|
||||||
|
|
||||||
const assetDir = isWorkerEnvironment() ? `${self.docURL}/assets/` : `${process.cwd()}/src/core/vendor/`;
|
const assetDir = isWorkerEnvironment() ? `${self.docURL}/assets/` : `${process.cwd()}/src/core/vendor/`;
|
||||||
@@ -74,7 +72,7 @@ class OpticalCharacterRecognition extends Operation {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
await worker.load();
|
await worker.load();
|
||||||
self.sendStatusMessage("Loading English language...");
|
self.sendStatusMessage(`Loading English language pack...`);
|
||||||
await worker.loadLanguage("eng");
|
await worker.loadLanguage("eng");
|
||||||
self.sendStatusMessage("Intialising Tesseract API...");
|
self.sendStatusMessage("Intialising Tesseract API...");
|
||||||
await worker.initialize("eng");
|
await worker.initialize("eng");
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ class ParseASN1HexString extends Operation {
|
|||||||
*/
|
*/
|
||||||
run(input, args) {
|
run(input, args) {
|
||||||
const [index, truncateLen] = args;
|
const [index, truncateLen] = args;
|
||||||
return r.ASN1HEX.dump(input.replace(/\s/g, ""), {
|
return r.ASN1HEX.dump(input.replace(/\s/g, "").toLowerCase(), {
|
||||||
"ommitLongOctet": truncateLen
|
"ommitLongOctet": truncateLen
|
||||||
}, index);
|
}, index);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class ParseSSHHostKey extends Operation {
|
|||||||
|
|
||||||
this.name = "Parse SSH Host Key";
|
this.name = "Parse SSH Host Key";
|
||||||
this.module = "Default";
|
this.module = "Default";
|
||||||
this.description = "Parses a SSH host key and extracts fields from it.<br>The key type can be:<ul><li>ssh-rsa</li><li>ssh-dss</li><li>ecdsa-sha2</li></ul>The key format can be either Hex or Base64.";
|
this.description = "Parses a SSH host key and extracts fields from it.<br>The key type can be:<ul><li>ssh-rsa</li><li>ssh-dss</li><li>ecdsa-sha2</li><li>ssh-ed25519</li></ul>The key format can be either Hex or Base64.";
|
||||||
this.infoURL = "https://wikipedia.org/wiki/Secure_Shell";
|
this.infoURL = "https://wikipedia.org/wiki/Secure_Shell";
|
||||||
this.inputType = "string";
|
this.inputType = "string";
|
||||||
this.outputType = "string";
|
this.outputType = "string";
|
||||||
@@ -71,6 +71,8 @@ class ParseSSHHostKey extends Operation {
|
|||||||
} else if (keyType.startsWith("ecdsa-sha2")) {
|
} else if (keyType.startsWith("ecdsa-sha2")) {
|
||||||
output += `\nCurve: ${Utils.byteArrayToChars(fromHex(fields[1]))}`;
|
output += `\nCurve: ${Utils.byteArrayToChars(fromHex(fields[1]))}`;
|
||||||
output += `\nPoint: 0x${fields.slice(2)}`;
|
output += `\nPoint: 0x${fields.slice(2)}`;
|
||||||
|
} else if (keyType === "ssh-ed25519") {
|
||||||
|
output += `\nx: 0x${fields[1]}`;
|
||||||
} else {
|
} else {
|
||||||
output += "\nUnsupported key type.";
|
output += "\nUnsupported key type.";
|
||||||
output += `\nParameters: ${fields.slice(1)}`;
|
output += `\nParameters: ${fields.slice(1)}`;
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ class ParseX509Certificate extends Operation {
|
|||||||
|
|
||||||
switch (inputFormat) {
|
switch (inputFormat) {
|
||||||
case "DER Hex":
|
case "DER Hex":
|
||||||
input = input.replace(/\s/g, "");
|
input = input.replace(/\s/g, "").toLowerCase();
|
||||||
cert.readCertHex(input);
|
cert.readCertHex(input);
|
||||||
break;
|
break;
|
||||||
case "PEM":
|
case "PEM":
|
||||||
|
|||||||
@@ -52,8 +52,12 @@ class PseudoRandomNumberGenerator extends Operation {
|
|||||||
let bytes;
|
let bytes;
|
||||||
|
|
||||||
if (isWorkerEnvironment() && self.crypto) {
|
if (isWorkerEnvironment() && self.crypto) {
|
||||||
bytes = self.crypto.getRandomValues(new Uint8Array(numBytes));
|
bytes = new ArrayBuffer(numBytes);
|
||||||
bytes = Utils.arrayBufferToStr(bytes.buffer);
|
const CHUNK_SIZE = 65536;
|
||||||
|
for (let i = 0; i < numBytes; i += CHUNK_SIZE) {
|
||||||
|
self.crypto.getRandomValues(new Uint8Array(bytes, i, Math.min(numBytes - i, CHUNK_SIZE)));
|
||||||
|
}
|
||||||
|
bytes = Utils.arrayBufferToStr(bytes);
|
||||||
} else {
|
} else {
|
||||||
bytes = forge.random.getBytesSync(numBytes);
|
bytes = forge.random.getBytesSync(numBytes);
|
||||||
}
|
}
|
||||||
|
|||||||
102
src/core/operations/ROT13BruteForce.mjs
Normal file
102
src/core/operations/ROT13BruteForce.mjs
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
/**
|
||||||
|
* @author MikeCAT
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Operation from "../Operation.mjs";
|
||||||
|
import Utils from "../Utils.mjs";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ROT13 Brute Force operation.
|
||||||
|
*/
|
||||||
|
class ROT13BruteForce extends Operation {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ROT13BruteForce constructor
|
||||||
|
*/
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.name = "ROT13 Brute Force";
|
||||||
|
this.module = "Default";
|
||||||
|
this.description = "Try all meaningful amounts for ROT13.<br><br>Optionally you can enter your known plaintext (crib) to filter the result.";
|
||||||
|
this.infoURL = "https://wikipedia.org/wiki/ROT13";
|
||||||
|
this.inputType = "byteArray";
|
||||||
|
this.outputType = "string";
|
||||||
|
this.args = [
|
||||||
|
{
|
||||||
|
name: "Rotate lower case chars",
|
||||||
|
type: "boolean",
|
||||||
|
value: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Rotate upper case chars",
|
||||||
|
type: "boolean",
|
||||||
|
value: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Rotate numbers",
|
||||||
|
type: "boolean",
|
||||||
|
value: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Sample length",
|
||||||
|
type: "number",
|
||||||
|
value: 100
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Sample offset",
|
||||||
|
type: "number",
|
||||||
|
value: 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Print amount",
|
||||||
|
type: "boolean",
|
||||||
|
value: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Crib (known plaintext string)",
|
||||||
|
type: "string",
|
||||||
|
value: ""
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {byteArray} input
|
||||||
|
* @param {Object[]} args
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
run(input, args) {
|
||||||
|
const [rotateLower, rotateUpper, rotateNum, sampleLength, sampleOffset, printAmount, crib] = args;
|
||||||
|
const sample = input.slice(sampleOffset, sampleOffset + sampleLength);
|
||||||
|
const cribLower = crib.toLowerCase();
|
||||||
|
const lowerStart = "a".charCodeAt(0), upperStart = "A".charCodeAt(0), numStart = "0".charCodeAt(0);
|
||||||
|
const result = [];
|
||||||
|
for (let amount = 1; amount < 26; amount++) {
|
||||||
|
const rotated = sample.slice();
|
||||||
|
for (let i = 0; i < rotated.length; i++) {
|
||||||
|
if (rotateLower && lowerStart <= rotated[i] && rotated[i] < lowerStart + 26) {
|
||||||
|
rotated[i] = (rotated[i] - lowerStart + amount) % 26 + lowerStart;
|
||||||
|
} else if (rotateUpper && upperStart <= rotated[i] && rotated[i] < upperStart + 26) {
|
||||||
|
rotated[i] = (rotated[i] - upperStart + amount) % 26 + upperStart;
|
||||||
|
} else if (rotateNum && numStart <= rotated[i] && rotated[i] < numStart + 10) {
|
||||||
|
rotated[i] = (rotated[i] - numStart + amount) % 10 + numStart;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const rotatedString = Utils.byteArrayToUtf8(rotated);
|
||||||
|
if (rotatedString.toLowerCase().indexOf(cribLower) >= 0) {
|
||||||
|
const rotatedStringPrintable = Utils.printable(rotatedString, false);
|
||||||
|
if (printAmount) {
|
||||||
|
const amountStr = "Amount = " + (" " + amount).slice(-2) + ": ";
|
||||||
|
result.push(amountStr + rotatedStringPrintable);
|
||||||
|
} else {
|
||||||
|
result.push(rotatedStringPrintable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result.join("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ROT13BruteForce;
|
||||||
82
src/core/operations/ROT47BruteForce.mjs
Normal file
82
src/core/operations/ROT47BruteForce.mjs
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
/**
|
||||||
|
* @author MikeCAT
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Operation from "../Operation.mjs";
|
||||||
|
import Utils from "../Utils.mjs";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ROT47 Brute Force operation.
|
||||||
|
*/
|
||||||
|
class ROT47BruteForce extends Operation {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ROT47BruteForce constructor
|
||||||
|
*/
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.name = "ROT47 Brute Force";
|
||||||
|
this.module = "Default";
|
||||||
|
this.description = "Try all meaningful amounts for ROT47.<br><br>Optionally you can enter your known plaintext (crib) to filter the result.";
|
||||||
|
this.infoURL = "https://wikipedia.org/wiki/ROT13#Variants";
|
||||||
|
this.inputType = "byteArray";
|
||||||
|
this.outputType = "string";
|
||||||
|
this.args = [
|
||||||
|
{
|
||||||
|
name: "Sample length",
|
||||||
|
type: "number",
|
||||||
|
value: 100
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Sample offset",
|
||||||
|
type: "number",
|
||||||
|
value: 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Print amount",
|
||||||
|
type: "boolean",
|
||||||
|
value: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Crib (known plaintext string)",
|
||||||
|
type: "string",
|
||||||
|
value: ""
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {byteArray} input
|
||||||
|
* @param {Object[]} args
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
run(input, args) {
|
||||||
|
const [sampleLength, sampleOffset, printAmount, crib] = args;
|
||||||
|
const sample = input.slice(sampleOffset, sampleOffset + sampleLength);
|
||||||
|
const cribLower = crib.toLowerCase();
|
||||||
|
const result = [];
|
||||||
|
for (let amount = 1; amount < 94; amount++) {
|
||||||
|
const rotated = sample.slice();
|
||||||
|
for (let i = 0; i < rotated.length; i++) {
|
||||||
|
if (33 <= rotated[i] && rotated[i] <= 126) {
|
||||||
|
rotated[i] = (rotated[i] - 33 + amount) % 94 + 33;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const rotatedString = Utils.byteArrayToUtf8(rotated);
|
||||||
|
if (rotatedString.toLowerCase().indexOf(cribLower) >= 0) {
|
||||||
|
const rotatedStringPrintable = Utils.printable(rotatedString, false);
|
||||||
|
if (printAmount) {
|
||||||
|
const amountStr = "Amount = " + (" " + amount).slice(-2) + ": ";
|
||||||
|
result.push(amountStr + rotatedStringPrintable);
|
||||||
|
} else {
|
||||||
|
result.push(rotatedStringPrintable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result.join("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ROT47BruteForce;
|
||||||
123
src/core/operations/ROT8000.mjs
Normal file
123
src/core/operations/ROT8000.mjs
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
/**
|
||||||
|
* @author Daniel Temkin [http://danieltemkin.com]
|
||||||
|
* @author Thomas Leplus [https://www.leplus.org]
|
||||||
|
* @copyright Crown Copyright 2021
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Operation from "../Operation.mjs";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ROT8000 operation.
|
||||||
|
*/
|
||||||
|
class ROT8000 extends Operation {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ROT8000 constructor
|
||||||
|
*/
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
this.name = "ROT8000";
|
||||||
|
this.module = "Default";
|
||||||
|
this.description = "The simple Caesar-cypher encryption that replaces each Unicode character with the one 0x8000 places forward or back along the alphabet.";
|
||||||
|
this.infoURL = "https://rot8000.com/info";
|
||||||
|
this.inputType = "string";
|
||||||
|
this.outputType = "string";
|
||||||
|
this.args = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {byteArray} input
|
||||||
|
* @param {Object[]} args
|
||||||
|
* @returns {byteArray}
|
||||||
|
*/
|
||||||
|
run(input, args) {
|
||||||
|
// Inspired from https://github.com/rottytooth/rot8000/blob/main/rot8000.js
|
||||||
|
// these come from the valid-code-point-transitions.json file generated from the c# proj
|
||||||
|
// this is done bc: 1) don't trust JS's understanging of surrogate pairs and 2) consistency with original rot8000
|
||||||
|
const validCodePoints = {
|
||||||
|
"33": true,
|
||||||
|
"127": false,
|
||||||
|
"161": true,
|
||||||
|
"5760": false,
|
||||||
|
"5761": true,
|
||||||
|
"8192": false,
|
||||||
|
"8203": true,
|
||||||
|
"8232": false,
|
||||||
|
"8234": true,
|
||||||
|
"8239": false,
|
||||||
|
"8240": true,
|
||||||
|
"8287": false,
|
||||||
|
"8288": true,
|
||||||
|
"12288": false,
|
||||||
|
"12289": true,
|
||||||
|
"55296": false,
|
||||||
|
"57344": true
|
||||||
|
};
|
||||||
|
const bmpSize = 0x10000;
|
||||||
|
const rotList = {}; // the mapping of char to rotated char
|
||||||
|
const hiddenBlocks = [];
|
||||||
|
let startBlock = 0;
|
||||||
|
for (const key in validCodePoints) {
|
||||||
|
if (Object.prototype.hasOwnProperty.call(validCodePoints, key)) {
|
||||||
|
if (validCodePoints[key] === true)
|
||||||
|
hiddenBlocks.push({ start: startBlock, end: parseInt(key, 10) - 1 });
|
||||||
|
else
|
||||||
|
startBlock = parseInt(key, 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const validIntList = []; // list of all valid chars
|
||||||
|
let currValid = false;
|
||||||
|
for (let i = 0; i < bmpSize; i++) {
|
||||||
|
if (validCodePoints[i] !== undefined) {
|
||||||
|
currValid = validCodePoints[i];
|
||||||
|
}
|
||||||
|
if (currValid) validIntList.push(i);
|
||||||
|
}
|
||||||
|
const rotateNum = Object.keys(validIntList).length / 2;
|
||||||
|
// go through every valid char and find its match
|
||||||
|
for (let i = 0; i < validIntList.length; i++) {
|
||||||
|
rotList[String.fromCharCode(validIntList[i])] =
|
||||||
|
String.fromCharCode(validIntList[(i + rotateNum) % (rotateNum * 2)]);
|
||||||
|
}
|
||||||
|
let output = "";
|
||||||
|
for (let count = 0; count < input.length; count++) {
|
||||||
|
// if it is not in the mappings list, just add it directly (no rotation)
|
||||||
|
if (rotList[input[count]] === undefined) {
|
||||||
|
output += input[count];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// otherwise, rotate it and add it to the string
|
||||||
|
output += rotList[input[count]];
|
||||||
|
}
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Highlight ROT8000
|
||||||
|
*
|
||||||
|
* @param {Object[]} pos
|
||||||
|
* @param {number} pos[].start
|
||||||
|
* @param {number} pos[].end
|
||||||
|
* @param {Object[]} args
|
||||||
|
* @returns {Object[]} pos
|
||||||
|
*/
|
||||||
|
highlight(pos, args) {
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Highlight ROT8000 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 ROT8000;
|
||||||
@@ -7,7 +7,6 @@
|
|||||||
import Operation from "../Operation.mjs";
|
import Operation from "../Operation.mjs";
|
||||||
import {INFLATE_BUFFER_TYPE} from "../lib/Zlib.mjs";
|
import {INFLATE_BUFFER_TYPE} from "../lib/Zlib.mjs";
|
||||||
import rawinflate from "zlibjs/bin/rawinflate.min.js";
|
import rawinflate from "zlibjs/bin/rawinflate.min.js";
|
||||||
import OperationError from "../errors/OperationError.mjs";
|
|
||||||
|
|
||||||
const Zlib = rawinflate.Zlib;
|
const Zlib = rawinflate.Zlib;
|
||||||
|
|
||||||
@@ -83,25 +82,6 @@ class RawInflate extends Operation {
|
|||||||
}),
|
}),
|
||||||
result = new Uint8Array(inflate.decompress());
|
result = new Uint8Array(inflate.decompress());
|
||||||
|
|
||||||
// Raw Inflate sometimes messes up and returns nonsense like this:
|
|
||||||
// ]....]....]....]....]....]....]....]....]....]....]....]....]....]...
|
|
||||||
// e.g. Input data of [8b, 1d, dc, 44]
|
|
||||||
// Look for the first two square brackets:
|
|
||||||
if (result.length > 158 && result[0] === 93 && result[5] === 93) {
|
|
||||||
// If the first two square brackets are there, check that the others
|
|
||||||
// are also there. If they are, throw an error. If not, continue.
|
|
||||||
let valid = false;
|
|
||||||
for (let i = 0; i < 155; i += 5) {
|
|
||||||
if (result[i] !== 93) {
|
|
||||||
valid = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!valid) {
|
|
||||||
throw new OperationError("Error: Unable to inflate data");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// This seems to be the easiest way...
|
|
||||||
return result.buffer;
|
return result.buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import Operation from "../Operation.mjs";
|
import Operation from "../Operation.mjs";
|
||||||
|
import Utils from "../Utils.mjs";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reverse operation
|
* Reverse operation
|
||||||
@@ -26,7 +27,8 @@ class Reverse extends Operation {
|
|||||||
{
|
{
|
||||||
"name": "By",
|
"name": "By",
|
||||||
"type": "option",
|
"type": "option",
|
||||||
"value": ["Character", "Line"]
|
"value": ["Byte", "Character", "Line"],
|
||||||
|
"defaultIndex": 1
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -57,6 +59,24 @@ class Reverse extends Operation {
|
|||||||
result.push(0x0a);
|
result.push(0x0a);
|
||||||
}
|
}
|
||||||
return result.slice(0, input.length);
|
return result.slice(0, input.length);
|
||||||
|
} else if (args[0] === "Character") {
|
||||||
|
const inputString = Utils.byteArrayToUtf8(input);
|
||||||
|
let result = "";
|
||||||
|
for (let i = inputString.length - 1; i >= 0; i--) {
|
||||||
|
const c = inputString.charCodeAt(i);
|
||||||
|
if (i > 0 && 0xdc00 <= c && c <= 0xdfff) {
|
||||||
|
const c2 = inputString.charCodeAt(i - 1);
|
||||||
|
if (0xd800 <= c2 && c2 <= 0xdbff) {
|
||||||
|
// surrogates
|
||||||
|
result += inputString.charAt(i - 1);
|
||||||
|
result += inputString.charAt(i);
|
||||||
|
i--;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result += inputString.charAt(i);
|
||||||
|
}
|
||||||
|
return Utils.strToUtf8ByteArray(result);
|
||||||
} else {
|
} else {
|
||||||
return input.reverse();
|
return input.reverse();
|
||||||
}
|
}
|
||||||
|
|||||||
78
src/core/operations/Shuffle.mjs
Normal file
78
src/core/operations/Shuffle.mjs
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
/**
|
||||||
|
* @author mikecat
|
||||||
|
* @copyright Crown Copyright 2022
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Operation from "../Operation.mjs";
|
||||||
|
import Utils from "../Utils.mjs";
|
||||||
|
import {INPUT_DELIM_OPTIONS} from "../lib/Delim.mjs";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shuffle operation
|
||||||
|
*/
|
||||||
|
class Shuffle extends Operation {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shuffle constructor
|
||||||
|
*/
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.name = "Shuffle";
|
||||||
|
this.module = "Default";
|
||||||
|
this.description = "Randomly reorders input elements.";
|
||||||
|
this.infoURL = "https://wikipedia.org/wiki/Shuffling";
|
||||||
|
this.inputType = "string";
|
||||||
|
this.outputType = "string";
|
||||||
|
this.args = [
|
||||||
|
{
|
||||||
|
name: "Delimiter",
|
||||||
|
type: "option",
|
||||||
|
value: INPUT_DELIM_OPTIONS
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} input
|
||||||
|
* @param {Object[]} args
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
run(input, args) {
|
||||||
|
const delim = Utils.charRep(args[0]);
|
||||||
|
if (input.length === 0) return input;
|
||||||
|
|
||||||
|
// return a random number in [0, 1)
|
||||||
|
const rng = (typeof crypto) !== "undefined" && crypto.getRandomValues ? (function() {
|
||||||
|
const buf = new Uint32Array(2);
|
||||||
|
return function() {
|
||||||
|
// generate 53-bit random integer: 21 + 32 bits
|
||||||
|
crypto.getRandomValues(buf);
|
||||||
|
const value = (buf[0] >>> (32 - 21)) * ((1 << 30) * 4) + buf[1];
|
||||||
|
return value / ((1 << 23) * (1 << 30));
|
||||||
|
};
|
||||||
|
})() : Math.random;
|
||||||
|
|
||||||
|
// return a random integer in [0, max)
|
||||||
|
const randint = function(max) {
|
||||||
|
return Math.floor(rng() * max);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Split input into shuffleable sections
|
||||||
|
const toShuffle = input.split(delim);
|
||||||
|
|
||||||
|
// shuffle elements
|
||||||
|
for (let i = toShuffle.length - 1; i > 0; i--) {
|
||||||
|
const idx = randint(i + 1);
|
||||||
|
const tmp = toShuffle[idx];
|
||||||
|
toShuffle[idx] = toShuffle[i];
|
||||||
|
toShuffle[i] = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
return toShuffle.join(delim);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Shuffle;
|
||||||
@@ -34,10 +34,50 @@ class Substitute extends Operation {
|
|||||||
"name": "Ciphertext",
|
"name": "Ciphertext",
|
||||||
"type": "binaryString",
|
"type": "binaryString",
|
||||||
"value": "XYZABCDEFGHIJKLMNOPQRSTUVW"
|
"value": "XYZABCDEFGHIJKLMNOPQRSTUVW"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Ignore case",
|
||||||
|
"type": "boolean",
|
||||||
|
"value": false
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert a single character using the dictionary, if ignoreCase is true then
|
||||||
|
* check in the dictionary for both upper and lower case versions of the character.
|
||||||
|
* In output the input character case is preserved.
|
||||||
|
* @param {string} char
|
||||||
|
* @param {Object} dict
|
||||||
|
* @param {boolean} ignoreCase
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
cipherSingleChar(char, dict, ignoreCase) {
|
||||||
|
if (!ignoreCase)
|
||||||
|
return dict[char] || char;
|
||||||
|
|
||||||
|
const isUpperCase = char === char.toUpperCase();
|
||||||
|
|
||||||
|
// convert using the dictionary keeping the case of the input character
|
||||||
|
|
||||||
|
if (dict[char] !== undefined) {
|
||||||
|
// if the character is in the dictionary return the value with the input case
|
||||||
|
return isUpperCase ? dict[char].toUpperCase() : dict[char].toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
// check for the other case, if it is in the dictionary return the value with the right case
|
||||||
|
if (isUpperCase) {
|
||||||
|
if (dict[char.toLowerCase()] !== undefined)
|
||||||
|
return dict[char.toLowerCase()].toUpperCase();
|
||||||
|
} else {
|
||||||
|
if (dict[char.toUpperCase()] !== undefined)
|
||||||
|
return dict[char.toUpperCase()].toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
return char;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} input
|
* @param {string} input
|
||||||
* @param {Object[]} args
|
* @param {Object[]} args
|
||||||
@@ -45,17 +85,23 @@ class Substitute extends Operation {
|
|||||||
*/
|
*/
|
||||||
run(input, args) {
|
run(input, args) {
|
||||||
const plaintext = Utils.expandAlphRange([...args[0]]),
|
const plaintext = Utils.expandAlphRange([...args[0]]),
|
||||||
ciphertext = Utils.expandAlphRange([...args[1]]);
|
ciphertext = Utils.expandAlphRange([...args[1]]),
|
||||||
let output = "",
|
ignoreCase = args[2];
|
||||||
index = -1;
|
let output = "";
|
||||||
|
|
||||||
if (plaintext.length !== ciphertext.length) {
|
if (plaintext.length !== ciphertext.length) {
|
||||||
output = "Warning: Plaintext and Ciphertext lengths differ\n\n";
|
output = "Warning: Plaintext and Ciphertext lengths differ\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// create dictionary for conversion
|
||||||
|
const dict = {};
|
||||||
|
for (let i = 0; i < Math.min(ciphertext.length, plaintext.length); i++) {
|
||||||
|
dict[plaintext[i]] = ciphertext[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
// map every letter with the conversion function
|
||||||
for (const character of input) {
|
for (const character of input) {
|
||||||
index = plaintext.indexOf(character);
|
output += this.cipherSingleChar(character, dict, ignoreCase);
|
||||||
output += index > -1 && index < ciphertext.length ? ciphertext[index] : character;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ class TripleDESDecrypt extends Operation {
|
|||||||
inputType = args[3],
|
inputType = args[3],
|
||||||
outputType = args[4];
|
outputType = args[4];
|
||||||
|
|
||||||
if (key.length !== 24) {
|
if (key.length !== 24 && key.length !== 16) {
|
||||||
throw new OperationError(`Invalid key length: ${key.length} bytes
|
throw new OperationError(`Invalid key length: ${key.length} bytes
|
||||||
|
|
||||||
Triple DES uses a key length of 24 bytes (192 bits).
|
Triple DES uses a key length of 24 bytes (192 bits).
|
||||||
@@ -85,7 +85,8 @@ Make sure you have specified the type correctly (e.g. Hex vs UTF8).`);
|
|||||||
|
|
||||||
input = Utils.convertToByteString(input, inputType);
|
input = Utils.convertToByteString(input, inputType);
|
||||||
|
|
||||||
const decipher = forge.cipher.createDecipher("3DES-" + mode, key);
|
const decipher = forge.cipher.createDecipher("3DES-" + mode,
|
||||||
|
key.length === 16 ? key + key.substring(0, 8) : key);
|
||||||
|
|
||||||
/* Allow for a "no padding" mode */
|
/* Allow for a "no padding" mode */
|
||||||
if (noPadding) {
|
if (noPadding) {
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ class TripleDESEncrypt extends Operation {
|
|||||||
inputType = args[3],
|
inputType = args[3],
|
||||||
outputType = args[4];
|
outputType = args[4];
|
||||||
|
|
||||||
if (key.length !== 24) {
|
if (key.length !== 24 && key.length !== 16) {
|
||||||
throw new OperationError(`Invalid key length: ${key.length} bytes
|
throw new OperationError(`Invalid key length: ${key.length} bytes
|
||||||
|
|
||||||
Triple DES uses a key length of 24 bytes (192 bits).
|
Triple DES uses a key length of 24 bytes (192 bits).
|
||||||
@@ -84,7 +84,8 @@ Make sure you have specified the type correctly (e.g. Hex vs UTF8).`);
|
|||||||
|
|
||||||
input = Utils.convertToByteString(input, inputType);
|
input = Utils.convertToByteString(input, inputType);
|
||||||
|
|
||||||
const cipher = forge.cipher.createCipher("3DES-" + mode, key);
|
const cipher = forge.cipher.createCipher("3DES-" + mode,
|
||||||
|
key.length === 16 ? key + key.substring(0, 8) : key);
|
||||||
cipher.start({iv: iv});
|
cipher.start({iv: iv});
|
||||||
cipher.update(forge.util.createBuffer(input));
|
cipher.update(forge.util.createBuffer(input));
|
||||||
cipher.finish();
|
cipher.finish();
|
||||||
|
|||||||
@@ -79,6 +79,9 @@ class UNIXTimestampToWindowsFiletime extends Operation {
|
|||||||
flipped += result.charAt(i);
|
flipped += result.charAt(i);
|
||||||
flipped += result.charAt(i + 1);
|
flipped += result.charAt(i + 1);
|
||||||
}
|
}
|
||||||
|
if (result.length % 2 !== 0) {
|
||||||
|
flipped += "0" + result.charAt(0);
|
||||||
|
}
|
||||||
result = flipped;
|
result = flipped;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ class ViewBitPlane extends Operation {
|
|||||||
* @returns {html}
|
* @returns {html}
|
||||||
*/
|
*/
|
||||||
present(data) {
|
present(data) {
|
||||||
if (!data.length) return "";
|
if (!data.byteLength) return "";
|
||||||
const type = isImage(data);
|
const type = isImage(data);
|
||||||
|
|
||||||
return `<img src="data:${type};base64,${toBase64(data)}">`;
|
return `<img src="data:${type};base64,${toBase64(data)}">`;
|
||||||
|
|||||||
@@ -52,7 +52,10 @@ class WindowsFiletimeToUNIXTimestamp extends Operation {
|
|||||||
if (format === "Hex (little endian)") {
|
if (format === "Hex (little endian)") {
|
||||||
// Swap endianness
|
// Swap endianness
|
||||||
let result = "";
|
let result = "";
|
||||||
for (let i = input.length - 2; i >= 0; i -= 2) {
|
if (input.length % 2 !== 0) {
|
||||||
|
result += input.charAt(input.length - 1);
|
||||||
|
}
|
||||||
|
for (let i = input.length - input.length % 2 - 2; i >= 0; i -= 2) {
|
||||||
result += input.charAt(i);
|
result += input.charAt(i);
|
||||||
result += input.charAt(i + 1);
|
result += input.charAt(i + 1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,17 @@ class YARARules extends Operation {
|
|||||||
name: "Show counts",
|
name: "Show counts",
|
||||||
type: "boolean",
|
type: "boolean",
|
||||||
value: true
|
value: true
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
name: "Show rule warnings",
|
||||||
|
type: "boolean",
|
||||||
|
value: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Show console module messages",
|
||||||
|
type: "boolean",
|
||||||
|
value: true
|
||||||
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,7 +74,7 @@ class YARARules extends Operation {
|
|||||||
async run(input, args) {
|
async run(input, args) {
|
||||||
if (isWorkerEnvironment())
|
if (isWorkerEnvironment())
|
||||||
self.sendStatusMessage("Instantiating YARA...");
|
self.sendStatusMessage("Instantiating YARA...");
|
||||||
const [rules, showStrings, showLengths, showMeta, showCounts] = args;
|
const [rules, showStrings, showLengths, showMeta, showCounts, showRuleWarns, showConsole] = args;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
Yara().then(yara => {
|
Yara().then(yara => {
|
||||||
if (isWorkerEnvironment()) self.sendStatusMessage("Converting data for YARA.");
|
if (isWorkerEnvironment()) self.sendStatusMessage("Converting data for YARA.");
|
||||||
@@ -83,11 +93,19 @@ class YARARules extends Operation {
|
|||||||
const compileError = resp.compileErrors.get(i);
|
const compileError = resp.compileErrors.get(i);
|
||||||
if (!compileError.warning) {
|
if (!compileError.warning) {
|
||||||
reject(new OperationError(`Error on line ${compileError.lineNumber}: ${compileError.message}`));
|
reject(new OperationError(`Error on line ${compileError.lineNumber}: ${compileError.message}`));
|
||||||
} else {
|
} else if (showRuleWarns) {
|
||||||
matchString += `Warning on line ${compileError.lineNumber}: ${compileError.message}`;
|
matchString += `Warning on line ${compileError.lineNumber}: ${compileError.message}\n`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (showConsole) {
|
||||||
|
const consoleLogs = resp.consoleLogs;
|
||||||
|
for (let i = 0; i < consoleLogs.size(); i++) {
|
||||||
|
matchString += consoleLogs.get(i) + "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const matchedRules = resp.matchedRules;
|
const matchedRules = resp.matchedRules;
|
||||||
for (let i = 0; i < matchedRules.size(); i++) {
|
for (let i = 0; i < matchedRules.size(); i++) {
|
||||||
const rule = matchedRules.get(i);
|
const rule = matchedRules.get(i);
|
||||||
@@ -100,11 +118,11 @@ class YARARules extends Operation {
|
|||||||
}
|
}
|
||||||
meta = meta.slice(0, -2) + "]";
|
meta = meta.slice(0, -2) + "]";
|
||||||
}
|
}
|
||||||
const countString = showCounts ? `${matches.size()} time${matches.size() > 1 ? "s" : ""}` : "";
|
const countString = matches.size() === 0 ? "" : (showCounts ? ` (${matches.size()} time${matches.size() > 1 ? "s" : ""})` : "");
|
||||||
if (matches.size() === 0 || !(showStrings || showLengths)) {
|
if (matches.size() === 0 || !(showStrings || showLengths)) {
|
||||||
matchString += `Input matches rule "${rule.ruleName}"${meta}${countString.length > 0 ? ` ${countString}`: ""}.\n`;
|
matchString += `Input matches rule "${rule.ruleName}"${meta}${countString.length > 0 ? ` ${countString}`: ""}.\n`;
|
||||||
} else {
|
} else {
|
||||||
matchString += `Rule "${rule.ruleName}"${meta} matches (${countString}):\n`;
|
matchString += `Rule "${rule.ruleName}"${meta} matches${countString}:\n`;
|
||||||
for (let j = 0; j < matches.size(); j++) {
|
for (let j = 0; j < matches.size(); j++) {
|
||||||
const match = matches.get(j);
|
const match = matches.get(j);
|
||||||
if (showStrings || showLengths) {
|
if (showStrings || showLengths) {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
import "highlight.js/styles/vs.css";
|
import "highlight.js/styles/vs.css";
|
||||||
|
|
||||||
/* Frameworks */
|
/* Frameworks */
|
||||||
import "./vendors/bootstrap.scss";
|
import "bootstrap-material-design/dist/css/bootstrap-material-design.css";
|
||||||
import "bootstrap-colorpicker/dist/css/bootstrap-colorpicker.css";
|
import "bootstrap-colorpicker/dist/css/bootstrap-colorpicker.css";
|
||||||
|
|
||||||
/* CyberChef styles */
|
/* CyberChef styles */
|
||||||
|
|||||||
@@ -82,7 +82,17 @@ a:focus {
|
|||||||
border-color: var(--btn-success-hover-border-colour);
|
border-color: var(--btn-success-hover-border-colour);
|
||||||
}
|
}
|
||||||
|
|
||||||
select.form-control:not([size]):not([multiple]), select.custom-file-control:not([size]):not([multiple]) {
|
select.form-control,
|
||||||
|
select.form-control:focus {
|
||||||
|
background-color: var(--primary-background-colour) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
select.form-control:focus {
|
||||||
|
transition: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
select.form-control:not([size]):not([multiple]),
|
||||||
|
select.custom-file-control:not([size]):not([multiple]) {
|
||||||
height: unset !important;
|
height: unset !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,7 +155,8 @@ optgroup {
|
|||||||
color: var(--primary-font-colour);
|
color: var(--primary-font-colour);
|
||||||
}
|
}
|
||||||
|
|
||||||
.table-bordered th, .table-bordered td {
|
.table-bordered th,
|
||||||
|
.table-bordered td {
|
||||||
border: 1px solid var(--table-border-colour);
|
border: 1px solid var(--table-border-colour);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,7 +183,9 @@ optgroup {
|
|||||||
color: var(--subtext-font-colour);
|
color: var(--subtext-font-colour);
|
||||||
}
|
}
|
||||||
|
|
||||||
.nav-tabs>li>a.nav-link.active, .nav-tabs>li>a.nav-link.active:focus, .nav-tabs>li>a.nav-link.active:hover {
|
.nav-tabs>li>a.nav-link.active,
|
||||||
|
.nav-tabs>li>a.nav-link.active:focus,
|
||||||
|
.nav-tabs>li>a.nav-link.active:hover {
|
||||||
background-color: var(--secondary-background-colour);
|
background-color: var(--secondary-background-colour);
|
||||||
border-color: var(--secondary-border-colour);
|
border-color: var(--secondary-border-colour);
|
||||||
border-bottom-color: transparent;
|
border-bottom-color: transparent;
|
||||||
@@ -183,7 +196,8 @@ optgroup {
|
|||||||
border-color: var(--primary-border-colour);
|
border-color: var(--primary-border-colour);
|
||||||
}
|
}
|
||||||
|
|
||||||
.nav a.nav-link:focus, .nav a.nav-link:hover {
|
.nav a.nav-link:focus,
|
||||||
|
.nav a.nav-link:hover {
|
||||||
background-color: var(--secondary-border-colour);
|
background-color: var(--secondary-border-colour);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,7 +213,8 @@ optgroup {
|
|||||||
color: var(--primary-font-colour);
|
color: var(--primary-font-colour);
|
||||||
}
|
}
|
||||||
|
|
||||||
.dropdown-menu a:focus, .dropdown-menu a:hover {
|
.dropdown-menu a:focus,
|
||||||
|
.dropdown-menu a:hover {
|
||||||
background-color: var(--secondary-background-colour);
|
background-color: var(--secondary-background-colour);
|
||||||
color: var(--primary-font-colour);
|
color: var(--primary-font-colour);
|
||||||
}
|
}
|
||||||
|
|||||||
23
src/web/stylesheets/vendors/bootstrap.scss
vendored
23
src/web/stylesheets/vendors/bootstrap.scss
vendored
@@ -1,23 +0,0 @@
|
|||||||
/**
|
|
||||||
* Bootstrap Material Design with overrides
|
|
||||||
*
|
|
||||||
* @author n1474335 [n1474335@gmail.com]
|
|
||||||
* @copyright Crown Copyright 2018
|
|
||||||
* @license Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
@import "~bootstrap-material-design/scss/variables/colors";
|
|
||||||
|
|
||||||
$theme-colors: (
|
|
||||||
primary: $blue-700,
|
|
||||||
success: $green,
|
|
||||||
info: $light-blue,
|
|
||||||
warning: $deep-orange,
|
|
||||||
danger: $red,
|
|
||||||
light: $grey-100,
|
|
||||||
dark: $grey-800
|
|
||||||
);
|
|
||||||
|
|
||||||
$bmd-form-line-height: 1.25;
|
|
||||||
|
|
||||||
@import "~bootstrap-material-design/scss/core";
|
|
||||||
@@ -249,6 +249,7 @@ module.exports = {
|
|||||||
// testOp(browser, "RIPEMD", "test input", "test_output");
|
// testOp(browser, "RIPEMD", "test input", "test_output");
|
||||||
// testOp(browser, "ROT13", "test input", "test_output");
|
// testOp(browser, "ROT13", "test input", "test_output");
|
||||||
// testOp(browser, "ROT47", "test input", "test_output");
|
// testOp(browser, "ROT47", "test input", "test_output");
|
||||||
|
// testOp(browser, "ROT8000", "test input", "test_output");
|
||||||
// testOp(browser, "Rail Fence Cipher Decode", "test input", "test_output");
|
// testOp(browser, "Rail Fence Cipher Decode", "test input", "test_output");
|
||||||
// testOp(browser, "Rail Fence Cipher Encode", "test input", "test_output");
|
// testOp(browser, "Rail Fence Cipher Encode", "test input", "test_output");
|
||||||
// testOp(browser, "Randomize Colour Palette", "test input", "test_output");
|
// testOp(browser, "Randomize Colour Palette", "test input", "test_output");
|
||||||
|
|||||||
@@ -45,10 +45,10 @@ TestRegister.addApiTests([
|
|||||||
const result = chef.ADD("sample input", {
|
const result = chef.ADD("sample input", {
|
||||||
key: {
|
key: {
|
||||||
string: "some key",
|
string: "some key",
|
||||||
option: "Hex"
|
option: "utf8"
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
assert.equal(result.toString(), "aO[^ZS\u000eW\\^cb");
|
assert.equal(result.toString(), "\xe6\xd0\xda\xd5\x8c\xd0\x85\xe2\xe1\xdf\xe2\xd9");
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
|
||||||
@@ -121,10 +121,10 @@ Tiger-128`;
|
|||||||
const result = chef.AND("Scot-free", {
|
const result = chef.AND("Scot-free", {
|
||||||
key: {
|
key: {
|
||||||
string: "Raining Cats and Dogs",
|
string: "Raining Cats and Dogs",
|
||||||
option: "Hex",
|
option: "utf8",
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
assert.strictEqual(result.toString(), "\u0000\"M$(D E");
|
assert.strictEqual(result.toString(), "Raid)fb A");
|
||||||
}),
|
}),
|
||||||
|
|
||||||
it("atBash Cipher", () => {
|
it("atBash Cipher", () => {
|
||||||
@@ -371,10 +371,10 @@ color: white;
|
|||||||
},
|
},
|
||||||
salt: {
|
salt: {
|
||||||
string: "Market",
|
string: "Market",
|
||||||
option: "Hex",
|
option: "utf8",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
assert.strictEqual(result.toString(), "7c21a9f5063a4d62fb1050068245c181");
|
assert.strictEqual(result.toString(), "4930d5d200e80f18c96b5550d13c6af8");
|
||||||
}),
|
}),
|
||||||
|
|
||||||
it("Derive PBKDF2 Key", () => {
|
it("Derive PBKDF2 Key", () => {
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ import "./tests/Base85.mjs";
|
|||||||
import "./tests/BitwiseOp.mjs";
|
import "./tests/BitwiseOp.mjs";
|
||||||
import "./tests/ByteRepr.mjs";
|
import "./tests/ByteRepr.mjs";
|
||||||
import "./tests/CartesianProduct.mjs";
|
import "./tests/CartesianProduct.mjs";
|
||||||
|
import "./tests/CetaceanCipherEncode.mjs";
|
||||||
|
import "./tests/CetaceanCipherDecode.mjs";
|
||||||
import "./tests/CharEnc.mjs";
|
import "./tests/CharEnc.mjs";
|
||||||
import "./tests/ChangeIPFormat.mjs";
|
import "./tests/ChangeIPFormat.mjs";
|
||||||
import "./tests/Charts.mjs";
|
import "./tests/Charts.mjs";
|
||||||
@@ -43,6 +45,7 @@ import "./tests/DateTime.mjs";
|
|||||||
import "./tests/ExtractEmailAddresses.mjs";
|
import "./tests/ExtractEmailAddresses.mjs";
|
||||||
import "./tests/Fork.mjs";
|
import "./tests/Fork.mjs";
|
||||||
import "./tests/FromDecimal.mjs";
|
import "./tests/FromDecimal.mjs";
|
||||||
|
import "./tests/GenerateAllHashes.mjs";
|
||||||
import "./tests/Gzip.mjs";
|
import "./tests/Gzip.mjs";
|
||||||
import "./tests/Gunzip.mjs";
|
import "./tests/Gunzip.mjs";
|
||||||
import "./tests/Hash.mjs";
|
import "./tests/Hash.mjs";
|
||||||
@@ -116,7 +119,12 @@ import "./tests/GetAllCasings.mjs";
|
|||||||
import "./tests/SIGABA.mjs";
|
import "./tests/SIGABA.mjs";
|
||||||
import "./tests/ELFInfo.mjs";
|
import "./tests/ELFInfo.mjs";
|
||||||
import "./tests/Subsection.mjs";
|
import "./tests/Subsection.mjs";
|
||||||
|
import "./tests/CaesarBoxCipher.mjs";
|
||||||
|
import "./tests/UnescapeString.mjs";
|
||||||
|
import "./tests/LS47.mjs";
|
||||||
|
import "./tests/LZString.mjs";
|
||||||
|
import "./tests/NTLM.mjs";
|
||||||
|
import "./tests/Shuffle.mjs";
|
||||||
|
|
||||||
// Cannot test operations that use the File type yet
|
// Cannot test operations that use the File type yet
|
||||||
// import "./tests/SplitColourChannels.mjs";
|
// import "./tests/SplitColourChannels.mjs";
|
||||||
|
|||||||
45
tests/operations/tests/CaesarBoxCipher.mjs
Normal file
45
tests/operations/tests/CaesarBoxCipher.mjs
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
/**
|
||||||
|
* Caesar Box Cipher tests.
|
||||||
|
*
|
||||||
|
* @author n1073645 [n1073645@gmail.com]
|
||||||
|
*
|
||||||
|
* @copyright Crown Copyright 2020
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
import TestRegister from "../../lib/TestRegister.mjs";
|
||||||
|
|
||||||
|
TestRegister.addTests([
|
||||||
|
{
|
||||||
|
name: "Caesar Box Cipher: nothing",
|
||||||
|
input: "",
|
||||||
|
expectedOutput: "",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "Caesar Box Cipher",
|
||||||
|
args: ["1"],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Caesar Box Cipher: Hello World!",
|
||||||
|
input: "Hello World!",
|
||||||
|
expectedOutput: "Hlodeor!lWl",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "Caesar Box Cipher",
|
||||||
|
args: ["3"],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Caesar Box Cipher: Hello World!",
|
||||||
|
input: "Hlodeor!lWl",
|
||||||
|
expectedOutput: "HelloWorld!",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "Caesar Box Cipher",
|
||||||
|
args: ["4"],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
]);
|
||||||
22
tests/operations/tests/CetaceanCipherDecode.mjs
Normal file
22
tests/operations/tests/CetaceanCipherDecode.mjs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
/**
|
||||||
|
* CetaceanCipher Encode tests
|
||||||
|
*
|
||||||
|
* @author dolphinOnKeys
|
||||||
|
* @copyright Crown Copyright 2022
|
||||||
|
* @licence Apache-2.0
|
||||||
|
*/
|
||||||
|
import TestRegister from "../../lib/TestRegister.mjs";
|
||||||
|
|
||||||
|
TestRegister.addTests([
|
||||||
|
{
|
||||||
|
name: "Cetacean Cipher Decode",
|
||||||
|
input: "EEEEEEEEEeeEEEEe EEEEEEEEEeeEEEeE EEEEEEEEEeeEEEee EEeeEEEEEeeEEeee",
|
||||||
|
expectedOutput: "a b c で",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "Cetacean Cipher Decode",
|
||||||
|
args: []
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
]);
|
||||||
22
tests/operations/tests/CetaceanCipherEncode.mjs
Normal file
22
tests/operations/tests/CetaceanCipherEncode.mjs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
/**
|
||||||
|
* CetaceanCipher Encode tests
|
||||||
|
*
|
||||||
|
* @author dolphinOnKeys
|
||||||
|
* @copyright Crown Copyright 2022
|
||||||
|
* @licence Apache-2.0
|
||||||
|
*/
|
||||||
|
import TestRegister from "../../lib/TestRegister.mjs";
|
||||||
|
|
||||||
|
TestRegister.addTests([
|
||||||
|
{
|
||||||
|
name: "Cetacean Cipher Encode",
|
||||||
|
input: "a b c で",
|
||||||
|
expectedOutput: "EEEEEEEEEeeEEEEe EEEEEEEEEeeEEEeE EEEEEEEEEeeEEEee EEeeEEEEEeeEEeee",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "Cetacean Cipher Encode",
|
||||||
|
args: []
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
]);
|
||||||
@@ -185,11 +185,11 @@ TestRegister.addTests([
|
|||||||
{
|
{
|
||||||
name: "JPath Expression: Empty expression",
|
name: "JPath Expression: Empty expression",
|
||||||
input: JSON.stringify(JSON_TEST_DATA),
|
input: JSON.stringify(JSON_TEST_DATA),
|
||||||
expectedOutput: "Invalid JPath expression: we need a path",
|
expectedOutput: "",
|
||||||
recipeConfig: [
|
recipeConfig: [
|
||||||
{
|
{
|
||||||
"op": "JPath expression",
|
"op": "JPath expression",
|
||||||
"args": ["", "\n"]
|
"args": ["", "\n", true]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -205,7 +205,7 @@ TestRegister.addTests([
|
|||||||
recipeConfig: [
|
recipeConfig: [
|
||||||
{
|
{
|
||||||
"op": "JPath expression",
|
"op": "JPath expression",
|
||||||
"args": ["$.store.book[*].author", "\n"]
|
"args": ["$.store.book[*].author", "\n", true]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -223,7 +223,7 @@ TestRegister.addTests([
|
|||||||
recipeConfig: [
|
recipeConfig: [
|
||||||
{
|
{
|
||||||
"op": "JPath expression",
|
"op": "JPath expression",
|
||||||
"args": ["$..title", "\n"]
|
"args": ["$..title", "\n", true]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -238,7 +238,7 @@ TestRegister.addTests([
|
|||||||
recipeConfig: [
|
recipeConfig: [
|
||||||
{
|
{
|
||||||
"op": "JPath expression",
|
"op": "JPath expression",
|
||||||
"args": ["$.store.*", "\n"]
|
"args": ["$.store.*", "\n", true]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -249,7 +249,7 @@ TestRegister.addTests([
|
|||||||
recipeConfig: [
|
recipeConfig: [
|
||||||
{
|
{
|
||||||
"op": "JPath expression",
|
"op": "JPath expression",
|
||||||
"args": ["$..book[-1:]", "\n"]
|
"args": ["$..book[-1:]", "\n", true]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -263,7 +263,7 @@ TestRegister.addTests([
|
|||||||
recipeConfig: [
|
recipeConfig: [
|
||||||
{
|
{
|
||||||
"op": "JPath expression",
|
"op": "JPath expression",
|
||||||
"args": ["$..book[:2]", "\n"]
|
"args": ["$..book[:2]", "\n", true]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -277,7 +277,7 @@ TestRegister.addTests([
|
|||||||
recipeConfig: [
|
recipeConfig: [
|
||||||
{
|
{
|
||||||
"op": "JPath expression",
|
"op": "JPath expression",
|
||||||
"args": ["$..book[?(@.isbn)]", "\n"]
|
"args": ["$..book[?(@.isbn)]", "\n", false]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -292,7 +292,7 @@ TestRegister.addTests([
|
|||||||
recipeConfig: [
|
recipeConfig: [
|
||||||
{
|
{
|
||||||
"op": "JPath expression",
|
"op": "JPath expression",
|
||||||
"args": ["$..book[?(@.price<30 && @.category==\"fiction\")]", "\n"]
|
"args": ["$..book[?(@.price<30 && @.category==\"fiction\")]", "\n", false]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -306,10 +306,25 @@ TestRegister.addTests([
|
|||||||
recipeConfig: [
|
recipeConfig: [
|
||||||
{
|
{
|
||||||
"op": "JPath expression",
|
"op": "JPath expression",
|
||||||
"args": ["$..book[?(@.price<10)]", "\n"]
|
"args": ["$..book[?(@.price<10)]", "\n", false]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "JPath Expression: Script-based expression",
|
||||||
|
input: "[{}]",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "JPath expression",
|
||||||
|
"args": [
|
||||||
|
"$..[?(({__proto__:[].constructor}).constructor(\"self.postMessage({action:'bakeComplete',data:{bakeId:1,dish:{type:1,value:''},duration:1,error:false,id:undefined,inputNum:2,progress:1,result:'<iframe/onload=debugger>',type: 'html'}});\")();)]",
|
||||||
|
"\n",
|
||||||
|
true
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
expectedOutput: "Invalid JPath expression: Eval [?(expr)] prevented in JSONPath expression."
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "CSS selector",
|
name: "CSS selector",
|
||||||
input: '<div id="test">\n<p class="a">hello</p>\n<p>world</p>\n<p class="a">again</p>\n</div>',
|
input: '<div id="test">\n<p class="a">hello</p>\n<p>world</p>\n<p class="a">again</p>\n</div>',
|
||||||
|
|||||||
@@ -23,4 +23,86 @@ TestRegister.addTests([
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "LZMA compress & decompress",
|
||||||
|
input: "The cat sat on the mat.",
|
||||||
|
// Generated using command `echo -n "The cat sat on the mat." | lzma -z -6 | xxd -p`
|
||||||
|
expectedOutput: "The cat sat on the mat.",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "LZMA Compress",
|
||||||
|
"args": ["6"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"op": "LZMA Decompress",
|
||||||
|
"args": []
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "LZMA decompress: binary",
|
||||||
|
// Generated using command `echo "00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10" | xxd -r -p | lzma -z -6 | xxd -p`
|
||||||
|
input: "5d00008000ffffffffffffffff00000052500a84f99bb28021a969d627e03e8a922effffbd160000",
|
||||||
|
expectedOutput: "00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "From Hex",
|
||||||
|
"args": ["Space"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"op": "LZMA Decompress",
|
||||||
|
"args": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"op": "To Hex",
|
||||||
|
"args": ["Space", 0]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "LZMA decompress: string",
|
||||||
|
// Generated using command `echo -n "The cat sat on the mat." | lzma -z -6 | xxd -p`
|
||||||
|
input: "5d00008000ffffffffffffffff002a1a08a202b1a4b814b912c94c4152e1641907d3fd8cd903ffff4fec0000",
|
||||||
|
expectedOutput: "The cat sat on the mat.",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "From Hex",
|
||||||
|
"args": ["Space"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"op": "LZMA Decompress",
|
||||||
|
"args": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "LZ4 Compress",
|
||||||
|
input: "The cat sat on the mat.",
|
||||||
|
expectedOutput: "04224d184070df170000805468652063617420736174206f6e20746865206d61742e00000000",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "LZ4 Compress",
|
||||||
|
"args": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"op": "To Hex",
|
||||||
|
"args": ["None", 0]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "LZ4 Decompress",
|
||||||
|
input: "04224d184070df170000805468652063617420736174206f6e20746865206d61742e00000000",
|
||||||
|
expectedOutput: "The cat sat on the mat.",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "From Hex",
|
||||||
|
"args": ["None"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"op": "LZ4 Decompress",
|
||||||
|
"args": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
]);
|
]);
|
||||||
|
|||||||
115
tests/operations/tests/GenerateAllHashes.mjs
Normal file
115
tests/operations/tests/GenerateAllHashes.mjs
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
/**
|
||||||
|
* GenerateAllHashes tests.
|
||||||
|
*
|
||||||
|
* @author john19696 [john19696@protonmail.com]
|
||||||
|
* @copyright Crown Copyright 2022
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
import TestRegister from "../../lib/TestRegister.mjs";
|
||||||
|
|
||||||
|
TestRegister.addTests([
|
||||||
|
{
|
||||||
|
name: "Full generate all hashes",
|
||||||
|
input: "test",
|
||||||
|
expectedOutput: `MD2: dd34716876364a02d0195e2fb9ae2d1b
|
||||||
|
MD4: db346d691d7acc4dc2625db19f9e3f52
|
||||||
|
MD5: 098f6bcd4621d373cade4e832627b4f6
|
||||||
|
MD6: 93c8a7d0ff132f325138a82b2baa98c12a7c9ac982feb6c5b310a1ca713615bd
|
||||||
|
SHA0: f8d3b312442a67706057aeb45b983221afb4f035
|
||||||
|
SHA1: a94a8fe5ccb19ba61c4c0873d391e987982fbbd3
|
||||||
|
SHA2 224: 90a3ed9e32b2aaf4c61c410eb925426119e1a9dc53d4286ade99a809
|
||||||
|
SHA2 256: 9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08
|
||||||
|
SHA2 384: 768412320f7b0aa5812fce428dc4706b3cae50e02a64caa16a782249bfe8efc4b7ef1ccb126255d196047dfedf17a0a9
|
||||||
|
SHA2 512: ee26b0dd4af7e749aa1a8ee3c10ae9923f618980772e473f8819a5d4940e0db27ac185f8a0e1d5f84f88bc887fd67b143732c304cc5fa9ad8e6f57f50028a8ff
|
||||||
|
SHA3 224: 3797bf0afbbfca4a7bbba7602a2b552746876517a7f9b7ce2db0ae7b
|
||||||
|
SHA3 256: 36f028580bb02cc8272a9a020f4200e346e276ae664e45ee80745574e2f5ab80
|
||||||
|
SHA3 384: e516dabb23b6e30026863543282780a3ae0dccf05551cf0295178d7ff0f1b41eecb9db3ff219007c4e097260d58621bd
|
||||||
|
SHA3 512: 9ece086e9bac491fac5c1d1046ca11d737b92a2b2ebd93f005d7b710110c0a678288166e7fbe796883a4f2e9b3ca9f484f521d0ce464345cc1aec96779149c14
|
||||||
|
Keccak 224: 3be30a9ff64f34a5861116c5198987ad780165f8366e67aff4760b5e
|
||||||
|
Keccak 256: 9c22ff5f21f0b81b113e63f7db6da94fedef11b2119b4088b89664fb9a3cb658
|
||||||
|
Keccak 384: 53d0ba137307d4c2f9b6674c83edbd58b70c0f4340133ed0adc6fba1d2478a6a03b7788229e775d2de8ae8c0759d0527
|
||||||
|
Keccak 512: 1e2e9fc2002b002d75198b7503210c05a1baac4560916a3c6d93bcce3a50d7f00fd395bf1647b9abb8d1afcc9c76c289b0c9383ba386a956da4b38934417789e
|
||||||
|
Shake 128: d3b0aa9cd8b7255622cebc631e867d4093d6f6010191a53973c45fec9b07c774
|
||||||
|
Shake 256: b54ff7255705a71ee2925e4a3e30e41aed489a579d5595e0df13e32e1e4dd202a7c7f68b31d6418d9845eb4d757adda6ab189e1bb340db818e5b3bc725d992fa
|
||||||
|
RIPEMD-128: f1abb5083c9ff8a9dbbca9cd2b11fead
|
||||||
|
RIPEMD-160: 5e52fee47e6b070565f74372468cdc699de89107
|
||||||
|
RIPEMD-256: fe0289110d07daeee9d9500e14c57787d9083f6ba10e6bcb256f86bb4fe7b981
|
||||||
|
RIPEMD-320: 3b0a2e841e589cf583634a5dd265d2b5d497c4cc44b241e34e0f62d03e98c1b9dc72970b9bc20eb5
|
||||||
|
HAS-160: cb15e491eec6e769771d1f811315139c93071084
|
||||||
|
Whirlpool-0: d50ff71342b521974bae166539871922669afcfc7181250ebbae015c317ebb797173a69e7a05afd11099a9f0918159cd5bc88434d3ca44513d7263caea9244fe
|
||||||
|
Whirlpool-T: e6b4aa087751b4428171777f1893ba585404c7e0171787720eba0d8bccd710dc2c42f874c572bfae4cedabf50f2c80bf923805d4e31c504b86ca3bc59265e7dd
|
||||||
|
Whirlpool: b913d5bbb8e461c2c5961cbe0edcdadfd29f068225ceb37da6defcf89849368f8c6c2eb6a4c4ac75775d032a0ecfdfe8550573062b653fe92fc7b8fb3b7be8d6
|
||||||
|
BLAKE2b-128: 44a8995dd50b6657a037a7839304535b
|
||||||
|
BLAKE2b-160: a34fc3b6d2cce8beb3216c2bbb5e55739e8121ed
|
||||||
|
BLAKE2b-256: 928b20366943e2afd11ebc0eae2e53a93bf177a4fcf35bcc64d503704e65e202
|
||||||
|
BLAKE2b-384: 8a84b8666c8fcfb69f2ec41f578d7c85fbdb504ea6510fb05b50fcbf7ed8153c77943bc2da73abb136834e1a0d4f22cb
|
||||||
|
BLAKE2b-512: a71079d42853dea26e453004338670a53814b78137ffbed07603a41d76a483aa9bc33b582f77d30a65e6f29a896c0411f38312e1d66e0bf16386c86a89bea572
|
||||||
|
BLAKE2s-128: e9ddd9926b9dcb382e09be39ba403d2c
|
||||||
|
BLAKE2s-160: d6197dabec2bd6f4ff303b8e519e8f15d42a453d
|
||||||
|
BLAKE2s-256: f308fc02ce9172ad02a7d75800ecfc027109bc67987ea32aba9b8dcc7b10150e
|
||||||
|
Streebog-256: 12a50838191b5504f1e5f2fd078714cf6b592b9d29af99d0b10d8d02881c3857
|
||||||
|
Streebog-512: 7200bf5dea560f0d7960d07fdc8874ad9f3b86ece2e45f5502ae2e176f2c928e0e581152281f5aee818318bed7cbe6aa69999589234723ceb33175598365b5c8
|
||||||
|
GOST: ee67303696d205ddd2b2363e8e01b4b7199a80957d94d7678eaad3fc834c5a27
|
||||||
|
LM Hash: 01FC5A6BE7BC6929AAD3B435B51404EE
|
||||||
|
NT Hash: 0CB6948805F797BF2A82807973B89537
|
||||||
|
SSDEEP: 3:Hn:Hn
|
||||||
|
CTPH: A:E:E
|
||||||
|
|
||||||
|
Checksums:
|
||||||
|
Fletcher-8: 3d
|
||||||
|
Fletcher-16: 5dc1
|
||||||
|
Fletcher-32: 045901c0
|
||||||
|
Fletcher-64: 00000459000001c0
|
||||||
|
Adler-32: 045d01c1
|
||||||
|
CRC-8: b9
|
||||||
|
CRC-16: f82e
|
||||||
|
CRC-32: d87f7e0c
|
||||||
|
`,
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Generate all hashes",
|
||||||
|
"args": ["All", true]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Hashes with length 32",
|
||||||
|
input: "test",
|
||||||
|
expectedOutput: `MD2: dd34716876364a02d0195e2fb9ae2d1b
|
||||||
|
MD4: db346d691d7acc4dc2625db19f9e3f52
|
||||||
|
MD5: 098f6bcd4621d373cade4e832627b4f6
|
||||||
|
RIPEMD-128: f1abb5083c9ff8a9dbbca9cd2b11fead
|
||||||
|
BLAKE2b-128: 44a8995dd50b6657a037a7839304535b
|
||||||
|
BLAKE2s-128: e9ddd9926b9dcb382e09be39ba403d2c
|
||||||
|
LM Hash: 01FC5A6BE7BC6929AAD3B435B51404EE
|
||||||
|
NT Hash: 0CB6948805F797BF2A82807973B89537
|
||||||
|
`,
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Generate all hashes",
|
||||||
|
"args": ["128", true]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Hashes without names",
|
||||||
|
input: "test",
|
||||||
|
expectedOutput: `93c8a7d0ff132f325138a82b2baa98c12a7c9ac982feb6c5b310a1ca713615bd
|
||||||
|
9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08
|
||||||
|
36f028580bb02cc8272a9a020f4200e346e276ae664e45ee80745574e2f5ab80
|
||||||
|
9c22ff5f21f0b81b113e63f7db6da94fedef11b2119b4088b89664fb9a3cb658
|
||||||
|
d3b0aa9cd8b7255622cebc631e867d4093d6f6010191a53973c45fec9b07c774
|
||||||
|
fe0289110d07daeee9d9500e14c57787d9083f6ba10e6bcb256f86bb4fe7b981
|
||||||
|
928b20366943e2afd11ebc0eae2e53a93bf177a4fcf35bcc64d503704e65e202
|
||||||
|
f308fc02ce9172ad02a7d75800ecfc027109bc67987ea32aba9b8dcc7b10150e
|
||||||
|
12a50838191b5504f1e5f2fd078714cf6b592b9d29af99d0b10d8d02881c3857
|
||||||
|
ee67303696d205ddd2b2363e8e01b4b7199a80957d94d7678eaad3fc834c5a27
|
||||||
|
`,
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Generate all hashes",
|
||||||
|
"args": ["256", false]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]);
|
||||||
@@ -46,6 +46,17 @@ TestRegister.addTests([
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "JSON to CSV: boolean and null as values",
|
||||||
|
input: JSON.stringify({a: false, b: null, c: 3}),
|
||||||
|
expectedOutput: "a,b,c\r\nfalse,null,3\r\n",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "JSON to CSV",
|
||||||
|
args: [",", "\\r\\n"]
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "JSON to CSV: JSON as an array",
|
name: "JSON to CSV: JSON as an array",
|
||||||
input: JSON.stringify([{a: 1, b: "2", c: 3}]),
|
input: JSON.stringify([{a: 1, b: "2", c: 3}]),
|
||||||
|
|||||||
45
tests/operations/tests/LS47.mjs
Normal file
45
tests/operations/tests/LS47.mjs
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
/**
|
||||||
|
* LS47 tests.
|
||||||
|
*
|
||||||
|
* @author n1073645 [n1073645@gmail.com]
|
||||||
|
*
|
||||||
|
* @copyright Crown Copyright 2020
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
import TestRegister from "../../lib/TestRegister.mjs";
|
||||||
|
|
||||||
|
TestRegister.addTests([
|
||||||
|
{
|
||||||
|
name: "LS47 Encrypt",
|
||||||
|
input: "thequickbrownfoxjumped",
|
||||||
|
expectedOutput: "(,t74ci78cp/8trx*yesu:alp1wqy",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "LS47 Encrypt",
|
||||||
|
args: ["helloworld", 0, "test"],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "LS47 Decrypt",
|
||||||
|
input: "(,t74ci78cp/8trx*yesu:alp1wqy",
|
||||||
|
expectedOutput: "thequickbrownfoxjumped---test",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "LS47 Decrypt",
|
||||||
|
args: ["helloworld", 0],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "LS47 Encrypt",
|
||||||
|
input: "thequickbrownfoxjumped",
|
||||||
|
expectedOutput: "Letter H is not included in LS47",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "LS47 Encrypt",
|
||||||
|
args: ["Helloworld", 0, "test"],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
]);
|
||||||
33
tests/operations/tests/LZString.mjs
Normal file
33
tests/operations/tests/LZString.mjs
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
/**
|
||||||
|
* LZString tests.
|
||||||
|
*
|
||||||
|
* @author crespyl [peter@crespyl.net]
|
||||||
|
* @copyright Peter Jacobs 2021
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
import TestRegister from "../../lib/TestRegister.mjs";
|
||||||
|
|
||||||
|
TestRegister.addTests([
|
||||||
|
{
|
||||||
|
name: "LZString Compress To Base64",
|
||||||
|
input: "hello world",
|
||||||
|
expectedOutput: "BYUwNmD2AEDukCcwBMg=",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "LZString Compress",
|
||||||
|
"args": ["Base64"]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "LZString Decompress From Base64",
|
||||||
|
input: "BYUwNmD2AEDukCcwBMg=",
|
||||||
|
expectedOutput: "hello world",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "LZString Decompress",
|
||||||
|
"args": ["Base64"]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
}
|
||||||
|
]);
|
||||||
34
tests/operations/tests/NTLM.mjs
Normal file
34
tests/operations/tests/NTLM.mjs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
/**
|
||||||
|
* NTLM test.
|
||||||
|
*
|
||||||
|
* @author brun0ne [brunonblok@gmail.com]
|
||||||
|
* @copyright Crown Copyright 2022
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
import TestRegister from "../../lib/TestRegister.mjs";
|
||||||
|
|
||||||
|
TestRegister.addTests([
|
||||||
|
{
|
||||||
|
name: "NT Hash",
|
||||||
|
input: "QWERTYUIOPASDFGHJKLZXCVBNM1234567890!@#$%^&*()_+.,?/",
|
||||||
|
expectedOutput: "C5FA1C40E55734A8E528DBFE21766D23",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "NT Hash",
|
||||||
|
args: [],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "LM Hash",
|
||||||
|
input: "QWERTYUIOPASDFGHJKLZXCVBNM1234567890!@#$%^&*()_+.,?/",
|
||||||
|
expectedOutput: "6D9DF16655336CA75A3C13DD18BA8156",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "LM Hash",
|
||||||
|
args: [],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
|
||||||
|
]);
|
||||||
@@ -49,6 +49,18 @@ Point: 0x046c59592006272250a15070142a6be36d1e45464313f930d985a6e6f0eba3cd39d0367
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "SSH Host Key: Ed25519",
|
||||||
|
input: "AAAAC3NzaC1lZDI1NTE5AAAAIBOF6r99IkvqGu1kwZrHHIqjpTB5w79bpv67B/Aw3+WJ",
|
||||||
|
expectedOutput: `Key type: ssh-ed25519
|
||||||
|
x: 0x1385eabf7d224bea1aed64c19ac71c8aa3a53079c3bf5ba6febb07f030dfe589`,
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "Parse SSH Host Key",
|
||||||
|
args: ["Base64"]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "SSH Host Key: Extract key",
|
name: "SSH Host Key: Extract key",
|
||||||
input: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDiJZ/9W9Ix/Dk9b+K4E+RGCug1AtkGXaJ9vNIY0YHFHLpWsB8DAuh/cGEI9TLbL1gzR2wG+RJNQ2EAQVWe6ypkK63Jm4zw4re+vhEiszpnP889J0h5N9yzyTndesrl4d3cQtv861FcKDPxUJbRALdtl6gwOB7BCL8gsXJLLVLO4EesrbPXD454qpVt7CgJXEXByOFjcIm3XwkdOnXMPHHnMSD7EIN1SvQMD6PfIDrbDd6KQt5QXW/Rc/BsfX5cbUIV1QW5A/GbepXHHKmWRtLC2J/mH3hW2Zq/hITPEaJdG1CtIilQmJaZGXpfGIwFeb0Av9pSL926arZZ6vDi9ctF test@test",
|
input: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDiJZ/9W9Ix/Dk9b+K4E+RGCug1AtkGXaJ9vNIY0YHFHLpWsB8DAuh/cGEI9TLbL1gzR2wG+RJNQ2EAQVWe6ypkK63Jm4zw4re+vhEiszpnP889J0h5N9yzyTndesrl4d3cQtv861FcKDPxUJbRALdtl6gwOB7BCL8gsXJLLVLO4EesrbPXD454qpVt7CgJXEXByOFjcIm3XwkdOnXMPHHnMSD7EIN1SvQMD6PfIDrbDd6KQt5QXW/Rc/BsfX5cbUIV1QW5A/GbepXHHKmWRtLC2J/mH3hW2Zq/hITPEaJdG1CtIilQmJaZGXpfGIwFeb0Av9pSL926arZZ6vDi9ctF test@test",
|
||||||
|
|||||||
@@ -40,10 +40,10 @@ TestRegister.addTests([
|
|||||||
"Apple": [
|
"Apple": [
|
||||||
28
|
28
|
||||||
],
|
],
|
||||||
"Banana": "You",
|
|
||||||
"Carrot": [
|
"Carrot": [
|
||||||
"Me"
|
"Me"
|
||||||
]
|
],
|
||||||
|
"Banana": "You"
|
||||||
}, null, 4),
|
}, null, 4),
|
||||||
recipeConfig: [
|
recipeConfig: [
|
||||||
{
|
{
|
||||||
@@ -72,10 +72,10 @@ TestRegister.addTests([
|
|||||||
"Apple": [
|
"Apple": [
|
||||||
28
|
28
|
||||||
],
|
],
|
||||||
"Banana": "You",
|
|
||||||
"Carrot": [
|
"Carrot": [
|
||||||
"Me"
|
"Me"
|
||||||
]
|
],
|
||||||
|
"Banana": "You"
|
||||||
},
|
},
|
||||||
"Unknown Fields": {
|
"Unknown Fields": {
|
||||||
"4": 43,
|
"4": 43,
|
||||||
@@ -111,10 +111,10 @@ TestRegister.addTests([
|
|||||||
"Apple": [
|
"Apple": [
|
||||||
28
|
28
|
||||||
],
|
],
|
||||||
"Banana": "You",
|
|
||||||
"Carrot": [
|
"Carrot": [
|
||||||
"Me"
|
"Me"
|
||||||
],
|
],
|
||||||
|
"Banana": "You",
|
||||||
"Date": 43,
|
"Date": 43,
|
||||||
"Elderberry": {
|
"Elderberry": {
|
||||||
"Fig": "abc123",
|
"Fig": "abc123",
|
||||||
@@ -154,10 +154,10 @@ TestRegister.addTests([
|
|||||||
input: "0d1c0000001203596f751a024d65202b2a0a0a06616263313233120031ba32a96cc10200003801",
|
input: "0d1c0000001203596f751a024d65202b2a0a0a06616263313233120031ba32a96cc10200003801",
|
||||||
expectedOutput: JSON.stringify({
|
expectedOutput: JSON.stringify({
|
||||||
"Test": {
|
"Test": {
|
||||||
"Banana (string)": "You",
|
|
||||||
"Carrot (string)": [
|
"Carrot (string)": [
|
||||||
"Me"
|
"Me"
|
||||||
],
|
],
|
||||||
|
"Banana (string)": "You",
|
||||||
"Date (int32)": 43,
|
"Date (int32)": 43,
|
||||||
"Imbe (Options)": "Option1"
|
"Imbe (Options)": "Option1"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -212,4 +212,37 @@ TestRegister.addTests([
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "ROT8000: nothing",
|
||||||
|
input: "",
|
||||||
|
expectedOutput: "",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "ROT8000",
|
||||||
|
args: []
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "ROT8000: normal",
|
||||||
|
input: "The Quick Brown Fox Jumped Over The Lazy Dog.",
|
||||||
|
expectedOutput: "籝籱籮 籚籾籲籬籴 籋类籸粀籷 籏籸粁 籓籾籶籹籮籭 籘籿籮类 籝籱籮 籕籪粃粂 籍籸籰簷",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "ROT8000",
|
||||||
|
args: []
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "ROT8000: backward",
|
||||||
|
input: "籝籱籮 籚籾籲籬籴 籋类籸粀籷 籏籸粁 籓籾籶籹籮籭 籘籿籮类 籝籱籮 籕籪粃粂 籍籸籰簷",
|
||||||
|
expectedOutput: "The Quick Brown Fox Jumped Over The Lazy Dog.",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "ROT8000",
|
||||||
|
args: []
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
]);
|
]);
|
||||||
|
|||||||
54
tests/operations/tests/Shuffle.mjs
Normal file
54
tests/operations/tests/Shuffle.mjs
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
/**
|
||||||
|
* @author mikecat
|
||||||
|
* @copyright Crown Copyright 2022
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
import TestRegister from "../../lib/TestRegister.mjs";
|
||||||
|
|
||||||
|
TestRegister.addTests([
|
||||||
|
{
|
||||||
|
"name": "Shuffle empty",
|
||||||
|
"input": "",
|
||||||
|
"expectedOutput": "",
|
||||||
|
"recipeConfig": [
|
||||||
|
{
|
||||||
|
"op": "Shuffle",
|
||||||
|
"args": ["Comma"]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Shuffle bytes",
|
||||||
|
"input": "12345678",
|
||||||
|
"expectedOutput": "31 32 33 34 35 36 37 38",
|
||||||
|
"recipeConfig": [
|
||||||
|
{
|
||||||
|
"op": "Shuffle",
|
||||||
|
"args": ["Nothing (separate chars)"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"op": "To Hex",
|
||||||
|
"args": ["Space", 0]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"op": "Sort",
|
||||||
|
"args": ["Space", false, "Alphabetical (case sensitive)"]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Shuffle lines",
|
||||||
|
"input": "1\n2\n3\n4\n5\n6\n7\n8\n9\na\nb\nc\nd\ne\nf\n",
|
||||||
|
"expectedOutput": "\n1\n2\n3\n4\n5\n6\n7\n8\n9\na\nb\nc\nd\ne\nf",
|
||||||
|
"recipeConfig": [
|
||||||
|
{
|
||||||
|
"op": "Shuffle",
|
||||||
|
"args": ["Line feed"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"op": "Sort",
|
||||||
|
"args": ["Line feed", false, "Alphabetical (case sensitive)"]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]);
|
||||||
55
tests/operations/tests/UnescapeString.mjs
Normal file
55
tests/operations/tests/UnescapeString.mjs
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
/**
|
||||||
|
* UnescapeString tests.
|
||||||
|
*
|
||||||
|
* @copyright Crown Copyright 2022
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
import TestRegister from "../../lib/TestRegister.mjs";
|
||||||
|
|
||||||
|
TestRegister.addTests([
|
||||||
|
{
|
||||||
|
name: "UnescapeString: escape sequences",
|
||||||
|
input: "\\a\\b\\f\\n\\r\\t\\v\\'\\\"",
|
||||||
|
expectedOutput: String.fromCharCode(0x07, 0x08, 0x0c, 0x0a, 0x0d, 0x09,
|
||||||
|
0x0b, 0x27, 0x22),
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "Unescape string",
|
||||||
|
args: [],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "UnescapeString: octals",
|
||||||
|
input: "\\0\\01\\012\\1\\12",
|
||||||
|
expectedOutput: String.fromCharCode(0, 1, 10, 1, 10),
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "Unescape string",
|
||||||
|
args: [],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "UnescapeString: hexadecimals",
|
||||||
|
input: "\\x00\\xAA\\xaa",
|
||||||
|
expectedOutput: String.fromCharCode(0, 170, 170),
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "Unescape string",
|
||||||
|
args: [],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "UnescapeString: unicode",
|
||||||
|
input: "\\u0061\\u{0062}",
|
||||||
|
expectedOutput: "ab",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "Unescape string",
|
||||||
|
args: [],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
]);
|
||||||
@@ -8,6 +8,22 @@
|
|||||||
*/
|
*/
|
||||||
import TestRegister from "../../lib/TestRegister.mjs";
|
import TestRegister from "../../lib/TestRegister.mjs";
|
||||||
|
|
||||||
|
const CONSOLE_COMPILE_WARNING_RULE = `import "console"
|
||||||
|
rule a
|
||||||
|
{
|
||||||
|
strings:
|
||||||
|
$s=" "
|
||||||
|
condition:
|
||||||
|
$s and console.log("log rule a")
|
||||||
|
}
|
||||||
|
rule b
|
||||||
|
{
|
||||||
|
strings:
|
||||||
|
$s=" "
|
||||||
|
condition:
|
||||||
|
$s and console.hex("log rule b: int8(0)=", int8(0))
|
||||||
|
}`;
|
||||||
|
|
||||||
TestRegister.addTests([
|
TestRegister.addTests([
|
||||||
{
|
{
|
||||||
name: "YARA Match: simple foobar",
|
name: "YARA Match: simple foobar",
|
||||||
@@ -20,5 +36,56 @@ TestRegister.addTests([
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "YARA Match: hashing rules",
|
||||||
|
input: "Hello World!",
|
||||||
|
expectedOutput: "Input matches rule \"HelloWorldMD5\".\nInput matches rule \"HelloWorldSHA256\".\n",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "YARA Rules",
|
||||||
|
"args": [
|
||||||
|
`import "hash"
|
||||||
|
rule HelloWorldMD5 {
|
||||||
|
condition:
|
||||||
|
hash.md5(0,filesize) == "ed076287532e86365e841e92bfc50d8c"
|
||||||
|
}
|
||||||
|
|
||||||
|
rule HelloWorldSHA256 {
|
||||||
|
condition:
|
||||||
|
hash.sha256(0,filesize) == "7f83b1657ff1fc53b92dc18148a1d65dfc2d4b1fa3d677284addd200126d9069"
|
||||||
|
}`,
|
||||||
|
true, true, true, true, false, false
|
||||||
|
],
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "YARA Match: compile warnings",
|
||||||
|
input: "CyberChef Yara",
|
||||||
|
expectedOutput: "Warning on line 5: string \"$s\" may slow down scanning\n" +
|
||||||
|
"Warning on line 12: string \"$s\" may slow down scanning\n" +
|
||||||
|
"Input matches rule \"a\".\n" +
|
||||||
|
"Input matches rule \"b\".\n",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "YARA Rules",
|
||||||
|
"args": [CONSOLE_COMPILE_WARNING_RULE, false, false, false, false, true, false],
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "YARA Match: console messages",
|
||||||
|
input: "CyberChef Yara",
|
||||||
|
expectedOutput: "log rule a\n" +
|
||||||
|
"log rule b: int8(0)=0x43\n" +
|
||||||
|
"Input matches rule \"a\".\n" +
|
||||||
|
"Input matches rule \"b\".\n",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "YARA Rules",
|
||||||
|
"args": [CONSOLE_COMPILE_WARNING_RULE, false, false, false, false, false, true],
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
@@ -109,7 +109,8 @@ module.exports = {
|
|||||||
"buffer": require.resolve("buffer/"),
|
"buffer": require.resolve("buffer/"),
|
||||||
"crypto": require.resolve("crypto-browserify"),
|
"crypto": require.resolve("crypto-browserify"),
|
||||||
"stream": require.resolve("stream-browserify"),
|
"stream": require.resolve("stream-browserify"),
|
||||||
"zlib": require.resolve("browserify-zlib")
|
"zlib": require.resolve("browserify-zlib"),
|
||||||
|
"process": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
module: {
|
module: {
|
||||||
@@ -164,19 +165,6 @@ module.exports = {
|
|||||||
"postcss-loader",
|
"postcss-loader",
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
test: /\.scss$/,
|
|
||||||
use: [
|
|
||||||
{
|
|
||||||
loader: MiniCssExtractPlugin.loader,
|
|
||||||
options: {
|
|
||||||
publicPath: "../"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"css-loader",
|
|
||||||
"sass-loader",
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
test: /\.(ico|eot|ttf|woff|woff2)$/,
|
test: /\.(ico|eot|ttf|woff|woff2)$/,
|
||||||
type: "asset/resource",
|
type: "asset/resource",
|
||||||
|
|||||||
Reference in New Issue
Block a user