cyberchef 9.35.0 → 9.37.0
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 +13 -0
- package/package.json +1 -1
- package/src/core/config/Categories.json +4 -1
- package/src/core/config/OperationConfig.json +1359 -160
- package/src/core/config/modules/Bletchley.mjs +2 -0
- package/src/core/config/modules/Ciphers.mjs +4 -0
- package/src/core/lib/Charts.mjs +2 -1
- package/src/core/lib/SIGABA.mjs +502 -0
- package/src/core/lib/SM4.mjs +331 -0
- package/src/core/operations/AESDecrypt.mjs +19 -2
- package/src/core/operations/Bombe.mjs +3 -0
- package/src/core/operations/Colossus.mjs +3 -0
- package/src/core/operations/DESDecrypt.mjs +13 -3
- package/src/core/operations/Enigma.mjs +3 -0
- package/src/core/operations/GetAllCasings.mjs +1 -1
- package/src/core/operations/Lorenz.mjs +3 -0
- package/src/core/operations/SIGABA.mjs +287 -0
- package/src/core/operations/SM4Decrypt.mjs +88 -0
- package/src/core/operations/SM4Encrypt.mjs +88 -0
- package/src/core/operations/ScatterChart.mjs +1 -1
- package/src/core/operations/SeriesChart.mjs +4 -1
- package/src/core/operations/TripleDESDecrypt.mjs +12 -3
- package/src/core/operations/Typex.mjs +3 -0
- package/src/core/operations/index.mjs +6 -0
- package/src/node/index.mjs +15 -0
- package/tests/node/tests/nodeApi.mjs +1 -1
- package/tests/operations/index.mjs +3 -0
- package/tests/operations/tests/GetAllCasings.mjs +3 -3
- package/tests/operations/tests/SIGABA.mjs +91 -0
- package/tests/operations/tests/SM4.mjs +279 -0
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Emulation of the SIGABA machine.
|
|
3
|
+
*
|
|
4
|
+
* @author hettysymes
|
|
5
|
+
* @copyright hettysymes 2020
|
|
6
|
+
* @license Apache-2.0
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import Operation from "../Operation.mjs";
|
|
10
|
+
import {LETTERS} from "../lib/Enigma.mjs";
|
|
11
|
+
import {NUMBERS, CR_ROTORS, I_ROTORS, SigabaMachine, CRRotor, IRotor} from "../lib/SIGABA.mjs";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Sigaba operation
|
|
15
|
+
*/
|
|
16
|
+
class Sigaba extends Operation {
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Sigaba constructor
|
|
20
|
+
*/
|
|
21
|
+
constructor() {
|
|
22
|
+
super();
|
|
23
|
+
|
|
24
|
+
this.name = "SIGABA";
|
|
25
|
+
this.module = "Bletchley";
|
|
26
|
+
this.description = "Encipher/decipher with the WW2 SIGABA machine. <br><br>SIGABA, otherwise known as ECM Mark II, was used by the United States for message encryption during WW2 up to the 1950s. It was developed in the 1930s by the US Army and Navy, and has up to this day never been broken. Consisting of 15 rotors: 5 cipher rotors and 10 rotors (5 control rotors and 5 index rotors) controlling the stepping of the cipher rotors, the rotor stepping for SIGABA is much more complex than other rotor machines of its time, such as Enigma. All example rotor wirings are random example sets.<br><br>To configure rotor wirings, for the cipher and control rotors enter a string of letters which map from A to Z, and for the index rotors enter a sequence of numbers which map from 0 to 9. Note that encryption is not the same as decryption, so first choose the desired mode. <br><br> Note: Whilst this has been tested against other software emulators, it has not been tested against hardware.";
|
|
27
|
+
this.infoURL = "https://wikipedia.org/wiki/SIGABA";
|
|
28
|
+
this.inputType = "string";
|
|
29
|
+
this.outputType = "string";
|
|
30
|
+
this.args = [
|
|
31
|
+
{
|
|
32
|
+
name: "1st (left-hand) cipher rotor",
|
|
33
|
+
type: "editableOption",
|
|
34
|
+
value: CR_ROTORS,
|
|
35
|
+
defaultIndex: 0
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: "1st cipher rotor reversed",
|
|
39
|
+
type: "boolean",
|
|
40
|
+
value: false
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: "1st cipher rotor intial value",
|
|
44
|
+
type: "option",
|
|
45
|
+
value: LETTERS
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: "2nd cipher rotor",
|
|
49
|
+
type: "editableOption",
|
|
50
|
+
value: CR_ROTORS,
|
|
51
|
+
defaultIndex: 0
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: "2nd cipher rotor reversed",
|
|
55
|
+
type: "boolean",
|
|
56
|
+
value: false
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: "2nd cipher rotor intial value",
|
|
60
|
+
type: "option",
|
|
61
|
+
value: LETTERS
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: "3rd (middle) cipher rotor",
|
|
65
|
+
type: "editableOption",
|
|
66
|
+
value: CR_ROTORS,
|
|
67
|
+
defaultIndex: 0
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: "3rd cipher rotor reversed",
|
|
71
|
+
type: "boolean",
|
|
72
|
+
value: false
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: "3rd cipher rotor intial value",
|
|
76
|
+
type: "option",
|
|
77
|
+
value: LETTERS
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: "4th cipher rotor",
|
|
81
|
+
type: "editableOption",
|
|
82
|
+
value: CR_ROTORS,
|
|
83
|
+
defaultIndex: 0
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: "4th cipher rotor reversed",
|
|
87
|
+
type: "boolean",
|
|
88
|
+
value: false
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
name: "4th cipher rotor intial value",
|
|
92
|
+
type: "option",
|
|
93
|
+
value: LETTERS
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: "5th (right-hand) cipher rotor",
|
|
97
|
+
type: "editableOption",
|
|
98
|
+
value: CR_ROTORS,
|
|
99
|
+
defaultIndex: 0
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: "5th cipher rotor reversed",
|
|
103
|
+
type: "boolean",
|
|
104
|
+
value: false
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
name: "5th cipher rotor intial value",
|
|
108
|
+
type: "option",
|
|
109
|
+
value: LETTERS
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
name: "1st (left-hand) control rotor",
|
|
113
|
+
type: "editableOption",
|
|
114
|
+
value: CR_ROTORS,
|
|
115
|
+
defaultIndex: 0
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
name: "1st control rotor reversed",
|
|
119
|
+
type: "boolean",
|
|
120
|
+
value: false
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
name: "1st control rotor intial value",
|
|
124
|
+
type: "option",
|
|
125
|
+
value: LETTERS
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
name: "2nd control rotor",
|
|
129
|
+
type: "editableOption",
|
|
130
|
+
value: CR_ROTORS,
|
|
131
|
+
defaultIndex: 0
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
name: "2nd control rotor reversed",
|
|
135
|
+
type: "boolean",
|
|
136
|
+
value: false
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
name: "2nd control rotor intial value",
|
|
140
|
+
type: "option",
|
|
141
|
+
value: LETTERS
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
name: "3rd (middle) control rotor",
|
|
145
|
+
type: "editableOption",
|
|
146
|
+
value: CR_ROTORS,
|
|
147
|
+
defaultIndex: 0
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
name: "3rd control rotor reversed",
|
|
151
|
+
type: "boolean",
|
|
152
|
+
value: false
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
name: "3rd control rotor intial value",
|
|
156
|
+
type: "option",
|
|
157
|
+
value: LETTERS
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
name: "4th control rotor",
|
|
161
|
+
type: "editableOption",
|
|
162
|
+
value: CR_ROTORS,
|
|
163
|
+
defaultIndex: 0
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
name: "4th control rotor reversed",
|
|
167
|
+
type: "boolean",
|
|
168
|
+
value: false
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
name: "4th control rotor intial value",
|
|
172
|
+
type: "option",
|
|
173
|
+
value: LETTERS
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
name: "5th (right-hand) control rotor",
|
|
177
|
+
type: "editableOption",
|
|
178
|
+
value: CR_ROTORS,
|
|
179
|
+
defaultIndex: 0
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
name: "5th control rotor reversed",
|
|
183
|
+
type: "boolean",
|
|
184
|
+
value: false
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
name: "5th control rotor intial value",
|
|
188
|
+
type: "option",
|
|
189
|
+
value: LETTERS
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
name: "1st (left-hand) index rotor",
|
|
193
|
+
type: "editableOption",
|
|
194
|
+
value: I_ROTORS,
|
|
195
|
+
defaultIndex: 0
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
name: "1st index rotor intial value",
|
|
199
|
+
type: "option",
|
|
200
|
+
value: NUMBERS
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
name: "2nd index rotor",
|
|
204
|
+
type: "editableOption",
|
|
205
|
+
value: I_ROTORS,
|
|
206
|
+
defaultIndex: 0
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
name: "2nd index rotor intial value",
|
|
210
|
+
type: "option",
|
|
211
|
+
value: NUMBERS
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
name: "3rd (middle) index rotor",
|
|
215
|
+
type: "editableOption",
|
|
216
|
+
value: I_ROTORS,
|
|
217
|
+
defaultIndex: 0
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
name: "3rd index rotor intial value",
|
|
221
|
+
type: "option",
|
|
222
|
+
value: NUMBERS
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
name: "4th index rotor",
|
|
226
|
+
type: "editableOption",
|
|
227
|
+
value: I_ROTORS,
|
|
228
|
+
defaultIndex: 0
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
name: "4th index rotor intial value",
|
|
232
|
+
type: "option",
|
|
233
|
+
value: NUMBERS
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
name: "5th (right-hand) index rotor",
|
|
237
|
+
type: "editableOption",
|
|
238
|
+
value: I_ROTORS,
|
|
239
|
+
defaultIndex: 0
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
name: "5th index rotor intial value",
|
|
243
|
+
type: "option",
|
|
244
|
+
value: NUMBERS
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
name: "SIGABA mode",
|
|
248
|
+
type: "option",
|
|
249
|
+
value: ["Encrypt", "Decrypt"]
|
|
250
|
+
}
|
|
251
|
+
];
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* @param {string} input
|
|
256
|
+
* @param {Object[]} args
|
|
257
|
+
* @returns {string}
|
|
258
|
+
*/
|
|
259
|
+
run(input, args) {
|
|
260
|
+
const sigabaSwitch = args[40];
|
|
261
|
+
const cipherRotors = [];
|
|
262
|
+
const controlRotors = [];
|
|
263
|
+
const indexRotors = [];
|
|
264
|
+
for (let i=0; i<5; i++) {
|
|
265
|
+
const rotorWiring = args[i*3];
|
|
266
|
+
cipherRotors.push(new CRRotor(rotorWiring, args[i*3+2], args[i*3+1]));
|
|
267
|
+
}
|
|
268
|
+
for (let i=5; i<10; i++) {
|
|
269
|
+
const rotorWiring = args[i*3];
|
|
270
|
+
controlRotors.push(new CRRotor(rotorWiring, args[i*3+2], args[i*3+1]));
|
|
271
|
+
}
|
|
272
|
+
for (let i=15; i<20; i++) {
|
|
273
|
+
const rotorWiring = args[i*2];
|
|
274
|
+
indexRotors.push(new IRotor(rotorWiring, args[i*2+1]));
|
|
275
|
+
}
|
|
276
|
+
const sigaba = new SigabaMachine(cipherRotors, controlRotors, indexRotors);
|
|
277
|
+
let result;
|
|
278
|
+
if (sigabaSwitch === "Encrypt") {
|
|
279
|
+
result = sigaba.encrypt(input);
|
|
280
|
+
} else if (sigabaSwitch === "Decrypt") {
|
|
281
|
+
result = sigaba.decrypt(input);
|
|
282
|
+
}
|
|
283
|
+
return result;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
}
|
|
287
|
+
export default Sigaba;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author swesven
|
|
3
|
+
* @copyright 2021
|
|
4
|
+
* @license Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import Operation from "../Operation.mjs";
|
|
8
|
+
import Utils from "../Utils.mjs";
|
|
9
|
+
import OperationError from "../errors/OperationError.mjs";
|
|
10
|
+
import { toHex } from "../lib/Hex.mjs";
|
|
11
|
+
import { decryptSM4 } from "../lib/SM4.mjs";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* SM4 Decrypt operation
|
|
15
|
+
*/
|
|
16
|
+
class SM4Decrypt extends Operation {
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* SM4Encrypt constructor
|
|
20
|
+
*/
|
|
21
|
+
constructor() {
|
|
22
|
+
super();
|
|
23
|
+
|
|
24
|
+
this.name = "SM4 Decrypt";
|
|
25
|
+
this.module = "Ciphers";
|
|
26
|
+
this.description = "SM4 is a 128-bit block cipher, currently established as a national standard (GB/T 32907-2016) of China.";
|
|
27
|
+
this.infoURL = "https://wikipedia.org/wiki/SM4_(cipher)";
|
|
28
|
+
this.inputType = "string";
|
|
29
|
+
this.outputType = "string";
|
|
30
|
+
this.args = [
|
|
31
|
+
{
|
|
32
|
+
"name": "Key",
|
|
33
|
+
"type": "toggleString",
|
|
34
|
+
"value": "",
|
|
35
|
+
"toggleValues": ["Hex", "UTF8", "Latin1", "Base64"]
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"name": "IV",
|
|
39
|
+
"type": "toggleString",
|
|
40
|
+
"value": "",
|
|
41
|
+
"toggleValues": ["Hex", "UTF8", "Latin1", "Base64"]
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"name": "Mode",
|
|
45
|
+
"type": "option",
|
|
46
|
+
"value": ["CBC", "CFB", "OFB", "CTR", "ECB", "CBC/NoPadding", "ECB/NoPadding"]
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"name": "Input",
|
|
50
|
+
"type": "option",
|
|
51
|
+
"value": ["Raw", "Hex"]
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"name": "Output",
|
|
55
|
+
"type": "option",
|
|
56
|
+
"value": ["Hex", "Raw"]
|
|
57
|
+
}
|
|
58
|
+
];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @param {string} input
|
|
63
|
+
* @param {Object[]} args
|
|
64
|
+
* @returns {string}
|
|
65
|
+
*/
|
|
66
|
+
run(input, args) {
|
|
67
|
+
const key = Utils.convertToByteArray(args[0].string, args[0].option),
|
|
68
|
+
iv = Utils.convertToByteArray(args[1].string, args[1].option),
|
|
69
|
+
[,, mode, inputType, outputType] = args;
|
|
70
|
+
|
|
71
|
+
if (key.length !== 16)
|
|
72
|
+
throw new OperationError(`Invalid key length: ${key.length} bytes
|
|
73
|
+
|
|
74
|
+
SM4 uses a key length of 16 bytes (128 bits).`);
|
|
75
|
+
if (iv.length !== 16 && !mode.startsWith("ECB"))
|
|
76
|
+
throw new OperationError(`Invalid IV length: ${iv.length} bytes
|
|
77
|
+
|
|
78
|
+
SM4 uses an IV length of 16 bytes (128 bits).
|
|
79
|
+
Make sure you have specified the type correctly (e.g. Hex vs UTF8).`);
|
|
80
|
+
|
|
81
|
+
input = Utils.convertToByteArray(input, inputType);
|
|
82
|
+
const output = decryptSM4(input, key, iv, mode.substring(0, 3), mode.endsWith("NoPadding"));
|
|
83
|
+
return outputType === "Hex" ? toHex(output) : Utils.byteArrayToUtf8(output);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export default SM4Decrypt;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author swesven
|
|
3
|
+
* @copyright 2021
|
|
4
|
+
* @license Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import Operation from "../Operation.mjs";
|
|
8
|
+
import Utils from "../Utils.mjs";
|
|
9
|
+
import OperationError from "../errors/OperationError.mjs";
|
|
10
|
+
import { toHex } from "../lib/Hex.mjs";
|
|
11
|
+
import { encryptSM4 } from "../lib/SM4.mjs";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* SM4 Encrypt operation
|
|
15
|
+
*/
|
|
16
|
+
class SM4Encrypt extends Operation {
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* SM4Encrypt constructor
|
|
20
|
+
*/
|
|
21
|
+
constructor() {
|
|
22
|
+
super();
|
|
23
|
+
|
|
24
|
+
this.name = "SM4 Encrypt";
|
|
25
|
+
this.module = "Ciphers";
|
|
26
|
+
this.description = "SM4 is a 128-bit block cipher, currently established as a national standard (GB/T 32907-2016) of China. Multiple block cipher modes are supported. When using CBC or ECB mode, the PKCS#7 padding scheme is used.";
|
|
27
|
+
this.infoURL = "https://wikipedia.org/wiki/SM4_(cipher)";
|
|
28
|
+
this.inputType = "string";
|
|
29
|
+
this.outputType = "string";
|
|
30
|
+
this.args = [
|
|
31
|
+
{
|
|
32
|
+
"name": "Key",
|
|
33
|
+
"type": "toggleString",
|
|
34
|
+
"value": "",
|
|
35
|
+
"toggleValues": ["Hex", "UTF8", "Latin1", "Base64"]
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"name": "IV",
|
|
39
|
+
"type": "toggleString",
|
|
40
|
+
"value": "",
|
|
41
|
+
"toggleValues": ["Hex", "UTF8", "Latin1", "Base64"]
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"name": "Mode",
|
|
45
|
+
"type": "option",
|
|
46
|
+
"value": ["CBC", "CFB", "OFB", "CTR", "ECB"]
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"name": "Input",
|
|
50
|
+
"type": "option",
|
|
51
|
+
"value": ["Raw", "Hex"]
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"name": "Output",
|
|
55
|
+
"type": "option",
|
|
56
|
+
"value": ["Hex", "Raw"]
|
|
57
|
+
}
|
|
58
|
+
];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @param {string} input
|
|
63
|
+
* @param {Object[]} args
|
|
64
|
+
* @returns {string}
|
|
65
|
+
*/
|
|
66
|
+
run(input, args) {
|
|
67
|
+
const key = Utils.convertToByteArray(args[0].string, args[0].option),
|
|
68
|
+
iv = Utils.convertToByteArray(args[1].string, args[1].option),
|
|
69
|
+
[,, mode, inputType, outputType] = args;
|
|
70
|
+
|
|
71
|
+
if (key.length !== 16)
|
|
72
|
+
throw new OperationError(`Invalid key length: ${key.length} bytes
|
|
73
|
+
|
|
74
|
+
SM4 uses a key length of 16 bytes (128 bits).`);
|
|
75
|
+
if (iv.length !== 16 && !mode.startsWith("ECB"))
|
|
76
|
+
throw new OperationError(`Invalid IV length: ${iv.length} bytes
|
|
77
|
+
|
|
78
|
+
SM4 uses an IV length of 16 bytes (128 bits).
|
|
79
|
+
Make sure you have specified the type correctly (e.g. Hex vs UTF8).`);
|
|
80
|
+
|
|
81
|
+
input = Utils.convertToByteArray(input, inputType);
|
|
82
|
+
const output = encryptSM4(input, key, iv, mode.substring(0, 3), mode.endsWith("NoPadding"));
|
|
83
|
+
return outputType === "Hex" ? toHex(output) : Utils.byteArrayToUtf8(output);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export default SM4Encrypt;
|
|
@@ -87,7 +87,7 @@ class ScatterChart extends Operation {
|
|
|
87
87
|
const recordDelimiter = Utils.charRep(args[0]),
|
|
88
88
|
fieldDelimiter = Utils.charRep(args[1]),
|
|
89
89
|
columnHeadingsAreIncluded = args[2],
|
|
90
|
-
fillColour = args[5],
|
|
90
|
+
fillColour = Utils.escapeHtml(args[5]),
|
|
91
91
|
radius = args[6],
|
|
92
92
|
colourInInput = args[7],
|
|
93
93
|
dimension = 500;
|
|
@@ -72,7 +72,10 @@ class SeriesChart extends Operation {
|
|
|
72
72
|
fieldDelimiter = Utils.charRep(args[1]),
|
|
73
73
|
xLabel = args[2],
|
|
74
74
|
pipRadius = args[3],
|
|
75
|
-
|
|
75
|
+
// Escape HTML from all colours to prevent reflected XSS. See https://github.com/gchq/CyberChef/issues/1265
|
|
76
|
+
seriesColours = args[4].split(",").map((colour) => {
|
|
77
|
+
return Utils.escapeHtml(colour);
|
|
78
|
+
}),
|
|
76
79
|
svgWidth = 500,
|
|
77
80
|
interSeriesPadding = 20,
|
|
78
81
|
xAxisHeight = 50,
|
|
@@ -22,7 +22,7 @@ class TripleDESDecrypt extends Operation {
|
|
|
22
22
|
|
|
23
23
|
this.name = "Triple DES Decrypt";
|
|
24
24
|
this.module = "Ciphers";
|
|
25
|
-
this.description = "Triple DES applies DES three times to each block to increase key size.<br><br><b>Key:</b> Triple DES uses a key length of 24 bytes (192 bits).<br>DES uses a key length of 8 bytes (64 bits).<br><br><b>IV:</b> The Initialization Vector should be 8 bytes long. If not entered, it will default to 8 null bytes.<br><br><b>Padding:</b> In CBC and ECB mode, PKCS#7 padding will be used.";
|
|
25
|
+
this.description = "Triple DES applies DES three times to each block to increase key size.<br><br><b>Key:</b> Triple DES uses a key length of 24 bytes (192 bits).<br>DES uses a key length of 8 bytes (64 bits).<br><br><b>IV:</b> The Initialization Vector should be 8 bytes long. If not entered, it will default to 8 null bytes.<br><br><b>Padding:</b> In CBC and ECB mode, PKCS#7 padding will be used as a default.";
|
|
26
26
|
this.infoURL = "https://wikipedia.org/wiki/Triple_DES";
|
|
27
27
|
this.inputType = "string";
|
|
28
28
|
this.outputType = "string";
|
|
@@ -42,7 +42,7 @@ class TripleDESDecrypt extends Operation {
|
|
|
42
42
|
{
|
|
43
43
|
"name": "Mode",
|
|
44
44
|
"type": "option",
|
|
45
|
-
"value": ["CBC", "CFB", "OFB", "CTR", "ECB"]
|
|
45
|
+
"value": ["CBC", "CFB", "OFB", "CTR", "ECB", "CBC/NoPadding", "ECB/NoPadding"]
|
|
46
46
|
},
|
|
47
47
|
{
|
|
48
48
|
"name": "Input",
|
|
@@ -65,7 +65,8 @@ class TripleDESDecrypt extends Operation {
|
|
|
65
65
|
run(input, args) {
|
|
66
66
|
const key = Utils.convertToByteString(args[0].string, args[0].option),
|
|
67
67
|
iv = Utils.convertToByteArray(args[1].string, args[1].option),
|
|
68
|
-
mode = args[2],
|
|
68
|
+
mode = args[2].substring(0, 3),
|
|
69
|
+
noPadding = args[2].endsWith("NoPadding"),
|
|
69
70
|
inputType = args[3],
|
|
70
71
|
outputType = args[4];
|
|
71
72
|
|
|
@@ -85,6 +86,14 @@ Make sure you have specified the type correctly (e.g. Hex vs UTF8).`);
|
|
|
85
86
|
input = Utils.convertToByteString(input, inputType);
|
|
86
87
|
|
|
87
88
|
const decipher = forge.cipher.createDecipher("3DES-" + mode, key);
|
|
89
|
+
|
|
90
|
+
/* Allow for a "no padding" mode */
|
|
91
|
+
if (noPadding) {
|
|
92
|
+
decipher.mode.unpad = function(output, options) {
|
|
93
|
+
return true;
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
88
97
|
decipher.start({iv: iv});
|
|
89
98
|
decipher.update(forge.util.createBuffer(input));
|
|
90
99
|
const result = decipher.finish();
|
|
@@ -275,7 +275,10 @@ import SHA0 from "./SHA0.mjs";
|
|
|
275
275
|
import SHA1 from "./SHA1.mjs";
|
|
276
276
|
import SHA2 from "./SHA2.mjs";
|
|
277
277
|
import SHA3 from "./SHA3.mjs";
|
|
278
|
+
import SIGABA from "./SIGABA.mjs";
|
|
278
279
|
import SM3 from "./SM3.mjs";
|
|
280
|
+
import SM4Decrypt from "./SM4Decrypt.mjs";
|
|
281
|
+
import SM4Encrypt from "./SM4Encrypt.mjs";
|
|
279
282
|
import SQLBeautify from "./SQLBeautify.mjs";
|
|
280
283
|
import SQLMinify from "./SQLMinify.mjs";
|
|
281
284
|
import SSDEEP from "./SSDEEP.mjs";
|
|
@@ -644,7 +647,10 @@ export {
|
|
|
644
647
|
SHA1,
|
|
645
648
|
SHA2,
|
|
646
649
|
SHA3,
|
|
650
|
+
SIGABA,
|
|
647
651
|
SM3,
|
|
652
|
+
SM4Decrypt,
|
|
653
|
+
SM4Encrypt,
|
|
648
654
|
SQLBeautify,
|
|
649
655
|
SQLMinify,
|
|
650
656
|
SSDEEP,
|
package/src/node/index.mjs
CHANGED
|
@@ -276,7 +276,10 @@ import {
|
|
|
276
276
|
SHA1 as core_SHA1,
|
|
277
277
|
SHA2 as core_SHA2,
|
|
278
278
|
SHA3 as core_SHA3,
|
|
279
|
+
SIGABA as core_SIGABA,
|
|
279
280
|
SM3 as core_SM3,
|
|
281
|
+
SM4Decrypt as core_SM4Decrypt,
|
|
282
|
+
SM4Encrypt as core_SM4Encrypt,
|
|
280
283
|
SQLBeautify as core_SQLBeautify,
|
|
281
284
|
SQLMinify as core_SQLMinify,
|
|
282
285
|
SSDEEP as core_SSDEEP,
|
|
@@ -645,7 +648,10 @@ function generateChef() {
|
|
|
645
648
|
"SHA1": _wrap(core_SHA1),
|
|
646
649
|
"SHA2": _wrap(core_SHA2),
|
|
647
650
|
"SHA3": _wrap(core_SHA3),
|
|
651
|
+
"SIGABA": _wrap(core_SIGABA),
|
|
648
652
|
"SM3": _wrap(core_SM3),
|
|
653
|
+
"SM4Decrypt": _wrap(core_SM4Decrypt),
|
|
654
|
+
"SM4Encrypt": _wrap(core_SM4Encrypt),
|
|
649
655
|
"SQLBeautify": _wrap(core_SQLBeautify),
|
|
650
656
|
"SQLMinify": _wrap(core_SQLMinify),
|
|
651
657
|
"SSDEEP": _wrap(core_SSDEEP),
|
|
@@ -1031,7 +1037,10 @@ const SHA0 = chef.SHA0;
|
|
|
1031
1037
|
const SHA1 = chef.SHA1;
|
|
1032
1038
|
const SHA2 = chef.SHA2;
|
|
1033
1039
|
const SHA3 = chef.SHA3;
|
|
1040
|
+
const SIGABA = chef.SIGABA;
|
|
1034
1041
|
const SM3 = chef.SM3;
|
|
1042
|
+
const SM4Decrypt = chef.SM4Decrypt;
|
|
1043
|
+
const SM4Encrypt = chef.SM4Encrypt;
|
|
1035
1044
|
const SQLBeautify = chef.SQLBeautify;
|
|
1036
1045
|
const SQLMinify = chef.SQLMinify;
|
|
1037
1046
|
const SSDEEP = chef.SSDEEP;
|
|
@@ -1402,7 +1411,10 @@ const operations = [
|
|
|
1402
1411
|
SHA1,
|
|
1403
1412
|
SHA2,
|
|
1404
1413
|
SHA3,
|
|
1414
|
+
SIGABA,
|
|
1405
1415
|
SM3,
|
|
1416
|
+
SM4Decrypt,
|
|
1417
|
+
SM4Encrypt,
|
|
1406
1418
|
SQLBeautify,
|
|
1407
1419
|
SQLMinify,
|
|
1408
1420
|
SSDEEP,
|
|
@@ -1777,7 +1789,10 @@ export {
|
|
|
1777
1789
|
SHA1,
|
|
1778
1790
|
SHA2,
|
|
1779
1791
|
SHA3,
|
|
1792
|
+
SIGABA,
|
|
1780
1793
|
SM3,
|
|
1794
|
+
SM4Decrypt,
|
|
1795
|
+
SM4Encrypt,
|
|
1781
1796
|
SQLBeautify,
|
|
1782
1797
|
SQLMinify,
|
|
1783
1798
|
SSDEEP,
|
|
@@ -119,7 +119,7 @@ TestRegister.addApiTests([
|
|
|
119
119
|
assert.strictEqual(result[0].module, "Ciphers");
|
|
120
120
|
assert.strictEqual(result[0].inputType, "string");
|
|
121
121
|
assert.strictEqual(result[0].outputType, "string");
|
|
122
|
-
assert.strictEqual(result[0].description, "Triple DES applies DES three times to each block to increase key size.<br><br><b>Key:</b> Triple DES uses a key length of 24 bytes (192 bits).<br>DES uses a key length of 8 bytes (64 bits).<br><br><b>IV:</b> The Initialization Vector should be 8 bytes long. If not entered, it will default to 8 null bytes.<br><br><b>Padding:</b> In CBC and ECB mode, PKCS#7 padding will be used.");
|
|
122
|
+
assert.strictEqual(result[0].description, "Triple DES applies DES three times to each block to increase key size.<br><br><b>Key:</b> Triple DES uses a key length of 24 bytes (192 bits).<br>DES uses a key length of 8 bytes (64 bits).<br><br><b>IV:</b> The Initialization Vector should be 8 bytes long. If not entered, it will default to 8 null bytes.<br><br><b>Padding:</b> In CBC and ECB mode, PKCS#7 padding will be used as a default.");
|
|
123
123
|
assert.strictEqual(result[0].args.length, 5);
|
|
124
124
|
}),
|
|
125
125
|
|
|
@@ -75,6 +75,7 @@ import "./tests/SeqUtils.mjs";
|
|
|
75
75
|
import "./tests/SetDifference.mjs";
|
|
76
76
|
import "./tests/SetIntersection.mjs";
|
|
77
77
|
import "./tests/SetUnion.mjs";
|
|
78
|
+
import "./tests/SM4.mjs";
|
|
78
79
|
import "./tests/StrUtils.mjs";
|
|
79
80
|
import "./tests/SymmetricDifference.mjs";
|
|
80
81
|
import "./tests/TextEncodingBruteForce.mjs";
|
|
@@ -109,6 +110,8 @@ import "./tests/JA3Fingerprint.mjs";
|
|
|
109
110
|
import "./tests/JA3SFingerprint.mjs";
|
|
110
111
|
import "./tests/HASSH.mjs";
|
|
111
112
|
import "./tests/GetAllCasings.mjs";
|
|
113
|
+
import "./tests/SIGABA.mjs";
|
|
114
|
+
|
|
112
115
|
|
|
113
116
|
// Cannot test operations that use the File type yet
|
|
114
117
|
// import "./tests/SplitColourChannels.mjs";
|
|
@@ -11,7 +11,7 @@ TestRegister.addTests([
|
|
|
11
11
|
{
|
|
12
12
|
name: "All casings of test",
|
|
13
13
|
input: "test",
|
|
14
|
-
expectedOutput: "test\nTest\ntEst\nTEst\nteSt\nTeSt\ntESt\nTESt\ntesT\nTesT\ntEsT\nTEsT\nteST\nTeST\ntEST\nTEST
|
|
14
|
+
expectedOutput: "test\nTest\ntEst\nTEst\nteSt\nTeSt\ntESt\nTESt\ntesT\nTesT\ntEsT\nTEsT\nteST\nTeST\ntEST\nTEST",
|
|
15
15
|
recipeConfig: [
|
|
16
16
|
{
|
|
17
17
|
"op": "Get All Casings",
|
|
@@ -22,7 +22,7 @@ TestRegister.addTests([
|
|
|
22
22
|
{
|
|
23
23
|
name: "All casings of t",
|
|
24
24
|
input: "t",
|
|
25
|
-
expectedOutput: "t\nT
|
|
25
|
+
expectedOutput: "t\nT",
|
|
26
26
|
recipeConfig: [
|
|
27
27
|
{
|
|
28
28
|
"op": "Get All Casings",
|
|
@@ -33,7 +33,7 @@ TestRegister.addTests([
|
|
|
33
33
|
{
|
|
34
34
|
name: "All casings of null",
|
|
35
35
|
input: "",
|
|
36
|
-
expectedOutput: "
|
|
36
|
+
expectedOutput: "",
|
|
37
37
|
recipeConfig: [
|
|
38
38
|
{
|
|
39
39
|
"op": "Get All Casings",
|