cyberchef 9.48.0 → 9.49.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -13,6 +13,9 @@ All major and minor version changes will be documented in this file. Details of
13
13
 
14
14
  ## Details
15
15
 
16
+ ### [9.49.0] - 2022-11-11
17
+ - Added 'LZ4 Compress' and 'LZ4 Decompress' operations [@n1474335] | [31a7f83]
18
+
16
19
  ### [9.48.0] - 2022-10-14
17
20
  - Added 'LM Hash' and 'NT Hash' operations [@n1474335] [@brun0ne] | [#1427]
18
21
 
@@ -321,6 +324,7 @@ All major and minor version changes will be documented in this file. Details of
321
324
 
322
325
 
323
326
 
327
+ [9.49.0]: https://github.com/gchq/CyberChef/releases/tag/v9.49.0
324
328
  [9.48.0]: https://github.com/gchq/CyberChef/releases/tag/v9.48.0
325
329
  [9.47.0]: https://github.com/gchq/CyberChef/releases/tag/v9.47.0
326
330
  [9.46.0]: https://github.com/gchq/CyberChef/releases/tag/v9.46.0
@@ -466,6 +470,7 @@ All major and minor version changes will be documented in this file. Details of
466
470
  [e9ca4dc]: https://github.com/gchq/CyberChef/commit/e9ca4dc9caf98f33fd986431cd400c88082a42b8
467
471
  [dd18e52]: https://github.com/gchq/CyberChef/commit/dd18e529939078b89867297b181a584e8b2cc7da
468
472
  [a895d1d]: https://github.com/gchq/CyberChef/commit/a895d1d82a2f92d440a0c5eca2bc7c898107b737
473
+ [31a7f83]: https://github.com/gchq/CyberChef/commit/31a7f83b82e78927f89689f323fcb9185144d6ff
469
474
 
470
475
  [#95]: https://github.com/gchq/CyberChef/pull/299
471
476
  [#173]: https://github.com/gchq/CyberChef/pull/173
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cyberchef",
3
- "version": "9.48.0",
3
+ "version": "9.49.1",
4
4
  "description": "The Cyber Swiss Army Knife for encryption, encoding, compression and data analysis.",
5
5
  "author": "n1474335 <n1474335@gmail.com>",
6
6
  "homepage": "https://gchq.github.io/CyberChef",
@@ -134,6 +134,7 @@
134
134
  "loglevel": "^1.8.0",
135
135
  "loglevel-message-prefix": "^3.0.0",
136
136
  "lz-string": "^1.4.4",
137
+ "lz4js": "^0.2.0",
137
138
  "markdown-it": "^13.0.1",
138
139
  "moment": "^2.29.3",
139
140
  "moment-timezone": "^0.5.34",
@@ -333,7 +333,9 @@
333
333
  "LZString Decompress",
334
334
  "LZString Compress",
335
335
  "LZMA Decompress",
336
- "LZMA Compress"
336
+ "LZMA Compress",
337
+ "LZ4 Decompress",
338
+ "LZ4 Compress"
337
339
  ]
338
340
  },
339
341
  {
@@ -8067,6 +8067,26 @@
8067
8067
  }
8068
8068
  ]
8069
8069
  },
8070
+ "LZ4 Compress": {
8071
+ "module": "Compression",
8072
+ "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.",
8073
+ "infoURL": "https://wikipedia.org/wiki/LZ4_(compression_algorithm)",
8074
+ "inputType": "ArrayBuffer",
8075
+ "outputType": "ArrayBuffer",
8076
+ "flowControl": false,
8077
+ "manualBake": false,
8078
+ "args": []
8079
+ },
8080
+ "LZ4 Decompress": {
8081
+ "module": "Compression",
8082
+ "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.",
8083
+ "infoURL": "https://wikipedia.org/wiki/LZ4_(compression_algorithm)",
8084
+ "inputType": "ArrayBuffer",
8085
+ "outputType": "ArrayBuffer",
8086
+ "flowControl": false,
8087
+ "manualBake": false,
8088
+ "args": []
8089
+ },
8070
8090
  "LZMA Compress": {
8071
8091
  "module": "Compression",
8072
8092
  "description": "Compresses data using the Lempel–Ziv–Markov chain algorithm. Compression mode determines the speed and effectiveness of the compression: 1 is fastest and less effective, 9 is slowest and most effective",
@@ -9,6 +9,8 @@ import Bzip2Compress from "../../operations/Bzip2Compress.mjs";
9
9
  import Bzip2Decompress from "../../operations/Bzip2Decompress.mjs";
10
10
  import Gunzip from "../../operations/Gunzip.mjs";
11
11
  import Gzip from "../../operations/Gzip.mjs";
12
+ import LZ4Compress from "../../operations/LZ4Compress.mjs";
13
+ import LZ4Decompress from "../../operations/LZ4Decompress.mjs";
12
14
  import LZMACompress from "../../operations/LZMACompress.mjs";
13
15
  import LZMADecompress from "../../operations/LZMADecompress.mjs";
14
16
  import LZStringCompress from "../../operations/LZStringCompress.mjs";
@@ -29,6 +31,8 @@ OpModules.Compression = {
29
31
  "Bzip2 Decompress": Bzip2Decompress,
30
32
  "Gunzip": Gunzip,
31
33
  "Gzip": Gzip,
34
+ "LZ4 Compress": LZ4Compress,
35
+ "LZ4 Decompress": LZ4Decompress,
32
36
  "LZMA Compress": LZMACompress,
33
37
  "LZMA Decompress": LZMADecompress,
34
38
  "LZString Compress": LZStringCompress,
@@ -0,0 +1,43 @@
1
+ /**
2
+ * @author n1474335 [n1474335@gmail.com]
3
+ * @copyright Crown Copyright 2022
4
+ * @license Apache-2.0
5
+ */
6
+
7
+ import Operation from "../Operation.mjs";
8
+ import lz4 from "lz4js";
9
+
10
+ /**
11
+ * LZ4 Compress operation
12
+ */
13
+ class LZ4Compress extends Operation {
14
+
15
+ /**
16
+ * LZ4Compress constructor
17
+ */
18
+ constructor() {
19
+ super();
20
+
21
+ this.name = "LZ4 Compress";
22
+ this.module = "Compression";
23
+ 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.";
24
+ this.infoURL = "https://wikipedia.org/wiki/LZ4_(compression_algorithm)";
25
+ this.inputType = "ArrayBuffer";
26
+ this.outputType = "ArrayBuffer";
27
+ this.args = [];
28
+ }
29
+
30
+ /**
31
+ * @param {ArrayBuffer} input
32
+ * @param {Object[]} args
33
+ * @returns {ArrayBuffer}
34
+ */
35
+ run(input, args) {
36
+ const inBuf = new Uint8Array(input);
37
+ const compressed = lz4.compress(inBuf);
38
+ return compressed.buffer;
39
+ }
40
+
41
+ }
42
+
43
+ export default LZ4Compress;
@@ -0,0 +1,43 @@
1
+ /**
2
+ * @author n1474335 [n1474335@gmail.com]
3
+ * @copyright Crown Copyright 2022
4
+ * @license Apache-2.0
5
+ */
6
+
7
+ import Operation from "../Operation.mjs";
8
+ import lz4 from "lz4js";
9
+
10
+ /**
11
+ * LZ4 Decompress operation
12
+ */
13
+ class LZ4Decompress extends Operation {
14
+
15
+ /**
16
+ * LZ4Decompress constructor
17
+ */
18
+ constructor() {
19
+ super();
20
+
21
+ this.name = "LZ4 Decompress";
22
+ this.module = "Compression";
23
+ 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.";
24
+ this.infoURL = "https://wikipedia.org/wiki/LZ4_(compression_algorithm)";
25
+ this.inputType = "ArrayBuffer";
26
+ this.outputType = "ArrayBuffer";
27
+ this.args = [];
28
+ }
29
+
30
+ /**
31
+ * @param {ArrayBuffer} input
32
+ * @param {Object[]} args
33
+ * @returns {ArrayBuffer}
34
+ */
35
+ run(input, args) {
36
+ const inBuf = new Uint8Array(input);
37
+ const decompressed = lz4.decompress(inBuf);
38
+ return decompressed.buffer;
39
+ }
40
+
41
+ }
42
+
43
+ export default LZ4Decompress;
@@ -52,8 +52,12 @@ class PseudoRandomNumberGenerator extends Operation {
52
52
  let bytes;
53
53
 
54
54
  if (isWorkerEnvironment() && self.crypto) {
55
- bytes = self.crypto.getRandomValues(new Uint8Array(numBytes));
56
- bytes = Utils.arrayBufferToStr(bytes.buffer);
55
+ bytes = new ArrayBuffer(numBytes);
56
+ const CHUNK_SIZE = 65536;
57
+ for (let i = 0; i < numBytes; i += CHUNK_SIZE) {
58
+ self.crypto.getRandomValues(new Uint8Array(bytes, i, Math.min(numBytes - i, CHUNK_SIZE)));
59
+ }
60
+ bytes = Utils.arrayBufferToStr(bytes);
57
61
  } else {
58
62
  bytes = forge.random.getBytesSync(numBytes);
59
63
  }
@@ -197,6 +197,8 @@ import Keccak from "./Keccak.mjs";
197
197
  import LMHash from "./LMHash.mjs";
198
198
  import LS47Decrypt from "./LS47Decrypt.mjs";
199
199
  import LS47Encrypt from "./LS47Encrypt.mjs";
200
+ import LZ4Compress from "./LZ4Compress.mjs";
201
+ import LZ4Decompress from "./LZ4Decompress.mjs";
200
202
  import LZMACompress from "./LZMACompress.mjs";
201
203
  import LZMADecompress from "./LZMADecompress.mjs";
202
204
  import LZStringCompress from "./LZStringCompress.mjs";
@@ -586,6 +588,8 @@ export {
586
588
  LMHash,
587
589
  LS47Decrypt,
588
590
  LS47Encrypt,
591
+ LZ4Compress,
592
+ LZ4Decompress,
589
593
  LZMACompress,
590
594
  LZMADecompress,
591
595
  LZStringCompress,
@@ -200,6 +200,8 @@ import {
200
200
  LMHash as core_LMHash,
201
201
  LS47Decrypt as core_LS47Decrypt,
202
202
  LS47Encrypt as core_LS47Encrypt,
203
+ LZ4Compress as core_LZ4Compress,
204
+ LZ4Decompress as core_LZ4Decompress,
203
205
  LZMACompress as core_LZMACompress,
204
206
  LZMADecompress as core_LZMADecompress,
205
207
  LZStringCompress as core_LZStringCompress,
@@ -589,6 +591,8 @@ function generateChef() {
589
591
  "LMHash": _wrap(core_LMHash),
590
592
  "LS47Decrypt": _wrap(core_LS47Decrypt),
591
593
  "LS47Encrypt": _wrap(core_LS47Encrypt),
594
+ "LZ4Compress": _wrap(core_LZ4Compress),
595
+ "LZ4Decompress": _wrap(core_LZ4Decompress),
592
596
  "LZMACompress": _wrap(core_LZMACompress),
593
597
  "LZMADecompress": _wrap(core_LZMADecompress),
594
598
  "LZStringCompress": _wrap(core_LZStringCompress),
@@ -993,6 +997,8 @@ const keccak = chef.keccak;
993
997
  const LMHash = chef.LMHash;
994
998
  const LS47Decrypt = chef.LS47Decrypt;
995
999
  const LS47Encrypt = chef.LS47Encrypt;
1000
+ const LZ4Compress = chef.LZ4Compress;
1001
+ const LZ4Decompress = chef.LZ4Decompress;
996
1002
  const LZMACompress = chef.LZMACompress;
997
1003
  const LZMADecompress = chef.LZMADecompress;
998
1004
  const LZStringCompress = chef.LZStringCompress;
@@ -1384,6 +1390,8 @@ const operations = [
1384
1390
  LMHash,
1385
1391
  LS47Decrypt,
1386
1392
  LS47Encrypt,
1393
+ LZ4Compress,
1394
+ LZ4Decompress,
1387
1395
  LZMACompress,
1388
1396
  LZMADecompress,
1389
1397
  LZStringCompress,
@@ -1779,6 +1787,8 @@ export {
1779
1787
  LMHash,
1780
1788
  LS47Decrypt,
1781
1789
  LS47Encrypt,
1790
+ LZ4Compress,
1791
+ LZ4Decompress,
1782
1792
  LZMACompress,
1783
1793
  LZMADecompress,
1784
1794
  LZStringCompress,
@@ -75,4 +75,34 @@ TestRegister.addTests([
75
75
  }
76
76
  ],
77
77
  },
78
+ {
79
+ name: "LZ4 Compress",
80
+ input: "The cat sat on the mat.",
81
+ expectedOutput: "04224d184070df170000805468652063617420736174206f6e20746865206d61742e00000000",
82
+ recipeConfig: [
83
+ {
84
+ "op": "LZ4 Compress",
85
+ "args": []
86
+ },
87
+ {
88
+ "op": "To Hex",
89
+ "args": ["None", 0]
90
+ }
91
+ ],
92
+ },
93
+ {
94
+ name: "LZ4 Decompress",
95
+ input: "04224d184070df170000805468652063617420736174206f6e20746865206d61742e00000000",
96
+ expectedOutput: "The cat sat on the mat.",
97
+ recipeConfig: [
98
+ {
99
+ "op": "From Hex",
100
+ "args": ["None"]
101
+ },
102
+ {
103
+ "op": "LZ4 Decompress",
104
+ "args": []
105
+ }
106
+ ],
107
+ },
78
108
  ]);