cyberchef 11.1.0 → 11.3.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.
Files changed (148) hide show
  1. package/AGENTS.md +75 -0
  2. package/CHANGELOG.md +173 -2
  3. package/Dockerfile +2 -2
  4. package/Gruntfile.js +1 -0
  5. package/README.md +7 -6
  6. package/SECURITY.md +3 -1
  7. package/package.json +22 -21
  8. package/src/core/Chef.mjs +2 -0
  9. package/src/core/Dish.mjs +1 -5
  10. package/src/core/Ingredient.mjs +92 -0
  11. package/src/core/Operation.mjs +19 -0
  12. package/src/core/Recipe.mjs +4 -0
  13. package/src/core/Utils.mjs +48 -0
  14. package/src/core/config/Categories.json +22 -6
  15. package/src/core/config/OperationConfig.json +4774 -1228
  16. package/src/core/config/modules/Ciphers.mjs +20 -0
  17. package/src/core/config/modules/Crypto.mjs +10 -0
  18. package/src/core/config/modules/Default.mjs +8 -0
  19. package/src/core/config/modules/File.mjs +16 -0
  20. package/src/core/config/modules/OpModules.mjs +2 -0
  21. package/src/core/config/scripts/generateHTMLEntities.mjs +139 -0
  22. package/src/core/config/scripts/htmlEntityOverrides.mjs +86 -0
  23. package/src/core/dishTypes/DishType.mjs +1 -1
  24. package/src/core/errors/ExcludedOperationError.mjs +1 -1
  25. package/src/core/lib/Arithmetic.mjs +21 -5
  26. package/src/core/lib/BigIntUtils.mjs +0 -1
  27. package/src/core/lib/COBS.mjs +86 -0
  28. package/src/core/lib/Charts.mjs +3 -3
  29. package/src/core/lib/Decimal.mjs +5 -5
  30. package/src/core/lib/HTMLEntities.mjs +2068 -0
  31. package/src/core/lib/Present.mjs +422 -0
  32. package/src/core/lib/Protocol.mjs +8 -6
  33. package/src/core/lib/TEA.mjs +494 -0
  34. package/src/core/lib/TLVParser.mjs +16 -7
  35. package/src/core/lib/Twofish.mjs +608 -0
  36. package/src/core/operations/AsconDecrypt.mjs +112 -0
  37. package/src/core/operations/AsconEncrypt.mjs +108 -0
  38. package/src/core/operations/AsconHash.mjs +49 -0
  39. package/src/core/operations/AsconMAC.mjs +68 -0
  40. package/src/core/operations/AutomatedValidationTestOp.mjs +84 -0
  41. package/src/core/operations/AvroToJSON.mjs +1 -1
  42. package/src/core/operations/BLAKE3.mjs +5 -1
  43. package/src/core/operations/BcryptCompare.mjs +11 -5
  44. package/src/core/operations/BitShiftLeft.mjs +4 -1
  45. package/src/core/operations/Bzip2Compress.mjs +1 -1
  46. package/src/core/operations/DechunkHTTPResponse.mjs +4 -1
  47. package/src/core/operations/ExtendedGCD.mjs +101 -0
  48. package/src/core/operations/FromBase.mjs +2 -1
  49. package/src/core/operations/FromCOBS.mjs +38 -0
  50. package/src/core/operations/FromDecimal.mjs +6 -1
  51. package/src/core/operations/FromHTMLEntity.mjs +2 -1458
  52. package/src/core/operations/GenerateDeBruijnSequence.mjs +8 -0
  53. package/src/core/operations/GenerateHOTP.mjs +21 -6
  54. package/src/core/operations/GenerateImage.mjs +22 -10
  55. package/src/core/operations/GeneratePrime.mjs +154 -0
  56. package/src/core/operations/GenerateTOTP.mjs +24 -7
  57. package/src/core/operations/Gzip.mjs +1 -3
  58. package/src/core/operations/Jsonata.mjs +12 -0
  59. package/src/core/operations/MIMEDecoding.mjs +1 -1
  60. package/src/core/operations/MOD.mjs +62 -0
  61. package/src/core/operations/ModularInverse.mjs +107 -0
  62. package/src/core/operations/PRESENTDecrypt.mjs +94 -0
  63. package/src/core/operations/PRESENTEncrypt.mjs +94 -0
  64. package/src/core/operations/ParityBit.mjs +1 -1
  65. package/src/core/operations/ParseIPv4Header.mjs +1 -1
  66. package/src/core/operations/ParseURI.mjs +18 -5
  67. package/src/core/operations/PseudoRandomNumberGenerator.mjs +2 -1
  68. package/src/core/operations/RandomPrime.mjs +154 -0
  69. package/src/core/operations/RenderPDF.mjs +100 -0
  70. package/src/core/operations/SHA2.mjs +1 -1
  71. package/src/core/operations/SM4Encrypt.mjs +1 -1
  72. package/src/core/operations/SetDifference.mjs +8 -1
  73. package/src/core/operations/SetIntersection.mjs +8 -1
  74. package/src/core/operations/ShowOnMap.mjs +14 -2
  75. package/src/core/operations/TEADecrypt.mjs +98 -0
  76. package/src/core/operations/TEAEncrypt.mjs +98 -0
  77. package/src/core/operations/ToBase.mjs +4 -4
  78. package/src/core/operations/ToBase32.mjs +20 -4
  79. package/src/core/operations/ToBinary.mjs +4 -1
  80. package/src/core/operations/ToCOBS.mjs +38 -0
  81. package/src/core/operations/ToHTMLEntity.mjs +7 -1430
  82. package/src/core/operations/ToHexdump.mjs +7 -1
  83. package/src/core/operations/TwofishDecrypt.mjs +94 -0
  84. package/src/core/operations/TwofishEncrypt.mjs +94 -0
  85. package/src/core/operations/URLEncode.mjs +22 -18
  86. package/src/core/operations/UnescapeUnicodeCharacters.mjs +2 -1
  87. package/src/core/operations/ViewBitPlane.mjs +9 -3
  88. package/src/core/operations/Wrap.mjs +5 -0
  89. package/src/core/operations/XORBruteForce.mjs +4 -1
  90. package/src/core/operations/XORChecksum.mjs +10 -3
  91. package/src/core/operations/XTEADecrypt.mjs +110 -0
  92. package/src/core/operations/XTEAEncrypt.mjs +110 -0
  93. package/src/core/operations/index.mjs +42 -0
  94. package/src/core/vendor/ascon.mjs +162 -0
  95. package/src/core/vendor/htmlEntities/entity.json +2233 -0
  96. package/src/core/vendor/htmlEntities/entity.txt +14 -0
  97. package/src/node/api.mjs +4 -1
  98. package/src/node/index.mjs +105 -0
  99. package/src/web/HTMLOperation.mjs +2 -1
  100. package/src/web/stylesheets/layout/_io.css +8 -0
  101. package/tests/browser/00_nightwatch.js +26 -0
  102. package/tests/browser/02_ops.js +20 -4
  103. package/tests/node/index.mjs +2 -0
  104. package/tests/node/tests/Dish.mjs +19 -0
  105. package/tests/node/tests/NodeDish.mjs +36 -0
  106. package/tests/node/tests/ToHTMLEntity.mjs +82 -0
  107. package/tests/node/tests/Utils.mjs +77 -0
  108. package/tests/node/tests/lib/ChartsProtocolPrototypePollution.mjs +90 -0
  109. package/tests/node/tests/nodeApi.mjs +33 -1
  110. package/tests/node/tests/operations.mjs +26 -1
  111. package/tests/operations/index.mjs +17 -0
  112. package/tests/operations/tests/Arithmetic.mjs +33 -0
  113. package/tests/operations/tests/Ascon.mjs +501 -0
  114. package/tests/operations/tests/AutomatedValidation.mjs +154 -0
  115. package/tests/operations/tests/BLAKE3.mjs +39 -1
  116. package/tests/operations/tests/Base32.mjs +22 -0
  117. package/tests/operations/tests/COBS.mjs +476 -0
  118. package/tests/operations/tests/CharEnc.mjs +2 -2
  119. package/tests/operations/tests/DechunkHTTPResponse.mjs +66 -0
  120. package/tests/operations/tests/ExtendedGCD.mjs +78 -0
  121. package/tests/operations/tests/FromBase.mjs +66 -0
  122. package/tests/operations/tests/FromDecimal.mjs +55 -0
  123. package/tests/operations/tests/GenerateLoremIpsum.mjs +2 -2
  124. package/tests/operations/tests/Gzip.mjs +60 -0
  125. package/tests/operations/tests/HTMLEntity.mjs +126 -0
  126. package/tests/operations/tests/Hash.mjs +44 -0
  127. package/tests/operations/tests/Hexdump.mjs +11 -0
  128. package/tests/operations/tests/Image.mjs +26 -0
  129. package/tests/operations/tests/Jsonata.mjs +23 -0
  130. package/tests/operations/tests/MIMEDecoding.mjs +33 -0
  131. package/tests/operations/tests/MOD.mjs +208 -0
  132. package/tests/operations/tests/Median.mjs +33 -0
  133. package/tests/operations/tests/ModularInverse.mjs +78 -0
  134. package/tests/operations/tests/OTP.mjs +167 -2
  135. package/tests/operations/tests/PRESENT.mjs +465 -0
  136. package/tests/operations/tests/ParseIPv4Header.mjs +11 -0
  137. package/tests/operations/tests/ParseTLV.mjs +41 -0
  138. package/tests/operations/tests/RenderPDF.mjs +55 -0
  139. package/tests/operations/tests/SM2.mjs +1 -1
  140. package/tests/operations/tests/SetDifference.mjs +22 -0
  141. package/tests/operations/tests/SetIntersection.mjs +23 -1
  142. package/tests/operations/tests/ShowOnMap.mjs +61 -0
  143. package/tests/operations/tests/TEA.mjs +566 -0
  144. package/tests/operations/tests/Twofish.mjs +486 -0
  145. package/tests/operations/tests/URLEncodeDecode.mjs +26 -0
  146. package/tests/operations/tests/UnescapeUnicodeCharacters.mjs +88 -0
  147. package/tests/operations/tests/Wrap.mjs +44 -0
  148. package/webpack.config.js +3 -3
@@ -212,6 +212,8 @@ class Recipe {
212
212
  self.sendProgressMessage(i + 1, this.opList.length);
213
213
  }
214
214
 
215
+ op.validateIngredients(op.ingValues);
216
+
215
217
  if (op.flowControl) {
216
218
  // Package up the current state
217
219
  let state = {
@@ -239,9 +241,11 @@ class Recipe {
239
241
  // Cannot rely on `err instanceof OperationError` here as extending
240
242
  // native types is not fully supported yet.
241
243
  dish.set(err.message, "string");
244
+ this.lastRunOp = null;
242
245
  return i;
243
246
  } else if (err instanceof DishError || err?.type === "DishError") {
244
247
  dish.set(err.message, "string");
248
+ this.lastRunOp = null;
245
249
  return i;
246
250
  } else {
247
251
  const e = typeof err == "string" ? { message: err } : err;
@@ -1015,6 +1015,7 @@ class Utils {
1015
1015
 
1016
1016
  // Parse bespoke recipe format
1017
1017
  recipe = recipe.replace(/\n/g, "");
1018
+ Utils._validatePrettyRecipe(recipe);
1018
1019
  let m, args;
1019
1020
  const recipeRegex = /([^(]+)\(((?:'[^'\\]*(?:\\.[^'\\]*)*'|[^)/'])*)(\/[^)]+)?\)/g,
1020
1021
  recipeConfig = [];
@@ -1040,6 +1041,53 @@ class Utils {
1040
1041
  }
1041
1042
 
1042
1043
 
1044
+ /**
1045
+ * Performs a linear structural validation pass over pretty recipe syntax.
1046
+ *
1047
+ * @param {string} recipe
1048
+ * @throws {Error} if the recipe is structurally invalid
1049
+ */
1050
+ static _validatePrettyRecipe(recipe) {
1051
+ let i = 0;
1052
+
1053
+ while (i < recipe.length) {
1054
+ const openParen = recipe.indexOf("(", i);
1055
+ if (openParen === -1 || openParen === i) {
1056
+ throw new Error("Invalid recipe");
1057
+ }
1058
+
1059
+ i = openParen + 1;
1060
+ let inString = false,
1061
+ escaped = false,
1062
+ foundCloseParen = false;
1063
+
1064
+ for (; i < recipe.length; i++) {
1065
+ const c = recipe[i];
1066
+
1067
+ if (inString) {
1068
+ if (escaped) {
1069
+ escaped = false;
1070
+ } else if (c === "\\") {
1071
+ escaped = true;
1072
+ } else if (c === "'") {
1073
+ inString = false;
1074
+ }
1075
+ } else if (c === "'") {
1076
+ inString = true;
1077
+ } else if (c === ")") {
1078
+ foundCloseParen = true;
1079
+ i++;
1080
+ break;
1081
+ }
1082
+ }
1083
+
1084
+ if (!foundCloseParen || inString || escaped) {
1085
+ throw new Error("Invalid recipe");
1086
+ }
1087
+ }
1088
+ }
1089
+
1090
+
1043
1091
  /**
1044
1092
  * Formats a list of files or directories.
1045
1093
  *
@@ -83,7 +83,9 @@
83
83
  "Rison Decode",
84
84
  "To Modhex",
85
85
  "From Modhex",
86
- "MIME Decoding"
86
+ "MIME Decoding",
87
+ "To COBS",
88
+ "From COBS"
87
89
  ]
88
90
  },
89
91
  {
@@ -113,6 +115,12 @@
113
115
  "SM4 Decrypt",
114
116
  "RC6 Encrypt",
115
117
  "RC6 Decrypt",
118
+ "Ascon Encrypt",
119
+ "Ascon Decrypt",
120
+ "PRESENT Encrypt",
121
+ "PRESENT Decrypt",
122
+ "Twofish Encrypt",
123
+ "Twofish Decrypt",
116
124
  "GOST Encrypt",
117
125
  "GOST Decrypt",
118
126
  "GOST Sign",
@@ -129,6 +137,10 @@
129
137
  "XOR Brute Force",
130
138
  "Vigenère Encode",
131
139
  "Vigenère Decode",
140
+ "TEA Encrypt",
141
+ "TEA Decrypt",
142
+ "XTEA Encrypt",
143
+ "XTEA Decrypt",
132
144
  "XXTEA Encrypt",
133
145
  "XXTEA Decrypt",
134
146
  "To Morse Code",
@@ -163,6 +175,7 @@
163
175
  "AES Key Wrap",
164
176
  "AES Key Unwrap",
165
177
  "Pseudo-Random Number Generator",
178
+ "Pseudo-Random Prime Generator",
166
179
  "Enigma",
167
180
  "Bombe",
168
181
  "Multiple Bombe",
@@ -231,9 +244,9 @@
231
244
  "Subtract",
232
245
  "Multiply",
233
246
  "Divide",
234
- "Modular Exponentiation",
235
- "Modular Inverse",
247
+ "MOD",
236
248
  "Extended GCD",
249
+ "Modular Inverse",
237
250
  "Mean",
238
251
  "Median",
239
252
  "Standard Deviation",
@@ -446,6 +459,8 @@
446
459
  "BLAKE2b",
447
460
  "BLAKE2s",
448
461
  "BLAKE3",
462
+ "Ascon Hash",
463
+ "Ascon MAC",
449
464
  "GOST Hash",
450
465
  "Streebog",
451
466
  "SSDEEP",
@@ -558,7 +573,7 @@
558
573
  "Scatter chart",
559
574
  "Series chart",
560
575
  "Heatmap chart",
561
- "Extract Audio Metadata"
576
+ "Render PDF"
562
577
  ]
563
578
  },
564
579
  {
@@ -584,7 +599,8 @@
584
599
  "HTML To Text",
585
600
  "Generate Lorem Ipsum",
586
601
  "Numberwang",
587
- "XKCD Random Number"
602
+ "XKCD Random Number",
603
+ "Automated Validation Test Op"
588
604
  ]
589
605
  },
590
606
  {
@@ -602,4 +618,4 @@
602
618
  "Comment"
603
619
  ]
604
620
  }
605
- ]
621
+ ]