cyberchef 9.37.0 → 9.37.3
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/nightwatch.json +3 -2
- package/package.json +1 -1
- package/src/core/Utils.mjs +2 -2
- package/src/core/config/OperationConfig.json +78 -3
- package/src/core/lib/Extract.mjs +16 -11
- package/src/core/lib/Sort.mjs +105 -0
- package/src/core/operations/ExtractDates.mjs +7 -1
- package/src/core/operations/ExtractDomains.mjs +29 -5
- package/src/core/operations/ExtractEmailAddresses.mjs +29 -5
- package/src/core/operations/ExtractFilePaths.mjs +38 -14
- package/src/core/operations/ExtractIPAddresses.mjs +44 -27
- package/src/core/operations/ExtractMACAddresses.mjs +28 -6
- package/src/core/operations/ExtractURLs.mjs +28 -5
- package/src/core/operations/RC4Drop.mjs +2 -2
- package/src/core/operations/Sort.mjs +5 -105
- package/src/core/operations/Strings.mjs +36 -14
- package/src/core/operations/ToBase45.mjs +1 -1
- package/src/core/operations/Unique.mjs +25 -5
- package/tests/browser/ops.js +77 -24
- package/tests/node/tests/operations.mjs +4 -5
- package/tests/operations/tests/ExtractEmailAddresses.mjs +4 -4
- package/tests/operations/tests/Image.mjs +1 -1
- package/tests/operations/tests/Magic.mjs +1 -1
- package/tests/operations/tests/PGP.mjs +1 -1
- package/tests/operations/tests/RSA.mjs +1 -1
- package/tests/{operations/samples → samples}/Ciphers.mjs +0 -0
- package/tests/{operations/samples → samples}/Images.mjs +12 -0
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import Operation from "../Operation.mjs";
|
|
8
8
|
import { search } from "../lib/Extract.mjs";
|
|
9
|
+
import { hexadecimalSort } from "../lib/Sort.mjs";
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Extract MAC addresses operation
|
|
@@ -25,9 +26,19 @@ class ExtractMACAddresses extends Operation {
|
|
|
25
26
|
this.outputType = "string";
|
|
26
27
|
this.args = [
|
|
27
28
|
{
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
name: "Display total",
|
|
30
|
+
type: "boolean",
|
|
31
|
+
value: false
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: "Sort",
|
|
35
|
+
type: "boolean",
|
|
36
|
+
value: false
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: "Unique",
|
|
40
|
+
type: "boolean",
|
|
41
|
+
value: false
|
|
31
42
|
}
|
|
32
43
|
];
|
|
33
44
|
}
|
|
@@ -38,10 +49,21 @@ class ExtractMACAddresses extends Operation {
|
|
|
38
49
|
* @returns {string}
|
|
39
50
|
*/
|
|
40
51
|
run(input, args) {
|
|
41
|
-
const displayTotal = args
|
|
42
|
-
regex = /[A-F\d]{2}(?:[:-][A-F\d]{2}){5}/ig
|
|
52
|
+
const [displayTotal, sort, unique] = args,
|
|
53
|
+
regex = /[A-F\d]{2}(?:[:-][A-F\d]{2}){5}/ig,
|
|
54
|
+
results = search(
|
|
55
|
+
input,
|
|
56
|
+
regex,
|
|
57
|
+
null,
|
|
58
|
+
sort ? hexadecimalSort : null,
|
|
59
|
+
unique
|
|
60
|
+
);
|
|
43
61
|
|
|
44
|
-
|
|
62
|
+
if (displayTotal) {
|
|
63
|
+
return `Total found: ${results.length}\n\n${results.join("\n")}`;
|
|
64
|
+
} else {
|
|
65
|
+
return results.join("\n");
|
|
66
|
+
}
|
|
45
67
|
}
|
|
46
68
|
|
|
47
69
|
}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import Operation from "../Operation.mjs";
|
|
8
8
|
import { search, URL_REGEX } from "../lib/Extract.mjs";
|
|
9
|
+
import { caseInsensitiveSort } from "../lib/Sort.mjs";
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Extract URLs operation
|
|
@@ -25,9 +26,19 @@ class ExtractURLs extends Operation {
|
|
|
25
26
|
this.outputType = "string";
|
|
26
27
|
this.args = [
|
|
27
28
|
{
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
name: "Display total",
|
|
30
|
+
type: "boolean",
|
|
31
|
+
value: false
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: "Sort",
|
|
35
|
+
type: "boolean",
|
|
36
|
+
value: false
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: "Unique",
|
|
40
|
+
type: "boolean",
|
|
41
|
+
value: false
|
|
31
42
|
}
|
|
32
43
|
];
|
|
33
44
|
}
|
|
@@ -38,8 +49,20 @@ class ExtractURLs extends Operation {
|
|
|
38
49
|
* @returns {string}
|
|
39
50
|
*/
|
|
40
51
|
run(input, args) {
|
|
41
|
-
const displayTotal = args
|
|
42
|
-
|
|
52
|
+
const [displayTotal, sort, unique] = args;
|
|
53
|
+
const results = search(
|
|
54
|
+
input,
|
|
55
|
+
URL_REGEX,
|
|
56
|
+
null,
|
|
57
|
+
sort ? caseInsensitiveSort : null,
|
|
58
|
+
unique
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
if (displayTotal) {
|
|
62
|
+
return `Total found: ${results.length}\n\n${results.join("\n")}`;
|
|
63
|
+
} else {
|
|
64
|
+
return results.join("\n");
|
|
65
|
+
}
|
|
43
66
|
}
|
|
44
67
|
|
|
45
68
|
}
|
|
@@ -43,9 +43,9 @@ class RC4Drop extends Operation {
|
|
|
43
43
|
"value": ["Latin1", "UTF8", "UTF16", "UTF16LE", "UTF16BE", "Hex", "Base64"]
|
|
44
44
|
},
|
|
45
45
|
{
|
|
46
|
-
"name": "Number of
|
|
46
|
+
"name": "Number of dwords to drop",
|
|
47
47
|
"type": "number",
|
|
48
|
-
"value":
|
|
48
|
+
"value": 192
|
|
49
49
|
}
|
|
50
50
|
];
|
|
51
51
|
}
|
|
@@ -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(
|
|
61
|
+
sorted = sorted.sort(caseInsensitiveSort);
|
|
61
62
|
} else if (order === "IP address") {
|
|
62
|
-
sorted = sorted.sort(
|
|
63
|
+
sorted = sorted.sort(ipSort);
|
|
63
64
|
} else if (order === "Numeric") {
|
|
64
|
-
sorted = sorted.sort(
|
|
65
|
+
sorted = sorted.sort(numericSort);
|
|
65
66
|
} else if (order === "Numeric (hexadecimal)") {
|
|
66
|
-
sorted = sorted.sort(
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
name: "Encoding",
|
|
32
|
+
type: "option",
|
|
33
|
+
value: ["Single byte", "16-bit littleendian", "16-bit bigendian", "All"]
|
|
33
34
|
},
|
|
34
35
|
{
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
name: "Minimum length",
|
|
37
|
+
type: "number",
|
|
38
|
+
value: 4
|
|
38
39
|
},
|
|
39
40
|
{
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
|
|
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
|
}
|
|
@@ -26,9 +26,14 @@ class Unique extends Operation {
|
|
|
26
26
|
this.outputType = "string";
|
|
27
27
|
this.args = [
|
|
28
28
|
{
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
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
|
}
|
package/tests/browser/ops.js
CHANGED
|
@@ -16,7 +16,8 @@ module.exports = {
|
|
|
16
16
|
.click("#auto-bake-label");
|
|
17
17
|
},
|
|
18
18
|
|
|
19
|
-
"Sanity check operations": browser => {
|
|
19
|
+
"Sanity check operations": async browser => {
|
|
20
|
+
const Images = await import("../samples/Images.mjs");
|
|
20
21
|
testOp(browser, "A1Z26 Cipher Decode", "20 5 19 20 15 21 20 16 21 20", "testoutput");
|
|
21
22
|
testOp(browser, "A1Z26 Cipher Encode", "test input", "20 5 19 20 9 14 16 21 20");
|
|
22
23
|
testOp(browser, "ADD", "test input", "Ê»ÉÊv¿ÄÆËÊ", [{ "option": "Hex", "string": "56" }]);
|
|
@@ -24,7 +25,7 @@ module.exports = {
|
|
|
24
25
|
testOp(browser, "AES Encrypt", "test input", "e42eb8fbfb7a98fff061cd2c1a794d92", [{"option": "Hex", "string": "00112233445566778899aabbccddeeff"}, {"option": "Hex", "string": "00000000000000000000000000000000"}, "CBC", "Raw", "Hex"]);
|
|
25
26
|
testOp(browser, "AND", "test input", "4$04 $044", [{ "option": "Hex", "string": "34" }]);
|
|
26
27
|
testOp(browser, "Add line numbers", "test input", "1 test input");
|
|
27
|
-
|
|
28
|
+
testOp(browser, ["From Hex", "Add Text To Image", "To Base64"], Images.PNG_HEX, Images.PNG_CHEF_B64, [[], ["Chef", "Center", "Middle", 0, 0, 16], []]);
|
|
28
29
|
testOp(browser, "Adler-32 Checksum", "test input", "16160411");
|
|
29
30
|
testOp(browser, "Affine Cipher Decode", "test input", "rcqr glnsr", [1, 2]);
|
|
30
31
|
testOp(browser, "Affine Cipher Encode", "test input", "njln rbfpn", [2, 1]);
|
|
@@ -44,12 +45,12 @@ module.exports = {
|
|
|
44
45
|
// testOp(browser, "Bifid Cipher Encode", "test input", "test_output");
|
|
45
46
|
// testOp(browser, "Bit shift left", "test input", "test_output");
|
|
46
47
|
// testOp(browser, "Bit shift right", "test input", "test_output");
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
testOp(browser, "Blowfish Decrypt", "10884e15427dd84ec35204e9c8e921ae", "test_output", [{"option": "Hex", "string": "1234567801234567"}, {"option": "Hex", "string": "0011223344556677"}, "CBC", "Hex", "Raw"]);
|
|
49
|
+
testOp(browser, "Blowfish Encrypt", "test input", "f0fadbd1d90d774f714248cf26b96410", [{"option": "Hex", "string": "1234567801234567"}, {"option": "Hex", "string": "0011223344556677"}, "CBC", "Raw", "Hex"]);
|
|
50
|
+
testOp(browser, ["From Hex", "Blur Image", "To Base64"], Images.PNG_HEX, Images.PNG_BLUR_B64);
|
|
50
51
|
// testOp(browser, "Bombe", "test input", "test_output");
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
testOp(browser, ["Bzip2 Compress", "To Hex"], "test input", "42 5a 68 39 31 41 59 26 53 59 cf 96 82 1d 00 00 03 91 80 40 00 02 21 4e 00 20 00 21 90 c2 10 c0 88 33 92 8e df 17 72 45 38 50 90 cf 96 82 1d");
|
|
53
|
+
testOp(browser, ["From Hex", "Bzip2 Decompress"], "425a68393141592653597b0884b7000003038000008200ce00200021a647a4218013709517c5dc914e14241ec2212dc0", "test_output", [[], [true]]);
|
|
53
54
|
// testOp(browser, "CRC-16 Checksum", "test input", "test_output");
|
|
54
55
|
// testOp(browser, "CRC-32 Checksum", "test input", "test_output");
|
|
55
56
|
// testOp(browser, "CRC-8 Checksum", "test input", "test_output");
|
|
@@ -69,10 +70,10 @@ module.exports = {
|
|
|
69
70
|
// testOp(browser, "Comment", "test input", "test_output");
|
|
70
71
|
// testOp(browser, "Compare CTPH hashes", "test input", "test_output");
|
|
71
72
|
// testOp(browser, "Compare SSDEEP hashes", "test input", "test_output");
|
|
72
|
-
// testOp(browser, "Conditional Jump", "test input", "test_output");
|
|
73
|
+
// /testOp(browser, "Conditional Jump", "test input", "test_output");
|
|
73
74
|
// testOp(browser, "Contain Image", "test input", "test_output");
|
|
74
75
|
// testOp(browser, "Convert area", "test input", "test_output");
|
|
75
|
-
// testOp(browser, "Convert co-ordinate format", "test input", "test_output");
|
|
76
|
+
// /testOp(browser, "Convert co-ordinate format", "test input", "test_output");
|
|
76
77
|
// testOp(browser, "Convert data units", "test input", "test_output");
|
|
77
78
|
// testOp(browser, "Convert distance", "test input", "test_output");
|
|
78
79
|
// testOp(browser, "Convert Image Format", "test input", "test_output");
|
|
@@ -197,10 +198,12 @@ module.exports = {
|
|
|
197
198
|
// testOp(browser, "MD4", "test input", "test_output");
|
|
198
199
|
// testOp(browser, "MD5", "test input", "test_output");
|
|
199
200
|
// testOp(browser, "MD6", "test input", "test_output");
|
|
200
|
-
|
|
201
|
+
testOpHtml(browser, "Magic", "dGVzdF9vdXRwdXQ=", "tr:nth-of-type(1) th:nth-of-type(2)", "Result snippet");
|
|
202
|
+
testOpHtml(browser, "Magic", "dGVzdF9vdXRwdXQ=", "tr:nth-of-type(2) td:nth-of-type(2)", "test_output");
|
|
203
|
+
testOpHtml(browser, "Magic", "dGVzdF9vdXRwdXQ=", "tr:nth-of-type(2) td:nth-of-type(1)", /Base64/);
|
|
201
204
|
// testOp(browser, "Mean", "test input", "test_output");
|
|
202
|
-
// testOp(browser, "Median", "test input", "test_output")
|
|
203
|
-
// testOp(browser, "Merge", "test input", "test_output")
|
|
205
|
+
// testOp(browser, "Median", "test input", "test_output");`
|
|
206
|
+
// testOp(browser, "Merge", "test input", "test_output");`
|
|
204
207
|
// testOp(browser, "Microsoft Script Decoder", "test input", "test_output");
|
|
205
208
|
// testOp(browser, "Multiple Bombe", "test input", "test_output");
|
|
206
209
|
// testOp(browser, "Multiply", "test input", "test_output");
|
|
@@ -372,23 +375,36 @@ module.exports = {
|
|
|
372
375
|
}
|
|
373
376
|
};
|
|
374
377
|
|
|
375
|
-
/**
|
|
376
|
-
* Clears the current recipe and
|
|
378
|
+
/** @function
|
|
379
|
+
* Clears the current recipe and bakes a new operation.
|
|
377
380
|
*
|
|
378
|
-
* @param {
|
|
379
|
-
* @param {
|
|
381
|
+
* @param {Browser} browser - Nightwatch client
|
|
382
|
+
* @param {string|Array<string>} opName - name of operation to be tested, array for multiple ops
|
|
383
|
+
* @param {string} input - input text for test
|
|
384
|
+
* @param {Array<string>|Array<Array<string>>} args - aarguments, nested if multiple ops
|
|
380
385
|
*/
|
|
381
|
-
function
|
|
386
|
+
function bakeOp(browser, opName, input, args=[]) {
|
|
387
|
+
let recipeConfig;
|
|
382
388
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
389
|
+
if (typeof(opName) === "string") {
|
|
390
|
+
recipeConfig = JSON.stringify([{
|
|
391
|
+
"op": opName,
|
|
392
|
+
"args": args
|
|
393
|
+
}]);
|
|
394
|
+
} else if (opName instanceof Array) {
|
|
395
|
+
recipeConfig = JSON.stringify(
|
|
396
|
+
opName.map((op, i) => {
|
|
397
|
+
return {
|
|
398
|
+
op: op,
|
|
399
|
+
args: args.length ? args[i] : []
|
|
400
|
+
};
|
|
401
|
+
})
|
|
402
|
+
);
|
|
403
|
+
} else {
|
|
404
|
+
throw new Error("Invalid operation type. Must be string or array of strings. Received: " + typeof(opName));
|
|
405
|
+
}
|
|
387
406
|
|
|
388
407
|
browser
|
|
389
|
-
.perform(function() {
|
|
390
|
-
console.log(opName);
|
|
391
|
-
})
|
|
392
408
|
.useCss()
|
|
393
409
|
.click("#clr-recipe")
|
|
394
410
|
.click("#clr-io")
|
|
@@ -396,6 +412,9 @@ function testOp(browser, opName, input, output, args=[]) {
|
|
|
396
412
|
.expect.element("#input-text").to.have.property("value").that.equals("");
|
|
397
413
|
|
|
398
414
|
browser
|
|
415
|
+
.perform(function() {
|
|
416
|
+
console.log(`Current test: ${opName}`);
|
|
417
|
+
})
|
|
399
418
|
.urlHash("recipe=" + recipeConfig)
|
|
400
419
|
.setValue("#input-text", input)
|
|
401
420
|
.waitForElementPresent("#rec-list li.operation")
|
|
@@ -408,6 +427,20 @@ function testOp(browser, opName, input, output, args=[]) {
|
|
|
408
427
|
.pause(100)
|
|
409
428
|
.waitForElementPresent("#stale-indicator.hidden", 5000)
|
|
410
429
|
.waitForElementNotVisible("#output-loader", 5000);
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/** @function
|
|
433
|
+
* Clears the current recipe and tests a new operation.
|
|
434
|
+
*
|
|
435
|
+
* @param {Browser} browser - Nightwatch client
|
|
436
|
+
* @param {string|Array<string>} opName - name of operation to be tested, array for multiple ops
|
|
437
|
+
* @param {string} input - input text
|
|
438
|
+
* @param {string} output - expected output
|
|
439
|
+
* @param {Array<string>|Array<Array<string>>} args - arguments, nested if multiple ops
|
|
440
|
+
*/
|
|
441
|
+
function testOp(browser, opName, input, output, args=[]) {
|
|
442
|
+
|
|
443
|
+
bakeOp(browser, opName, input, args);
|
|
411
444
|
|
|
412
445
|
if (typeof output === "string") {
|
|
413
446
|
browser.expect.element("#output-text").to.have.property("value").that.equals(output);
|
|
@@ -415,3 +448,23 @@ function testOp(browser, opName, input, output, args=[]) {
|
|
|
415
448
|
browser.expect.element("#output-text").to.have.property("value").that.matches(output);
|
|
416
449
|
}
|
|
417
450
|
}
|
|
451
|
+
|
|
452
|
+
/** @function
|
|
453
|
+
* Clears the current recipe and tests a new operation.
|
|
454
|
+
*
|
|
455
|
+
* @param {Browser} browser - Nightwatch client
|
|
456
|
+
* @param {string|Array<string>} opName - name of operation to be tested array for multiple ops
|
|
457
|
+
* @param {string} input - input text
|
|
458
|
+
* @param {string} cssSelector - CSS selector for HTML output
|
|
459
|
+
* @param {string} output - expected output
|
|
460
|
+
* @param {Array<string>|Array<Array<string>>} args - arguments, nested if multiple ops
|
|
461
|
+
*/
|
|
462
|
+
function testOpHtml(browser, opName, input, cssSelector, output, args=[]) {
|
|
463
|
+
bakeOp(browser, opName, input, args);
|
|
464
|
+
|
|
465
|
+
if (typeof output === "string") {
|
|
466
|
+
browser.expect.element("#output-html " + cssSelector).text.that.equals(output);
|
|
467
|
+
} else if (output instanceof RegExp) {
|
|
468
|
+
browser.expect.element("#output-html " + cssSelector).text.that.matches(output);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
@@ -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
|
|
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", () => {
|
|
@@ -816,7 +816,7 @@ pCGTErs=
|
|
|
816
816
|
it("RC4 Drop", () => {
|
|
817
817
|
assert.strictEqual(
|
|
818
818
|
chef.RC4Drop("Go Out On a Limb", {passphrase: {string: "Under Your Nose", option: "UTF8"}, inputFormat: "UTF8", outputFormat: "Hex"}).toString(),
|
|
819
|
-
"
|
|
819
|
+
"b85cb1c4ed6bed8f260ab92829bba942");
|
|
820
820
|
}),
|
|
821
821
|
|
|
822
822
|
it("Regular Expression", () => {
|
|
@@ -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
|
|
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* @license Apache-2.0
|
|
10
10
|
*/
|
|
11
11
|
import TestRegister from "../../lib/TestRegister.mjs";
|
|
12
|
-
import { GIF_ANIMATED_HEX, PNG_HEX, JPG_B64, EXIF_JPG_HEX, NO_EXIF_JPG_HEX } from "
|
|
12
|
+
import { GIF_ANIMATED_HEX, PNG_HEX, JPG_B64, EXIF_JPG_HEX, NO_EXIF_JPG_HEX } from "../../samples/Images.mjs";
|
|
13
13
|
|
|
14
14
|
TestRegister.addTests([
|
|
15
15
|
{
|