cyberchef 10.22.1 → 10.23.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 +131 -0
- package/CONTRIBUTING.md +37 -0
- package/Dockerfile +2 -0
- package/Gruntfile.js +0 -12
- package/README.md +1 -1
- package/babel.config.js +0 -6
- package/package.json +63 -62
- package/src/core/Chef.mjs +8 -1
- package/src/core/Ingredient.mjs +5 -2
- package/src/core/Operation.mjs +6 -1
- package/src/core/Recipe.mjs +10 -5
- package/src/core/config/Categories.json +18 -3
- package/src/core/config/OperationConfig.json +496 -23
- package/src/core/config/modules/Ciphers.mjs +6 -0
- package/src/core/config/modules/Crypto.mjs +6 -0
- package/src/core/config/modules/Default.mjs +6 -0
- package/src/core/config/modules/Shellcode.mjs +2 -0
- package/src/core/lib/AudioBytes.mjs +103 -0
- package/src/core/lib/AudioMetaSchema.mjs +82 -0
- package/src/core/lib/AudioParsers.mjs +630 -0
- package/src/core/lib/BigIntUtils.mjs +73 -0
- package/src/core/lib/Modhex.mjs +2 -0
- package/src/core/lib/QRCode.mjs +30 -10
- package/src/core/lib/RC6.mjs +625 -0
- package/src/core/operations/A1Z26CipherDecode.mjs +1 -1
- package/src/core/operations/AddTextToImage.mjs +116 -64
- package/src/core/operations/BlurImage.mjs +10 -12
- package/src/core/operations/ContainImage.mjs +50 -40
- package/src/core/operations/ConvertImageFormat.mjs +33 -39
- package/src/core/operations/CoverImage.mjs +39 -37
- package/src/core/operations/CropImage.mjs +35 -21
- package/src/core/operations/DisassembleARM.mjs +193 -0
- package/src/core/operations/DitherImage.mjs +8 -8
- package/src/core/operations/EscapeUnicodeCharacters.mjs +0 -17
- package/src/core/operations/ExtractAudioMetadata.mjs +175 -0
- package/src/core/operations/ExtractLSB.mjs +17 -11
- package/src/core/operations/ExtractRGBA.mjs +12 -10
- package/src/core/operations/FlaskSessionDecode.mjs +80 -0
- package/src/core/operations/FlaskSessionSign.mjs +89 -0
- package/src/core/operations/FlaskSessionVerify.mjs +136 -0
- package/src/core/operations/FlipImage.mjs +14 -10
- package/src/core/operations/GenerateImage.mjs +39 -32
- package/src/core/operations/ImageBrightnessContrast.mjs +10 -10
- package/src/core/operations/ImageFilter.mjs +14 -13
- package/src/core/operations/ImageHueSaturationLightness.mjs +22 -20
- package/src/core/operations/ImageOpacity.mjs +6 -8
- package/src/core/operations/InvertImage.mjs +4 -6
- package/src/core/operations/Jq.mjs +12 -4
- package/src/core/operations/NormaliseImage.mjs +5 -7
- package/src/core/operations/OffsetChecker.mjs +1 -1
- package/src/core/operations/ParseEthernetFrame.mjs +112 -0
- package/src/core/operations/ParseIPv4Header.mjs +23 -6
- package/src/core/operations/ParseQRCode.mjs +13 -13
- package/src/core/operations/PseudoRandomIntegerGenerator.mjs +164 -0
- package/src/core/operations/RC6Decrypt.mjs +119 -0
- package/src/core/operations/RC6Encrypt.mjs +119 -0
- package/src/core/operations/RandomizeColourPalette.mjs +11 -11
- package/src/core/operations/ResizeImage.mjs +30 -23
- package/src/core/operations/RotateImage.mjs +8 -9
- package/src/core/operations/SQLBeautify.mjs +21 -3
- package/src/core/operations/SharpenImage.mjs +94 -62
- package/src/core/operations/SplitColourChannels.mjs +47 -21
- package/src/core/operations/TextIntegerConverter.mjs +123 -0
- package/src/core/operations/UnescapeUnicodeCharacters.mjs +17 -0
- package/src/core/operations/ViewBitPlane.mjs +16 -20
- package/src/core/operations/index.mjs +20 -0
- package/src/node/index.mjs +50 -0
- package/src/web/HTMLIngredient.mjs +24 -43
- package/src/web/Manager.mjs +1 -0
- package/src/web/html/index.html +6 -6
- package/src/web/static/fonts/bmfonts/Roboto72White.fnt +491 -485
- package/src/web/static/fonts/bmfonts/RobotoBlack72White.fnt +494 -488
- package/src/web/static/fonts/bmfonts/RobotoMono72White.fnt +110 -103
- package/src/web/static/fonts/bmfonts/RobotoSlab72White.fnt +498 -492
- package/src/web/stylesheets/layout/_banner.css +30 -0
- package/src/web/stylesheets/layout/_modals.css +5 -0
- package/src/web/stylesheets/utils/_overrides.css +7 -0
- package/src/web/waiters/ControlsWaiter.mjs +82 -0
- package/src/web/waiters/InputWaiter.mjs +12 -6
- package/src/web/waiters/RecipeWaiter.mjs +2 -2
- package/tests/browser/02_ops.js +23 -3
- package/tests/node/index.mjs +1 -0
- package/tests/node/tests/lib/BigIntUtils.mjs +150 -0
- package/tests/node/tests/operations.mjs +9 -7
- package/tests/operations/index.mjs +8 -0
- package/tests/operations/tests/A1Z26CipherDecode.mjs +33 -0
- package/tests/operations/tests/DisassembleARM.mjs +377 -0
- package/tests/operations/tests/ExtractAudioMetadata.mjs +287 -0
- package/tests/operations/tests/FlaskSession.mjs +246 -0
- package/tests/operations/tests/GenerateQRCode.mjs +67 -0
- package/tests/operations/tests/JWTSign.mjs +83 -8
- package/tests/operations/tests/Jq.mjs +32 -0
- package/tests/operations/tests/Modhex.mjs +20 -0
- package/tests/operations/tests/ParseEthernetFrame.mjs +45 -0
- package/tests/operations/tests/RC6.mjs +487 -0
- package/tests/operations/tests/SQLBeautify.mjs +54 -0
- package/tests/operations/tests/TextIntegerConverter.mjs +199 -0
- package/tests/samples/Audio.mjs +73 -0
- package/tests/samples/Images.mjs +0 -12
- package/webpack.config.js +10 -7
- package/src/core/lib/ImageManipulation.mjs +0 -251
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author p-leriche [philip.leriche@cantab.net]
|
|
3
|
+
* @copyright Crown Copyright 2025
|
|
4
|
+
* @license Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import OperationError from "../errors/OperationError.mjs";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Number theory utilities used by cryptographic operations.
|
|
11
|
+
*
|
|
12
|
+
* Currently provides:
|
|
13
|
+
* - parseBigInt
|
|
14
|
+
* - Extended Euclidean Algorithm
|
|
15
|
+
* - Modular Exponentiation
|
|
16
|
+
*
|
|
17
|
+
* Additional algorithms may be added as required.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* parseBigInt helper operation
|
|
22
|
+
*/
|
|
23
|
+
export function parseBigInt(value, param) {
|
|
24
|
+
const v = (value ?? "").trim();
|
|
25
|
+
if (/^0x[0-9a-f]+$/i.test(v)) return BigInt(v);
|
|
26
|
+
if (/^[+-]?[0-9]+$/.test(v)) return BigInt(v);
|
|
27
|
+
throw new OperationError(param + " must be decimal or hex (0x...)");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Extended Euclidean Algorithm
|
|
32
|
+
*
|
|
33
|
+
* Returns [g, x, y] such that:
|
|
34
|
+
* a*x + b*y = g = gcd(a, b)
|
|
35
|
+
*
|
|
36
|
+
* (Uses an iterative algorithm to avoid possible stack overflow)
|
|
37
|
+
*/
|
|
38
|
+
export function egcd(a, b) {
|
|
39
|
+
let oldR = a, r = b;
|
|
40
|
+
let oldS = 1n, s = 0n;
|
|
41
|
+
let oldT = 0n, t = 1n;
|
|
42
|
+
|
|
43
|
+
while (r !== 0n) {
|
|
44
|
+
const quotient = oldR / r;
|
|
45
|
+
|
|
46
|
+
[oldR, r] = [r, oldR - quotient * r];
|
|
47
|
+
[oldS, s] = [s, oldS - quotient * s];
|
|
48
|
+
[oldT, t] = [t, oldT - quotient * t];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// oldR is the gcd
|
|
52
|
+
// oldS and oldT are the Bézout coefficients
|
|
53
|
+
return [oldR, oldS, oldT];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Modular exponentiation
|
|
58
|
+
*/
|
|
59
|
+
export function modPow(base, exponent, modulus) {
|
|
60
|
+
let result = 1n;
|
|
61
|
+
base %= modulus;
|
|
62
|
+
|
|
63
|
+
while (exponent > 0n) {
|
|
64
|
+
if (exponent & 1n) {
|
|
65
|
+
result = (result * base) % modulus;
|
|
66
|
+
}
|
|
67
|
+
base = (base * base) % modulus;
|
|
68
|
+
exponent >>= 1n;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return result;
|
|
72
|
+
}
|
|
73
|
+
|
package/src/core/lib/Modhex.mjs
CHANGED
|
@@ -50,6 +50,7 @@ const HEX_ALPHABET_MAP = HEX_ALPHABET.split("");
|
|
|
50
50
|
export function toModhex(data, delim=" ", padding=2, extraDelim="", lineSize=0) {
|
|
51
51
|
if (!data) return "";
|
|
52
52
|
if (data instanceof ArrayBuffer) data = new Uint8Array(data);
|
|
53
|
+
if (data.length === 0) return "";
|
|
53
54
|
|
|
54
55
|
const regularHexString = toHex(data, "", padding, "", 0);
|
|
55
56
|
|
|
@@ -100,6 +101,7 @@ export function toModhex(data, delim=" ", padding=2, extraDelim="", lineSize=0)
|
|
|
100
101
|
export function toModhexFast(data) {
|
|
101
102
|
if (!data) return "";
|
|
102
103
|
if (data instanceof ArrayBuffer) data = new Uint8Array(data);
|
|
104
|
+
if (data.length === 0) return "";
|
|
103
105
|
|
|
104
106
|
const output = [];
|
|
105
107
|
|
package/src/core/lib/QRCode.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import OperationError from "../errors/OperationError.mjs";
|
|
|
10
10
|
import jsQR from "jsqr";
|
|
11
11
|
import qr from "qr-image";
|
|
12
12
|
import Utils from "../Utils.mjs";
|
|
13
|
-
import Jimp from "jimp
|
|
13
|
+
import { Jimp, JimpMime } from "jimp";
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Parses a QR code image from an image
|
|
@@ -29,18 +29,31 @@ export async function parseQrCode(input, normalise) {
|
|
|
29
29
|
|
|
30
30
|
try {
|
|
31
31
|
if (normalise) {
|
|
32
|
-
image.rgba(false);
|
|
33
|
-
image.background(0xFFFFFFFF);
|
|
34
|
-
image.normalize();
|
|
35
32
|
image.greyscale();
|
|
36
|
-
image
|
|
37
|
-
image = await Jimp.read(image);
|
|
33
|
+
image.normalize();
|
|
38
34
|
}
|
|
39
35
|
} catch (err) {
|
|
40
36
|
throw new OperationError(`Error normalising image. (${err})`);
|
|
41
37
|
}
|
|
42
38
|
|
|
43
|
-
|
|
39
|
+
// Remove transparency which jsQR cannot handle
|
|
40
|
+
image.scan((x, y, idx) => {
|
|
41
|
+
// If pixel is fully transparent, make it opaque white
|
|
42
|
+
if (image.bitmap.data[idx + 3] === 0x00) {
|
|
43
|
+
image.bitmap.data[idx + 0] = 0xff;
|
|
44
|
+
image.bitmap.data[idx + 1] = 0xff;
|
|
45
|
+
image.bitmap.data[idx + 2] = 0xff;
|
|
46
|
+
}
|
|
47
|
+
// Otherwise, make it fully opaque at its existing colour
|
|
48
|
+
image.bitmap.data[idx + 3] = 0xff;
|
|
49
|
+
});
|
|
50
|
+
image = await Jimp.read(await image.getBuffer(JimpMime.jpeg));
|
|
51
|
+
|
|
52
|
+
const qrData = jsQR(
|
|
53
|
+
new Uint8ClampedArray(image.bitmap.data),
|
|
54
|
+
image.width,
|
|
55
|
+
image.height,
|
|
56
|
+
);
|
|
44
57
|
if (qrData) {
|
|
45
58
|
return qrData.data;
|
|
46
59
|
} else {
|
|
@@ -58,7 +71,13 @@ export async function parseQrCode(input, normalise) {
|
|
|
58
71
|
* @param {string} errorCorrection
|
|
59
72
|
* @returns {ArrayBuffer}
|
|
60
73
|
*/
|
|
61
|
-
export function generateQrCode(
|
|
74
|
+
export function generateQrCode(
|
|
75
|
+
input,
|
|
76
|
+
format,
|
|
77
|
+
moduleSize,
|
|
78
|
+
margin,
|
|
79
|
+
errorCorrection,
|
|
80
|
+
) {
|
|
62
81
|
const formats = ["SVG", "EPS", "PDF", "PNG"];
|
|
63
82
|
if (!formats.includes(format.toUpperCase())) {
|
|
64
83
|
throw new OperationError("Unsupported QR code format.");
|
|
@@ -70,7 +89,8 @@ export function generateQrCode(input, format, moduleSize, margin, errorCorrectio
|
|
|
70
89
|
type: format,
|
|
71
90
|
size: moduleSize,
|
|
72
91
|
margin: margin,
|
|
73
|
-
|
|
92
|
+
// eslint-disable-next-line camelcase
|
|
93
|
+
ec_level: errorCorrection.charAt(0).toUpperCase(),
|
|
74
94
|
});
|
|
75
95
|
} catch (err) {
|
|
76
96
|
throw new OperationError(`Error generating QR code. (${err})`);
|
|
@@ -86,7 +106,7 @@ export function generateQrCode(input, format, moduleSize, margin, errorCorrectio
|
|
|
86
106
|
case "PDF":
|
|
87
107
|
return Utils.strToArrayBuffer(qrImage);
|
|
88
108
|
case "PNG":
|
|
89
|
-
return qrImage.buffer;
|
|
109
|
+
return qrImage.buffer.slice(qrImage.byteOffset, qrImage.byteLength + qrImage.byteOffset);
|
|
90
110
|
default:
|
|
91
111
|
throw new OperationError("Unsupported QR code format.");
|
|
92
112
|
}
|