cyberchef 9.39.5 → 9.39.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cyberchef",
3
- "version": "9.39.5",
3
+ "version": "9.39.6",
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",
@@ -6006,6 +6006,26 @@
6006
6006
  "type": "boolean",
6007
6007
  "value": true
6008
6008
  }
6009
+ ],
6010
+ "checks": [
6011
+ {
6012
+ "pattern": "^\\s*(?:<~)?[\\s!-uz]*[!-uz]{15}[\\s!-uz]*(?:~>)?\\s*$",
6013
+ "args": [
6014
+ "!-u"
6015
+ ]
6016
+ },
6017
+ {
6018
+ "pattern": "^[\\s0-9a-zA-Z.\\-:+=^!/*?&<>()[\\]{}@%$#]*[0-9a-zA-Z.\\-:+=^!/*?&<>()[\\]{}@%$#]{15}[\\s0-9a-zA-Z.\\-:+=^!/*?&<>()[\\]{}@%$#]*$",
6019
+ "args": [
6020
+ "0-9a-zA-Z.\\-:+=^!/*?&<>()[]{}@%$#"
6021
+ ]
6022
+ },
6023
+ {
6024
+ "pattern": "^[\\s0-9A-Za-z!#$%&()*+\\-;<=>?@^_`{|}~]*[0-9A-Za-z!#$%&()*+\\-;<=>?@^_`{|}~]{15}[\\s0-9A-Za-z!#$%&()*+\\-;<=>?@^_`{|}~]*$",
6025
+ "args": [
6026
+ "0-9A-Za-z!#$%&()*+\\-;<=>?@^_`{|}~"
6027
+ ]
6028
+ }
6009
6029
  ]
6010
6030
  },
6011
6031
  "From Binary": {
@@ -1,3 +1,5 @@
1
+ import Utils from "../Utils.mjs";
2
+
1
3
  /**
2
4
  * Base85 resources.
3
5
  *
@@ -32,13 +34,12 @@ export const ALPHABET_OPTIONS = [
32
34
  * @returns {string}
33
35
  */
34
36
  export function alphabetName(alphabet) {
35
- alphabet = alphabet.replace(/'/g, "&apos;");
36
- alphabet = alphabet.replace(/"/g, "&quot;");
37
- alphabet = alphabet.replace(/\\/g, "&bsol;");
37
+ alphabet = escape(alphabet);
38
38
  let name;
39
39
 
40
40
  ALPHABET_OPTIONS.forEach(function(a) {
41
- if (escape(alphabet) === escape(a.value)) name = a.name;
41
+ const expanded = Utils.expandAlphRange(a.value).join("");
42
+ if (alphabet === escape(expanded)) name = a.name;
42
43
  });
43
44
 
44
45
  return name;
@@ -38,6 +38,35 @@ class FromBase85 extends Operation {
38
38
  value: true
39
39
  },
40
40
  ];
41
+ this.checks = [
42
+ {
43
+ pattern:
44
+ "^\\s*(?:<~)?" + // Optional whitespace and starting marker
45
+ "[\\s!-uz]*" + // Any amount of base85 characters and whitespace
46
+ "[!-uz]{15}" + // At least 15 continoues base85 characters without whitespace
47
+ "[\\s!-uz]*" + // Any amount of base85 characters and whitespace
48
+ "(?:~>)?\\s*$", // Optional ending marker and whitespace
49
+ args: ["!-u"],
50
+ },
51
+ {
52
+ pattern:
53
+ "^" +
54
+ "[\\s0-9a-zA-Z.\\-:+=^!/*?&<>()[\\]{}@%$#]*" +
55
+ "[0-9a-zA-Z.\\-:+=^!/*?&<>()[\\]{}@%$#]{15}" + // At least 15 continoues base85 characters without whitespace
56
+ "[\\s0-9a-zA-Z.\\-:+=^!/*?&<>()[\\]{}@%$#]*" +
57
+ "$",
58
+ args: ["0-9a-zA-Z.\\-:+=^!/*?&<>()[]{}@%$#"],
59
+ },
60
+ {
61
+ pattern:
62
+ "^" +
63
+ "[\\s0-9A-Za-z!#$%&()*+\\-;<=>?@^_`{|}~]*" +
64
+ "[0-9A-Za-z!#$%&()*+\\-;<=>?@^_`{|}~]{15}" + // At least 15 continoues base85 characters without whitespace
65
+ "[\\s0-9A-Za-z!#$%&()*+\\-;<=>?@^_`{|}~]*" +
66
+ "$",
67
+ args: ["0-9A-Za-z!#$%&()*+\\-;<=>?@^_`{|}~"],
68
+ },
69
+ ];
41
70
  }
42
71
 
43
72
  /**
@@ -56,6 +85,10 @@ class FromBase85 extends Operation {
56
85
  throw new OperationError("Alphabet must be of length 85");
57
86
  }
58
87
 
88
+ // Remove delimiters if present
89
+ const matches = input.match(/^<~(.+?)~>$/);
90
+ if (matches !== null) input = matches[1];
91
+
59
92
  // Remove non-alphabet characters
60
93
  if (removeNonAlphChars) {
61
94
  const re = new RegExp("[^" + alphabet.replace(/[[\]\\\-^$]/g, "\\$&") + "]", "g");
@@ -64,9 +97,6 @@ class FromBase85 extends Operation {
64
97
 
65
98
  if (input.length === 0) return [];
66
99
 
67
- const matches = input.match(/<~(.+?)~>/);
68
- if (matches !== null) input = matches[1];
69
-
70
100
  let i = 0;
71
101
  let block, blockBytes;
72
102
  while (i < input.length) {
@@ -12,6 +12,7 @@
12
12
  import Chef from "../../src/core/Chef.mjs";
13
13
  import Utils from "../../src/core/Utils.mjs";
14
14
  import cliProgress from "cli-progress";
15
+ import log from "loglevel";
15
16
 
16
17
  /**
17
18
  * Object to store and run the list of tests.
@@ -50,6 +51,9 @@ class TestRegister {
50
51
  * Runs all the tests in the register.
51
52
  */
52
53
  async runTests () {
54
+ // Turn off logging to avoid messy errors
55
+ log.setLevel("silent", false);
56
+
53
57
  const progBar = new cliProgress.SingleBar({
54
58
  format: formatter,
55
59
  stopOnComplete: true
@@ -128,6 +132,9 @@ class TestRegister {
128
132
  progBar.increment();
129
133
  }
130
134
 
135
+ // Turn logging back on
136
+ log.setLevel("info", false);
137
+
131
138
  return testResults;
132
139
  }
133
140