Skip to content

Commit 8852712

Browse files
authored
Merge branch 'master' into master
2 parents ae9054d + d3357d2 commit 8852712

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+13009
-3583
lines changed

.cspell.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"version": "0.2",
3+
"language": "en,en-gb",
4+
"words": [],
5+
"dictionaries": [
6+
"npm",
7+
"softwareTerms",
8+
"node",
9+
"html",
10+
"css",
11+
"bash",
12+
"en-gb",
13+
"misc"
14+
],
15+
"ignorePaths": ["package.json", "package-lock.json", "node_modules"]
16+
}
17+

.github/workflows/master.yml

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919

2020
- name: Install
2121
run: |
22+
export DETECT_CHROMEDRIVER_VERSION=true
2223
npm install
2324
npm run setheapsize
2425

.github/workflows/pull_requests.yml

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818

1919
- name: Install
2020
run: |
21+
export DETECT_CHROMEDRIVER_VERSION=true
2122
npm install
2223
npm run setheapsize
2324

package-lock.json

+6,541-3,397
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cyberchef",
3-
"version": "10.19.2",
3+
"version": "10.19.4",
44
"description": "The Cyber Swiss Army Knife for encryption, encoding, compression and data analysis.",
55
"author": "n1474335 <[email protected]>",
66
"homepage": "https://gchq.github.io/CyberChef",
@@ -55,11 +55,13 @@
5555
"babel-plugin-dynamic-import-node": "^2.3.3",
5656
"babel-plugin-transform-builtin-extend": "1.1.2",
5757
"base64-loader": "^1.0.0",
58-
"chromedriver": "^127.0.2",
58+
"chromedriver": "^130.0.0",
5959
"cli-progress": "^3.12.0",
6060
"colors": "^1.4.0",
61+
"compression-webpack-plugin": "^11.1.0",
6162
"copy-webpack-plugin": "^12.0.2",
6263
"core-js": "^3.37.1",
64+
"cspell": "^8.17.3",
6365
"css-loader": "7.1.2",
6466
"eslint": "^9.4.0",
6567
"eslint-plugin-jsdoc": "^48.2.9",
@@ -159,7 +161,7 @@
159161
"notepack.io": "^3.0.1",
160162
"ntlm": "^0.1.3",
161163
"nwmatcher": "^1.4.4",
162-
"otp": "0.1.3",
164+
"otpauth": "9.3.6",
163165
"path": "^0.12.7",
164166
"popper.js": "^1.16.1",
165167
"process": "^0.11.10",
@@ -192,6 +194,7 @@
192194
"testui": "npx grunt testui",
193195
"testuidev": "npx nightwatch --env=dev",
194196
"lint": "npx grunt lint",
197+
"lint:grammar": "cspell ./src",
195198
"postinstall": "npx grunt exec:fixCryptoApiImports && npx grunt exec:fixSnackbarMarkup && npx grunt exec:fixJimpModule",
196199
"newop": "node --experimental-modules --experimental-json-modules src/core/config/scripts/newOperation.mjs",
197200
"minor": "node --experimental-modules --experimental-json-modules src/core/config/scripts/newMinorVersion.mjs",

src/core/config/Categories.json

+15-3
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@
7474
"CBOR Decode",
7575
"Caret/M-decode",
7676
"Rison Encode",
77-
"Rison Decode"
77+
"Rison Decode",
78+
"To Modhex",
79+
"From Modhex",
80+
"MIME Decoding"
7881
]
7982
},
8083
{
@@ -164,6 +167,7 @@
164167
"name": "Public Key",
165168
"ops": [
166169
"Parse X.509 certificate",
170+
"Parse X.509 CRL",
167171
"Parse ASN.1 hex string",
168172
"PEM to Hex",
169173
"Hex to PEM",
@@ -235,9 +239,14 @@
235239
"Parse User Agent",
236240
"Parse IP range",
237241
"Parse IPv6 address",
242+
"IPv6 Transition Addresses",
238243
"Parse IPv4 header",
244+
"Strip IPv4 header",
239245
"Parse TCP",
246+
"Strip TCP header",
247+
"Parse TLS record",
240248
"Parse UDP",
249+
"Strip UDP header",
241250
"Parse SSH Host Key",
242251
"Parse URI",
243252
"URL Encode",
@@ -270,7 +279,8 @@
270279
"Unicode Text Format",
271280
"Remove Diacritics",
272281
"Unescape Unicode Characters",
273-
"Convert to NATO alphabet"
282+
"Convert to NATO alphabet",
283+
"Convert Leet Speak"
274284
]
275285
},
276286
{
@@ -322,7 +332,9 @@
322332
"Unescape string",
323333
"Pseudo-Random Number Generator",
324334
"Sleep",
325-
"File Tree"
335+
"File Tree",
336+
"Take nth bytes",
337+
"Drop nth bytes"
326338
]
327339
},
328340
{

src/core/lib/Extract.mjs

+6
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,9 @@ export const URL_REGEX = new RegExp(protocol + hostname + "(?:" + port + ")?(?:"
6262
* Domain name regular expression
6363
*/
6464
export const DOMAIN_REGEX = /\b((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}\b/ig;
65+
66+
67+
/**
68+
* DMARC Domain name regular expression
69+
*/
70+
export const DMARC_DOMAIN_REGEX = /\b((?=[a-z0-9_-]{1,63}\.)(xn--)?[a-z0-9_]+(-[a-z0-9_]+)*\.)+[a-z]{2,63}\b/ig;

src/core/lib/Modhex.mjs

+165
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
/**
2+
* @author linuxgemini [[email protected]]
3+
* @copyright Crown Copyright 2024
4+
* @license Apache-2.0
5+
*/
6+
7+
import Utils from "../Utils.mjs";
8+
import OperationError from "../errors/OperationError.mjs";
9+
import { fromHex, toHex } from "./Hex.mjs";
10+
11+
/**
12+
* Modhex alphabet.
13+
*/
14+
const MODHEX_ALPHABET = "cbdefghijklnrtuv";
15+
16+
17+
/**
18+
* Modhex alphabet map.
19+
*/
20+
const MODHEX_ALPHABET_MAP = MODHEX_ALPHABET.split("");
21+
22+
23+
/**
24+
* Hex alphabet to substitute Modhex.
25+
*/
26+
const HEX_ALPHABET = "0123456789abcdef";
27+
28+
29+
/**
30+
* Hex alphabet map to substitute Modhex.
31+
*/
32+
const HEX_ALPHABET_MAP = HEX_ALPHABET.split("");
33+
34+
35+
/**
36+
* Convert a byte array into a modhex string.
37+
*
38+
* @param {byteArray|Uint8Array|ArrayBuffer} data
39+
* @param {string} [delim=" "]
40+
* @param {number} [padding=2]
41+
* @returns {string}
42+
*
43+
* @example
44+
* // returns "cl bf bu"
45+
* toModhex([10,20,30]);
46+
*
47+
* // returns "cl:bf:bu"
48+
* toModhex([10,20,30], ":");
49+
*/
50+
export function toModhex(data, delim=" ", padding=2, extraDelim="", lineSize=0) {
51+
if (!data) return "";
52+
if (data instanceof ArrayBuffer) data = new Uint8Array(data);
53+
54+
const regularHexString = toHex(data, "", padding, "", 0);
55+
56+
let modhexString = "";
57+
for (const letter of regularHexString.split("")) {
58+
modhexString += MODHEX_ALPHABET_MAP[HEX_ALPHABET_MAP.indexOf(letter)];
59+
}
60+
61+
let output = "";
62+
const groupingRegexp = new RegExp(`.{1,${padding}}`, "g");
63+
const groupedModhex = modhexString.match(groupingRegexp);
64+
65+
for (let i = 0; i < groupedModhex.length; i++) {
66+
const group = groupedModhex[i];
67+
output += group + delim;
68+
69+
if (extraDelim) {
70+
output += extraDelim;
71+
}
72+
// Add LF after each lineSize amount of bytes but not at the end
73+
if ((i !== groupedModhex.length - 1) && ((i + 1) % lineSize === 0)) {
74+
output += "\n";
75+
}
76+
}
77+
78+
// Remove the extraDelim at the end (if there is one)
79+
// and remove the delim at the end, but if it's prepended there's nothing to remove
80+
const rTruncLen = extraDelim.length + delim.length;
81+
if (rTruncLen) {
82+
// If rTruncLen === 0 then output.slice(0,0) will be returned, which is nothing
83+
return output.slice(0, -rTruncLen);
84+
} else {
85+
return output;
86+
}
87+
}
88+
89+
90+
/**
91+
* Convert a byte array into a modhex string as efficiently as possible with no options.
92+
*
93+
* @param {byteArray|Uint8Array|ArrayBuffer} data
94+
* @returns {string}
95+
*
96+
* @example
97+
* // returns "clbfbu"
98+
* toModhexFast([10,20,30]);
99+
*/
100+
export function toModhexFast(data) {
101+
if (!data) return "";
102+
if (data instanceof ArrayBuffer) data = new Uint8Array(data);
103+
104+
const output = [];
105+
106+
for (let i = 0; i < data.length; i++) {
107+
output.push(MODHEX_ALPHABET_MAP[(data[i] >> 4) & 0xf]);
108+
output.push(MODHEX_ALPHABET_MAP[data[i] & 0xf]);
109+
}
110+
return output.join("");
111+
}
112+
113+
114+
/**
115+
* Convert a modhex string into a byte array.
116+
*
117+
* @param {string} data
118+
* @param {string} [delim]
119+
* @param {number} [byteLen=2]
120+
* @returns {byteArray}
121+
*
122+
* @example
123+
* // returns [10,20,30]
124+
* fromModhex("cl bf bu");
125+
*
126+
* // returns [10,20,30]
127+
* fromModhex("cl:bf:bu", "Colon");
128+
*/
129+
export function fromModhex(data, delim="Auto", byteLen=2) {
130+
if (byteLen < 1 || Math.round(byteLen) !== byteLen)
131+
throw new OperationError("Byte length must be a positive integer");
132+
133+
// The `.replace(/\s/g, "")` an interesting workaround: Hex "multiline" tests aren't actually
134+
// multiline. Tests for Modhex fixes that, thus exposing the issue.
135+
data = data.toLowerCase().replace(/\s/g, "");
136+
137+
if (delim !== "None") {
138+
const delimRegex = delim === "Auto" ? /[^cbdefghijklnrtuv]/gi : Utils.regexRep(delim);
139+
data = data.split(delimRegex);
140+
} else {
141+
data = [data];
142+
}
143+
144+
let regularHexString = "";
145+
for (let i = 0; i < data.length; i++) {
146+
for (const letter of data[i].split("")) {
147+
regularHexString += HEX_ALPHABET_MAP[MODHEX_ALPHABET_MAP.indexOf(letter)];
148+
}
149+
}
150+
151+
const output = fromHex(regularHexString, "None", byteLen);
152+
return output;
153+
}
154+
155+
156+
/**
157+
* To Modhex delimiters.
158+
*/
159+
export const TO_MODHEX_DELIM_OPTIONS = ["Space", "Percent", "Comma", "Semi-colon", "Colon", "Line feed", "CRLF", "None"];
160+
161+
162+
/**
163+
* From Modhex delimiters.
164+
*/
165+
export const FROM_MODHEX_DELIM_OPTIONS = ["Auto"].concat(TO_MODHEX_DELIM_OPTIONS);

src/core/lib/Protocol.mjs

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ export function objToTable(obj, nested=false) {
2626
</tr>`;
2727

2828
for (const key in obj) {
29+
if (typeof obj[key] === "function")
30+
continue;
31+
2932
html += `<tr><td style='word-wrap: break-word'>${key}</td>`;
3033
if (typeof obj[key] === "object")
3134
html += `<td style='padding: 0'>${objToTable(obj[key], true)}</td>`;

src/core/operations/AddLineNumbers.mjs

+9-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,13 @@ class AddLineNumbers extends Operation {
2222
this.description = "Adds line numbers to the output.";
2323
this.inputType = "string";
2424
this.outputType = "string";
25-
this.args = [];
25+
this.args = [
26+
{
27+
"name": "Offset",
28+
"type": "number",
29+
"value": 0
30+
}
31+
];
2632
}
2733

2834
/**
@@ -33,10 +39,11 @@ class AddLineNumbers extends Operation {
3339
run(input, args) {
3440
const lines = input.split("\n"),
3541
width = lines.length.toString().length;
42+
const offset = args[0] ? parseInt(args[0], 10) : 0;
3643
let output = "";
3744

3845
for (let n = 0; n < lines.length; n++) {
39-
output += (n+1).toString().padStart(width, " ") + " " + lines[n] + "\n";
46+
output += (n+1+offset).toString().padStart(width, " ") + " " + lines[n] + "\n";
4047
}
4148
return output.slice(0, output.length-1);
4249
}

src/core/operations/BlowfishDecrypt.mjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ class BlowfishDecrypt extends Operation {
7676
Blowfish's key length needs to be between 4 and 56 bytes (32-448 bits).`);
7777
}
7878

79-
if (iv.length !== 8) {
80-
throw new OperationError(`Invalid IV length: ${iv.length} bytes. Expected 8 bytes`);
79+
if (mode !== "ECB" && iv.length !== 8) {
80+
throw new OperationError(`Invalid IV length: ${iv.length} bytes. Expected 8 bytes.`);
8181
}
8282

8383
input = Utils.convertToByteString(input, inputType);

src/core/operations/BlowfishEncrypt.mjs

+3-3
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@ class BlowfishEncrypt extends Operation {
7272

7373
if (key.length < 4 || key.length > 56) {
7474
throw new OperationError(`Invalid key length: ${key.length} bytes
75-
75+
7676
Blowfish's key length needs to be between 4 and 56 bytes (32-448 bits).`);
7777
}
7878

79-
if (iv.length !== 8) {
80-
throw new OperationError(`Invalid IV length: ${iv.length} bytes. Expected 8 bytes`);
79+
if (mode !== "ECB" && iv.length !== 8) {
80+
throw new OperationError(`Invalid IV length: ${iv.length} bytes. Expected 8 bytes.`);
8181
}
8282

8383
input = Utils.convertToByteString(input, inputType);

0 commit comments

Comments
 (0)