cyberchef 9.37.1 → 9.38.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 (34) hide show
  1. package/CHANGELOG.md +7 -2
  2. package/Gruntfile.js +2 -1
  3. package/package.json +2 -2
  4. package/src/core/Utils.mjs +2 -2
  5. package/src/core/config/Categories.json +1 -0
  6. package/src/core/config/OperationConfig.json +106 -3
  7. package/src/core/config/modules/Default.mjs +2 -0
  8. package/src/core/lib/Binary.mjs +9 -5
  9. package/src/core/lib/Extract.mjs +16 -11
  10. package/src/core/lib/FileSignatures.mjs +12 -12
  11. package/src/core/lib/Protocol.mjs +47 -0
  12. package/src/core/lib/Sort.mjs +105 -0
  13. package/src/core/lib/Stream.mjs +22 -12
  14. package/src/core/operations/ExtractDates.mjs +7 -1
  15. package/src/core/operations/ExtractDomains.mjs +29 -5
  16. package/src/core/operations/ExtractEmailAddresses.mjs +29 -5
  17. package/src/core/operations/ExtractFilePaths.mjs +38 -14
  18. package/src/core/operations/ExtractIPAddresses.mjs +44 -27
  19. package/src/core/operations/ExtractMACAddresses.mjs +28 -6
  20. package/src/core/operations/ExtractURLs.mjs +28 -5
  21. package/src/core/operations/ParseTCP.mjs +245 -0
  22. package/src/core/operations/ParseUDP.mjs +29 -24
  23. package/src/core/operations/Sort.mjs +5 -105
  24. package/src/core/operations/Strings.mjs +36 -14
  25. package/src/core/operations/ToBase45.mjs +1 -1
  26. package/src/core/operations/Unique.mjs +25 -5
  27. package/src/core/operations/index.mjs +2 -0
  28. package/src/node/index.mjs +5 -0
  29. package/src/web/waiters/OperationsWaiter.mjs +5 -1
  30. package/tests/node/tests/operations.mjs +3 -4
  31. package/tests/operations/index.mjs +1 -0
  32. package/tests/operations/tests/ExtractEmailAddresses.mjs +4 -4
  33. package/tests/operations/tests/ParseTCP.mjs +44 -0
  34. package/tests/operations/tests/ParseUDP.mjs +5 -18
@@ -6,7 +6,9 @@
6
6
 
7
7
  import Operation from "../Operation.mjs";
8
8
  import Stream from "../lib/Stream.mjs";
9
- import {toHex} from "../lib/Hex.mjs";
9
+ import {toHexFast, fromHex} from "../lib/Hex.mjs";
10
+ import {objToTable} from "../lib/Protocol.mjs";
11
+ import Utils from "../Utils.mjs";
10
12
  import OperationError from "../errors/OperationError.mjs";
11
13
 
12
14
  /**
@@ -24,58 +26,61 @@ class ParseUDP extends Operation {
24
26
  this.module = "Default";
25
27
  this.description = "Parses a UDP header and payload (if present).";
26
28
  this.infoURL = "https://wikipedia.org/wiki/User_Datagram_Protocol";
27
- this.inputType = "ArrayBuffer";
29
+ this.inputType = "string";
28
30
  this.outputType = "json";
29
31
  this.presentType = "html";
30
- this.args = [];
32
+ this.args = [
33
+ {
34
+ name: "Input format",
35
+ type: "option",
36
+ value: ["Hex", "Raw"]
37
+ }
38
+ ];
31
39
  }
32
40
 
33
41
  /**
34
- * @param {ArrayBuffer} input
42
+ * @param {string} input
43
+ * @param {Object[]} args
35
44
  * @returns {Object}
36
45
  */
37
46
  run(input, args) {
38
- if (input.byteLength < 8) {
39
- throw new OperationError("Need 8 bytes for a UDP Header");
47
+ const format = args[0];
48
+
49
+ if (format === "Hex") {
50
+ input = fromHex(input);
51
+ } else if (format === "Raw") {
52
+ input = Utils.strToArrayBuffer(input);
53
+ } else {
54
+ throw new OperationError("Unrecognised input format.");
40
55
  }
41
56
 
42
57
  const s = new Stream(new Uint8Array(input));
58
+ if (s.length < 8) {
59
+ throw new OperationError("Need 8 bytes for a UDP Header");
60
+ }
61
+
43
62
  // Parse Header
44
63
  const UDPPacket = {
45
64
  "Source port": s.readInt(2),
46
65
  "Destination port": s.readInt(2),
47
66
  "Length": s.readInt(2),
48
- "Checksum": toHex(s.getBytes(2), "")
67
+ "Checksum": "0x" + toHexFast(s.getBytes(2))
49
68
  };
50
69
  // Parse data if present
51
70
  if (s.hasMore()) {
52
- UDPPacket.Data = toHex(s.getBytes(UDPPacket.Length - 8), "");
71
+ UDPPacket.Data = "0x" + toHexFast(s.getBytes(UDPPacket.Length - 8));
53
72
  }
54
73
 
55
74
  return UDPPacket;
56
75
  }
57
76
 
58
77
  /**
59
- * Displays the UDP Packet in a table style
78
+ * Displays the UDP Packet in a tabular style
60
79
  * @param {Object} data
61
80
  * @returns {html}
62
81
  */
63
82
  present(data) {
64
- const html = [];
65
- html.push("<table class='table table-hover table-sm table-bordered table-nonfluid' style='table-layout: fixed'>");
66
- html.push("<tr>");
67
- html.push("<th>Field</th>");
68
- html.push("<th>Value</th>");
69
- html.push("</tr>");
70
-
71
- for (const key in data) {
72
- html.push("<tr>");
73
- html.push("<td style=\"word-wrap:break-word\">" + key + "</td>");
74
- html.push("<td>" + data[key] + "</td>");
75
- html.push("</tr>");
76
- }
77
- html.push("</table>");
78
- return html.join("");
83
+ return objToTable(data);
79
84
  }
80
85
 
81
86
  }
@@ -7,6 +7,7 @@
7
7
  import Operation from "../Operation.mjs";
8
8
  import Utils from "../Utils.mjs";
9
9
  import {INPUT_DELIM_OPTIONS} from "../lib/Delim.mjs";
10
+ import {caseInsensitiveSort, ipSort, numericSort, hexadecimalSort} from "../lib/Sort.mjs";
10
11
 
11
12
  /**
12
13
  * Sort operation
@@ -57,120 +58,19 @@ class Sort extends Operation {
57
58
  if (order === "Alphabetical (case sensitive)") {
58
59
  sorted = sorted.sort();
59
60
  } else if (order === "Alphabetical (case insensitive)") {
60
- sorted = sorted.sort(Sort._caseInsensitiveSort);
61
+ sorted = sorted.sort(caseInsensitiveSort);
61
62
  } else if (order === "IP address") {
62
- sorted = sorted.sort(Sort._ipSort);
63
+ sorted = sorted.sort(ipSort);
63
64
  } else if (order === "Numeric") {
64
- sorted = sorted.sort(Sort._numericSort);
65
+ sorted = sorted.sort(numericSort);
65
66
  } else if (order === "Numeric (hexadecimal)") {
66
- sorted = sorted.sort(Sort._hexadecimalSort);
67
+ sorted = sorted.sort(hexadecimalSort);
67
68
  }
68
69
 
69
70
  if (sortReverse) sorted.reverse();
70
71
  return sorted.join(delim);
71
72
  }
72
73
 
73
- /**
74
- * Comparison operation for sorting of strings ignoring case.
75
- *
76
- * @private
77
- * @param {string} a
78
- * @param {string} b
79
- * @returns {number}
80
- */
81
- static _caseInsensitiveSort(a, b) {
82
- return a.toLowerCase().localeCompare(b.toLowerCase());
83
- }
84
-
85
-
86
- /**
87
- * Comparison operation for sorting of IPv4 addresses.
88
- *
89
- * @private
90
- * @param {string} a
91
- * @param {string} b
92
- * @returns {number}
93
- */
94
- static _ipSort(a, b) {
95
- let a_ = a.split("."),
96
- b_ = b.split(".");
97
-
98
- a_ = a_[0] * 0x1000000 + a_[1] * 0x10000 + a_[2] * 0x100 + a_[3] * 1;
99
- b_ = b_[0] * 0x1000000 + b_[1] * 0x10000 + b_[2] * 0x100 + b_[3] * 1;
100
-
101
- if (isNaN(a_) && !isNaN(b_)) return 1;
102
- if (!isNaN(a_) && isNaN(b_)) return -1;
103
- if (isNaN(a_) && isNaN(b_)) return a.localeCompare(b);
104
-
105
- return a_ - b_;
106
- }
107
-
108
- /**
109
- * Comparison operation for sorting of numeric values.
110
- *
111
- * @author Chris van Marle
112
- * @private
113
- * @param {string} a
114
- * @param {string} b
115
- * @returns {number}
116
- */
117
- static _numericSort(a, b) {
118
- const a_ = a.split(/([^\d]+)/),
119
- b_ = b.split(/([^\d]+)/);
120
-
121
- for (let i = 0; i < a_.length && i < b.length; ++i) {
122
- if (isNaN(a_[i]) && !isNaN(b_[i])) return 1; // Numbers after non-numbers
123
- if (!isNaN(a_[i]) && isNaN(b_[i])) return -1;
124
- if (isNaN(a_[i]) && isNaN(b_[i])) {
125
- const ret = a_[i].localeCompare(b_[i]); // Compare strings
126
- if (ret !== 0) return ret;
127
- }
128
- if (!isNaN(a_[i]) && !isNaN(b_[i])) { // Compare numbers
129
- if (a_[i] - b_[i] !== 0) return a_[i] - b_[i];
130
- }
131
- }
132
-
133
- return a.localeCompare(b);
134
- }
135
-
136
- /**
137
- * Comparison operation for sorting of hexadecimal values.
138
- *
139
- * @author Chris van Marle
140
- * @private
141
- * @param {string} a
142
- * @param {string} b
143
- * @returns {number}
144
- */
145
- static _hexadecimalSort(a, b) {
146
- let a_ = a.split(/([^\da-f]+)/i),
147
- b_ = b.split(/([^\da-f]+)/i);
148
-
149
- a_ = a_.map(v => {
150
- const t = parseInt(v, 16);
151
- return isNaN(t) ? v : t;
152
- });
153
-
154
- b_ = b_.map(v => {
155
- const t = parseInt(v, 16);
156
- return isNaN(t) ? v : t;
157
- });
158
-
159
- for (let i = 0; i < a_.length && i < b.length; ++i) {
160
- if (isNaN(a_[i]) && !isNaN(b_[i])) return 1; // Numbers after non-numbers
161
- if (!isNaN(a_[i]) && isNaN(b_[i])) return -1;
162
- if (isNaN(a_[i]) && isNaN(b_[i])) {
163
- const ret = a_[i].localeCompare(b_[i]); // Compare strings
164
- if (ret !== 0) return ret;
165
- }
166
- if (!isNaN(a_[i]) && !isNaN(b_[i])) { // Compare numbers
167
- if (a_[i] - b_[i] !== 0) return a_[i] - b_[i];
168
- }
169
- }
170
-
171
- return a.localeCompare(b);
172
- }
173
-
174
74
  }
175
75
 
176
76
  export default Sort;
@@ -7,6 +7,7 @@
7
7
  import Operation from "../Operation.mjs";
8
8
  import XRegExp from "xregexp";
9
9
  import { search } from "../lib/Extract.mjs";
10
+ import { caseInsensitiveSort } from "../lib/Sort.mjs";
10
11
 
11
12
  /**
12
13
  * Strings operation
@@ -27,27 +28,37 @@ class Strings extends Operation {
27
28
  this.outputType = "string";
28
29
  this.args = [
29
30
  {
30
- "name": "Encoding",
31
- "type": "option",
32
- "value": ["Single byte", "16-bit littleendian", "16-bit bigendian", "All"]
31
+ name: "Encoding",
32
+ type: "option",
33
+ value: ["Single byte", "16-bit littleendian", "16-bit bigendian", "All"]
33
34
  },
34
35
  {
35
- "name": "Minimum length",
36
- "type": "number",
37
- "value": 4
36
+ name: "Minimum length",
37
+ type: "number",
38
+ value: 4
38
39
  },
39
40
  {
40
- "name": "Match",
41
- "type": "option",
42
- "value": [
41
+ name: "Match",
42
+ type: "option",
43
+ value: [
43
44
  "[ASCII]", "Alphanumeric + punctuation (A)", "All printable chars (A)", "Null-terminated strings (A)",
44
45
  "[Unicode]", "Alphanumeric + punctuation (U)", "All printable chars (U)", "Null-terminated strings (U)"
45
46
  ]
46
47
  },
47
48
  {
48
- "name": "Display total",
49
- "type": "boolean",
50
- "value": false
49
+ name: "Display total",
50
+ type: "boolean",
51
+ value: false
52
+ },
53
+ {
54
+ name: "Sort",
55
+ type: "boolean",
56
+ value: false
57
+ },
58
+ {
59
+ name: "Unique",
60
+ type: "boolean",
61
+ value: false
51
62
  }
52
63
  ];
53
64
  }
@@ -58,7 +69,7 @@ class Strings extends Operation {
58
69
  * @returns {string}
59
70
  */
60
71
  run(input, args) {
61
- const [encoding, minLen, matchType, displayTotal] = args,
72
+ const [encoding, minLen, matchType, displayTotal, sort, unique] = args,
62
73
  alphanumeric = "A-Z\\d",
63
74
  punctuation = "/\\-:.,_$%'\"()<>= !\\[\\]{}@",
64
75
  printable = "\x20-\x7e",
@@ -108,8 +119,19 @@ class Strings extends Operation {
108
119
  }
109
120
 
110
121
  const regex = new XRegExp(strings, "ig");
122
+ const results = search(
123
+ input,
124
+ regex,
125
+ null,
126
+ sort ? caseInsensitiveSort : null,
127
+ unique
128
+ );
111
129
 
112
- return search(input, regex, null, displayTotal);
130
+ if (displayTotal) {
131
+ return `Total found: ${results.length}\n\n${results.join("\n")}`;
132
+ } else {
133
+ return results.join("\n");
134
+ }
113
135
  }
114
136
 
115
137
  }
@@ -43,9 +43,9 @@ class ToBase45 extends Operation {
43
43
  * @returns {string}
44
44
  */
45
45
  run(input, args) {
46
+ if (!input) return "";
46
47
  input = new Uint8Array(input);
47
48
  const alphabet = Utils.expandAlphRange(args[0]);
48
- if (!input) return "";
49
49
 
50
50
  const res = [];
51
51
 
@@ -26,9 +26,14 @@ class Unique extends Operation {
26
26
  this.outputType = "string";
27
27
  this.args = [
28
28
  {
29
- "name": "Delimiter",
30
- "type": "option",
31
- "value": INPUT_DELIM_OPTIONS
29
+ name: "Delimiter",
30
+ type: "option",
31
+ value: INPUT_DELIM_OPTIONS
32
+ },
33
+ {
34
+ name: "Display count",
35
+ type: "boolean",
36
+ value: false
32
37
  }
33
38
  ];
34
39
  }
@@ -39,8 +44,23 @@ class Unique extends Operation {
39
44
  * @returns {string}
40
45
  */
41
46
  run(input, args) {
42
- const delim = Utils.charRep(args[0]);
43
- return input.split(delim).unique().join(delim);
47
+ const delim = Utils.charRep(args[0]),
48
+ count = args[1];
49
+
50
+ if (count) {
51
+ const valMap = input.split(delim).reduce((acc, curr) => {
52
+ if (Object.prototype.hasOwnProperty.call(acc, curr)) {
53
+ acc[curr]++;
54
+ } else {
55
+ acc[curr] = 1;
56
+ }
57
+ return acc;
58
+ }, {});
59
+
60
+ return Object.keys(valMap).map(val => `${valMap[val]} ${val}`).join(delim);
61
+ } else {
62
+ return input.split(delim).unique().join(delim);
63
+ }
44
64
  }
45
65
 
46
66
  }
@@ -229,6 +229,7 @@ import ParseIPv6Address from "./ParseIPv6Address.mjs";
229
229
  import ParseObjectIDTimestamp from "./ParseObjectIDTimestamp.mjs";
230
230
  import ParseQRCode from "./ParseQRCode.mjs";
231
231
  import ParseSSHHostKey from "./ParseSSHHostKey.mjs";
232
+ import ParseTCP from "./ParseTCP.mjs";
232
233
  import ParseTLV from "./ParseTLV.mjs";
233
234
  import ParseUDP from "./ParseUDP.mjs";
234
235
  import ParseUNIXFilePermissions from "./ParseUNIXFilePermissions.mjs";
@@ -601,6 +602,7 @@ export {
601
602
  ParseObjectIDTimestamp,
602
603
  ParseQRCode,
603
604
  ParseSSHHostKey,
605
+ ParseTCP,
604
606
  ParseTLV,
605
607
  ParseUDP,
606
608
  ParseUNIXFilePermissions,
@@ -230,6 +230,7 @@ import {
230
230
  ParseObjectIDTimestamp as core_ParseObjectIDTimestamp,
231
231
  ParseQRCode as core_ParseQRCode,
232
232
  ParseSSHHostKey as core_ParseSSHHostKey,
233
+ ParseTCP as core_ParseTCP,
233
234
  ParseTLV as core_ParseTLV,
234
235
  ParseUDP as core_ParseUDP,
235
236
  ParseUNIXFilePermissions as core_ParseUNIXFilePermissions,
@@ -602,6 +603,7 @@ function generateChef() {
602
603
  "parseObjectIDTimestamp": _wrap(core_ParseObjectIDTimestamp),
603
604
  "parseQRCode": _wrap(core_ParseQRCode),
604
605
  "parseSSHHostKey": _wrap(core_ParseSSHHostKey),
606
+ "parseTCP": _wrap(core_ParseTCP),
605
607
  "parseTLV": _wrap(core_ParseTLV),
606
608
  "parseUDP": _wrap(core_ParseUDP),
607
609
  "parseUNIXFilePermissions": _wrap(core_ParseUNIXFilePermissions),
@@ -991,6 +993,7 @@ const parseIPv6Address = chef.parseIPv6Address;
991
993
  const parseObjectIDTimestamp = chef.parseObjectIDTimestamp;
992
994
  const parseQRCode = chef.parseQRCode;
993
995
  const parseSSHHostKey = chef.parseSSHHostKey;
996
+ const parseTCP = chef.parseTCP;
994
997
  const parseTLV = chef.parseTLV;
995
998
  const parseUDP = chef.parseUDP;
996
999
  const parseUNIXFilePermissions = chef.parseUNIXFilePermissions;
@@ -1365,6 +1368,7 @@ const operations = [
1365
1368
  parseObjectIDTimestamp,
1366
1369
  parseQRCode,
1367
1370
  parseSSHHostKey,
1371
+ parseTCP,
1368
1372
  parseTLV,
1369
1373
  parseUDP,
1370
1374
  parseUNIXFilePermissions,
@@ -1743,6 +1747,7 @@ export {
1743
1747
  parseObjectIDTimestamp,
1744
1748
  parseQRCode,
1745
1749
  parseSSHHostKey,
1750
+ parseTCP,
1746
1751
  parseTLV,
1747
1752
  parseUDP,
1748
1753
  parseUNIXFilePermissions,
@@ -109,11 +109,15 @@ class OperationsWaiter {
109
109
  const matchedOps = [];
110
110
  const matchedDescs = [];
111
111
 
112
+ // Create version with no whitespace for the fuzzy match
113
+ // Helps avoid missing matches e.g. query "TCP " would not find "Parse TCP"
114
+ const inStrNWS = inStr.replace(/\s/g, "");
115
+
112
116
  for (const opName in this.app.operations) {
113
117
  const op = this.app.operations[opName];
114
118
 
115
119
  // Match op name using fuzzy match
116
- const [nameMatch, score, idxs] = fuzzyMatch(inStr, opName);
120
+ const [nameMatch, score, idxs] = fuzzyMatch(inStrNWS, opName);
117
121
 
118
122
  // Match description based on exact match
119
123
  const descPos = op.description.toLowerCase().indexOf(inStr.toLowerCase());
@@ -471,7 +471,7 @@ color: white;
471
471
  }),
472
472
 
473
473
  it("Extract dates", () => {
474
- assert.strictEqual(chef.extractDates("Don't Look a Gift Horse In The Mouth 01/02/1992").toString(), "01/02/1992\n");
474
+ assert.strictEqual(chef.extractDates("Don't Look a Gift Horse In The Mouth 01/02/1992").toString(), "01/02/1992");
475
475
  }),
476
476
 
477
477
  it("Filter", () => {
@@ -859,7 +859,7 @@ pCGTErs=
859
859
  }),
860
860
 
861
861
  it("SQL Beautify", () => {
862
- const result = chef.SQLBeautify(`SELECT MONTH, ID, RAIN_I, TEMP_F
862
+ const result = chef.SQLBeautify(`SELECT MONTH, ID, RAIN_I, TEMP_F
863
863
  FROM STATS;`);
864
864
  const expected = `SELECT MONTH,
865
865
  ID,
@@ -879,8 +879,7 @@ FROM STATS;`;
879
879
  const result = chef.strings("smothering ampersand abreast", {displayTotal: true});
880
880
  const expected = `Total found: 1
881
881
 
882
- smothering ampersand abreast
883
- `;
882
+ smothering ampersand abreast`;
884
883
  assert.strictEqual(result.toString(), expected);
885
884
  }),
886
885
 
@@ -96,6 +96,7 @@ import "./tests/Protobuf.mjs";
96
96
  import "./tests/ParseSSHHostKey.mjs";
97
97
  import "./tests/DefangIP.mjs";
98
98
  import "./tests/ParseUDP.mjs";
99
+ import "./tests/ParseTCP.mjs";
99
100
  import "./tests/AvroToJSON.mjs";
100
101
  import "./tests/Lorenz.mjs";
101
102
  import "./tests/LuhnChecksum.mjs";
@@ -11,7 +11,7 @@ TestRegister.addTests([
11
11
  {
12
12
  name: "Extract email address",
13
13
  input: "email@example.com\nfirstname.lastname@example.com\nemail@subdomain.example.com\nfirstname+lastname@example.com\n1234567890@example.com\nemail@example-one.com\n_______@example.com email@example.name\nemail@example.museum email@example.co.jp firstname-lastname@example.com",
14
- expectedOutput: "email@example.com\nfirstname.lastname@example.com\nemail@subdomain.example.com\nfirstname+lastname@example.com\n1234567890@example.com\nemail@example-one.com\n_______@example.com\nemail@example.name\nemail@example.museum\nemail@example.co.jp\nfirstname-lastname@example.com\n",
14
+ expectedOutput: "email@example.com\nfirstname.lastname@example.com\nemail@subdomain.example.com\nfirstname+lastname@example.com\n1234567890@example.com\nemail@example-one.com\n_______@example.com\nemail@example.name\nemail@example.museum\nemail@example.co.jp\nfirstname-lastname@example.com",
15
15
  recipeConfig: [
16
16
  {
17
17
  "op": "Extract email addresses",
@@ -22,7 +22,7 @@ TestRegister.addTests([
22
22
  {
23
23
  name: "Extract email address - Display total",
24
24
  input: "email@example.com\nfirstname.lastname@example.com\nemail@subdomain.example.com\nfirstname+lastname@example.com\n1234567890@example.com\nemail@example-one.com\n_______@example.com email@example.name\nemail@example.museum email@example.co.jp firstname-lastname@example.com",
25
- expectedOutput: "Total found: 11\n\nemail@example.com\nfirstname.lastname@example.com\nemail@subdomain.example.com\nfirstname+lastname@example.com\n1234567890@example.com\nemail@example-one.com\n_______@example.com\nemail@example.name\nemail@example.museum\nemail@example.co.jp\nfirstname-lastname@example.com\n",
25
+ expectedOutput: "Total found: 11\n\nemail@example.com\nfirstname.lastname@example.com\nemail@subdomain.example.com\nfirstname+lastname@example.com\n1234567890@example.com\nemail@example-one.com\n_______@example.com\nemail@example.name\nemail@example.museum\nemail@example.co.jp\nfirstname-lastname@example.com",
26
26
  recipeConfig: [
27
27
  {
28
28
  "op": "Extract email addresses",
@@ -33,7 +33,7 @@ TestRegister.addTests([
33
33
  {
34
34
  name: "Extract email address (Internationalized)",
35
35
  input: "\u4f0a\u662d\u5091@\u90f5\u4ef6.\u5546\u52d9 \u093e\u092e@\u092e\u094b\u0939\u0928.\u0908\u0928\u094d\u092b\u094b\n\u044e\u0437\u0435\u0440@\u0435\u043a\u0437\u0430\u043c\u043f\u043b.\u043a\u043e\u043c \u03b8\u03c3\u03b5\u03c1@\u03b5\u03c7\u03b1\u03bc\u03c0\u03bb\u03b5.\u03c8\u03bf\u03bc Jos\u1ec5Silv\u1ec5@googl\u1ec5.com\nJos\u1ec5Silv\u1ec5@google.com and Jos\u1ec5Silva@google.com\nFoO@BaR.CoM, john@192.168.10.100\ng\xf3mez@junk.br and Abc.123@example.com.\nuser+mailbox/department=shipping@example.com\n\u7528\u6237@\u4f8b\u5b50.\u5e7f\u544a\n\u0909\u092a\u092f\u094b\u0917\u0915\u0930\u094d\u0924\u093e@\u0909\u0926\u093e\u0939\u0930\u0923.\u0915\u0949\u092e\n\u044e\u0437\u0435\u0440@\u0435\u043a\u0437\u0430\u043c\u043f\u043b.\u043a\u043e\u043c\n\u03b8\u03c3\u03b5\u03c1@\u03b5\u03c7\u03b1\u03bc\u03c0\u03bb\u03b5.\u03c8\u03bf\u03bc\nD\xf6rte@S\xf6rensen.example.com\n\u0430\u0434\u0436\u0430\u0439@\u044d\u043a\u0437\u0430\u043c\u043f\u043b.\u0440\u0443\u0441\ntest@xn--bcher-kva.com",
36
- expectedOutput: "\u4f0a\u662d\u5091@\u90f5\u4ef6.\u5546\u52d9\n\u093e\u092e@\u092e\u094b\u0939\u0928.\u0908\u0928\u094d\u092b\u094b\n\u044e\u0437\u0435\u0440@\u0435\u043a\u0437\u0430\u043c\u043f\u043b.\u043a\u043e\u043c\n\u03b8\u03c3\u03b5\u03c1@\u03b5\u03c7\u03b1\u03bc\u03c0\u03bb\u03b5.\u03c8\u03bf\u03bc\nJos\u1ec5Silv\u1ec5@googl\u1ec5.com\nJos\u1ec5Silv\u1ec5@google.com\nJos\u1ec5Silva@google.com\nFoO@BaR.CoM\njohn@192.168.10.100\ng\xf3mez@junk.br\nAbc.123@example.com\nuser+mailbox/department=shipping@example.com\n\u7528\u6237@\u4f8b\u5b50.\u5e7f\u544a\n\u0909\u092a\u092f\u094b\u0917\u0915\u0930\u094d\u0924\u093e@\u0909\u0926\u093e\u0939\u0930\u0923.\u0915\u0949\u092e\n\u044e\u0437\u0435\u0440@\u0435\u043a\u0437\u0430\u043c\u043f\u043b.\u043a\u043e\u043c\n\u03b8\u03c3\u03b5\u03c1@\u03b5\u03c7\u03b1\u03bc\u03c0\u03bb\u03b5.\u03c8\u03bf\u03bc\nD\xf6rte@S\xf6rensen.example.com\n\u0430\u0434\u0436\u0430\u0439@\u044d\u043a\u0437\u0430\u043c\u043f\u043b.\u0440\u0443\u0441\ntest@xn--bcher-kva.com\n",
36
+ expectedOutput: "\u4f0a\u662d\u5091@\u90f5\u4ef6.\u5546\u52d9\n\u093e\u092e@\u092e\u094b\u0939\u0928.\u0908\u0928\u094d\u092b\u094b\n\u044e\u0437\u0435\u0440@\u0435\u043a\u0437\u0430\u043c\u043f\u043b.\u043a\u043e\u043c\n\u03b8\u03c3\u03b5\u03c1@\u03b5\u03c7\u03b1\u03bc\u03c0\u03bb\u03b5.\u03c8\u03bf\u03bc\nJos\u1ec5Silv\u1ec5@googl\u1ec5.com\nJos\u1ec5Silv\u1ec5@google.com\nJos\u1ec5Silva@google.com\nFoO@BaR.CoM\njohn@192.168.10.100\ng\xf3mez@junk.br\nAbc.123@example.com\nuser+mailbox/department=shipping@example.com\n\u7528\u6237@\u4f8b\u5b50.\u5e7f\u544a\n\u0909\u092a\u092f\u094b\u0917\u0915\u0930\u094d\u0924\u093e@\u0909\u0926\u093e\u0939\u0930\u0923.\u0915\u0949\u092e\n\u044e\u0437\u0435\u0440@\u0435\u043a\u0437\u0430\u043c\u043f\u043b.\u043a\u043e\u043c\n\u03b8\u03c3\u03b5\u03c1@\u03b5\u03c7\u03b1\u03bc\u03c0\u03bb\u03b5.\u03c8\u03bf\u03bc\nD\xf6rte@S\xf6rensen.example.com\n\u0430\u0434\u0436\u0430\u0439@\u044d\u043a\u0437\u0430\u043c\u043f\u043b.\u0440\u0443\u0441\ntest@xn--bcher-kva.com",
37
37
  recipeConfig: [
38
38
  {
39
39
  "op": "Extract email addresses",
@@ -44,7 +44,7 @@ TestRegister.addTests([
44
44
  {
45
45
  name: "Extract email address - Display total (Internationalized)",
46
46
  input: "\u4f0a\u662d\u5091@\u90f5\u4ef6.\u5546\u52d9 \u093e\u092e@\u092e\u094b\u0939\u0928.\u0908\u0928\u094d\u092b\u094b\n\u044e\u0437\u0435\u0440@\u0435\u043a\u0437\u0430\u043c\u043f\u043b.\u043a\u043e\u043c \u03b8\u03c3\u03b5\u03c1@\u03b5\u03c7\u03b1\u03bc\u03c0\u03bb\u03b5.\u03c8\u03bf\u03bc Jos\u1ec5Silv\u1ec5@googl\u1ec5.com\nJos\u1ec5Silv\u1ec5@google.com and Jos\u1ec5Silva@google.com\nFoO@BaR.CoM, john@192.168.10.100\ng\xf3mez@junk.br and Abc.123@example.com.\nuser+mailbox/department=shipping@example.com\n\u7528\u6237@\u4f8b\u5b50.\u5e7f\u544a\n\u0909\u092a\u092f\u094b\u0917\u0915\u0930\u094d\u0924\u093e@\u0909\u0926\u093e\u0939\u0930\u0923.\u0915\u0949\u092e\n\u044e\u0437\u0435\u0440@\u0435\u043a\u0437\u0430\u043c\u043f\u043b.\u043a\u043e\u043c\n\u03b8\u03c3\u03b5\u03c1@\u03b5\u03c7\u03b1\u03bc\u03c0\u03bb\u03b5.\u03c8\u03bf\u03bc\nD\xf6rte@S\xf6rensen.example.com\n\u0430\u0434\u0436\u0430\u0439@\u044d\u043a\u0437\u0430\u043c\u043f\u043b.\u0440\u0443\u0441\ntest@xn--bcher-kva.com",
47
- expectedOutput: "Total found: 19\n\n\u4f0a\u662d\u5091@\u90f5\u4ef6.\u5546\u52d9\n\u093e\u092e@\u092e\u094b\u0939\u0928.\u0908\u0928\u094d\u092b\u094b\n\u044e\u0437\u0435\u0440@\u0435\u043a\u0437\u0430\u043c\u043f\u043b.\u043a\u043e\u043c\n\u03b8\u03c3\u03b5\u03c1@\u03b5\u03c7\u03b1\u03bc\u03c0\u03bb\u03b5.\u03c8\u03bf\u03bc\nJos\u1ec5Silv\u1ec5@googl\u1ec5.com\nJos\u1ec5Silv\u1ec5@google.com\nJos\u1ec5Silva@google.com\nFoO@BaR.CoM\njohn@192.168.10.100\ng\xf3mez@junk.br\nAbc.123@example.com\nuser+mailbox/department=shipping@example.com\n\u7528\u6237@\u4f8b\u5b50.\u5e7f\u544a\n\u0909\u092a\u092f\u094b\u0917\u0915\u0930\u094d\u0924\u093e@\u0909\u0926\u093e\u0939\u0930\u0923.\u0915\u0949\u092e\n\u044e\u0437\u0435\u0440@\u0435\u043a\u0437\u0430\u043c\u043f\u043b.\u043a\u043e\u043c\n\u03b8\u03c3\u03b5\u03c1@\u03b5\u03c7\u03b1\u03bc\u03c0\u03bb\u03b5.\u03c8\u03bf\u03bc\nD\xf6rte@S\xf6rensen.example.com\n\u0430\u0434\u0436\u0430\u0439@\u044d\u043a\u0437\u0430\u043c\u043f\u043b.\u0440\u0443\u0441\ntest@xn--bcher-kva.com\n",
47
+ expectedOutput: "Total found: 19\n\n\u4f0a\u662d\u5091@\u90f5\u4ef6.\u5546\u52d9\n\u093e\u092e@\u092e\u094b\u0939\u0928.\u0908\u0928\u094d\u092b\u094b\n\u044e\u0437\u0435\u0440@\u0435\u043a\u0437\u0430\u043c\u043f\u043b.\u043a\u043e\u043c\n\u03b8\u03c3\u03b5\u03c1@\u03b5\u03c7\u03b1\u03bc\u03c0\u03bb\u03b5.\u03c8\u03bf\u03bc\nJos\u1ec5Silv\u1ec5@googl\u1ec5.com\nJos\u1ec5Silv\u1ec5@google.com\nJos\u1ec5Silva@google.com\nFoO@BaR.CoM\njohn@192.168.10.100\ng\xf3mez@junk.br\nAbc.123@example.com\nuser+mailbox/department=shipping@example.com\n\u7528\u6237@\u4f8b\u5b50.\u5e7f\u544a\n\u0909\u092a\u092f\u094b\u0917\u0915\u0930\u094d\u0924\u093e@\u0909\u0926\u093e\u0939\u0930\u0923.\u0915\u0949\u092e\n\u044e\u0437\u0435\u0440@\u0435\u043a\u0437\u0430\u043c\u043f\u043b.\u043a\u043e\u043c\n\u03b8\u03c3\u03b5\u03c1@\u03b5\u03c7\u03b1\u03bc\u03c0\u03bb\u03b5.\u03c8\u03bf\u03bc\nD\xf6rte@S\xf6rensen.example.com\n\u0430\u0434\u0436\u0430\u0439@\u044d\u043a\u0437\u0430\u043c\u043f\u043b.\u0440\u0443\u0441\ntest@xn--bcher-kva.com",
48
48
  recipeConfig: [
49
49
  {
50
50
  "op": "Extract email addresses",
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Parse TCP tests.
3
+ *
4
+ * @author n1474335
5
+ * @copyright Crown Copyright 2022
6
+ * @license Apache-2.0
7
+ */
8
+ import TestRegister from "../../lib/TestRegister.mjs";
9
+
10
+ TestRegister.addTests([
11
+ {
12
+ name: "Parse TCP: No options",
13
+ input: "c2eb0050a138132e70dc9fb9501804025ea70000",
14
+ expectedMatch: /1026 \(Scaled: 1026\)/,
15
+ recipeConfig: [
16
+ {
17
+ op: "Parse TCP",
18
+ args: ["Hex"],
19
+ }
20
+ ],
21
+ },
22
+ {
23
+ name: "Parse TCP: Options",
24
+ input: "c2eb0050a1380c1f000000008002faf080950000020405b40103030801010402",
25
+ expectedMatch: /1460/,
26
+ recipeConfig: [
27
+ {
28
+ op: "Parse TCP",
29
+ args: ["Hex"],
30
+ }
31
+ ],
32
+ },
33
+ {
34
+ name: "Parse TCP: Timestamps",
35
+ input: "9e90e11574d57b2c00000000a002ffffe5740000020405b40402080aa4e8c8f50000000001030308",
36
+ expectedMatch: /2766719221/,
37
+ recipeConfig: [
38
+ {
39
+ op: "Parse TCP",
40
+ args: ["Hex"],
41
+ }
42
+ ],
43
+ }
44
+ ]);
@@ -2,7 +2,6 @@
2
2
  * Parse UDP tests.
3
3
  *
4
4
  * @author h345983745
5
- *
6
5
  * @copyright Crown Copyright 2019
7
6
  * @license Apache-2.0
8
7
  */
@@ -12,15 +11,11 @@ TestRegister.addTests([
12
11
  {
13
12
  name: "Parse UDP: No Data - JSON",
14
13
  input: "04 89 00 35 00 2c 01 01",
15
- expectedOutput: "{\"Source port\":1161,\"Destination port\":53,\"Length\":44,\"Checksum\":\"0101\"}",
14
+ expectedOutput: "{\"Source port\":1161,\"Destination port\":53,\"Length\":44,\"Checksum\":\"0x0101\"}",
16
15
  recipeConfig: [
17
- {
18
- op: "From Hex",
19
- args: ["Auto"],
20
- },
21
16
  {
22
17
  op: "Parse UDP",
23
- args: [],
18
+ args: ["Hex"],
24
19
  },
25
20
  {
26
21
  op: "JSON Minify",
@@ -30,15 +25,11 @@ TestRegister.addTests([
30
25
  }, {
31
26
  name: "Parse UDP: With Data - JSON",
32
27
  input: "04 89 00 35 00 2c 01 01 02 02",
33
- expectedOutput: "{\"Source port\":1161,\"Destination port\":53,\"Length\":44,\"Checksum\":\"0101\",\"Data\":\"0202\"}",
28
+ expectedOutput: "{\"Source port\":1161,\"Destination port\":53,\"Length\":44,\"Checksum\":\"0x0101\",\"Data\":\"0x0202\"}",
34
29
  recipeConfig: [
35
- {
36
- op: "From Hex",
37
- args: ["Auto"],
38
- },
39
30
  {
40
31
  op: "Parse UDP",
41
- args: [],
32
+ args: ["Hex"],
42
33
  },
43
34
  {
44
35
  op: "JSON Minify",
@@ -51,13 +42,9 @@ TestRegister.addTests([
51
42
  input: "04 89 00",
52
43
  expectedOutput: "Need 8 bytes for a UDP Header",
53
44
  recipeConfig: [
54
- {
55
- op: "From Hex",
56
- args: ["Auto"],
57
- },
58
45
  {
59
46
  op: "Parse UDP",
60
- args: [],
47
+ args: ["Hex"],
61
48
  },
62
49
  {
63
50
  op: "JSON Minify",