Compare commits
28 commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
c4e7c41a6e | ||
![]() |
210186e754 | ||
![]() |
b4c14219b6 | ||
![]() |
299a3c48a1 | ||
![]() |
cd0aee7626 | ||
![]() |
bc82f590d4 | ||
![]() |
bebb216df2 | ||
![]() |
61d587a4a5 | ||
![]() |
85da5f83b5 | ||
![]() |
6c0c53d00f | ||
![]() |
196bce04cc | ||
![]() |
ba82941cef | ||
![]() |
63449872da | ||
![]() |
14ee3f0f4b | ||
![]() |
774828823c | ||
![]() |
9e73e2555b | ||
![]() |
dc68b7d9bf | ||
![]() |
7a38504015 | ||
![]() |
26fa5f3d1d | ||
![]() |
8b5b17b8e0 | ||
![]() |
7cfb5e0b2a | ||
![]() |
e973ea6f08 | ||
![]() |
a942fe92fd | ||
![]() |
b5e3a6c5a3 | ||
![]() |
24cd4033c4 | ||
![]() |
efda16b039 | ||
![]() |
55cac17456 | ||
![]() |
846e84d3a4 |
20 changed files with 591 additions and 12 deletions
41
.devcontainer/devcontainer.json
Normal file
41
.devcontainer/devcontainer.json
Normal file
|
@ -0,0 +1,41 @@
|
|||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
|
||||
// README at: https://github.com/devcontainers/templates/tree/main/src/javascript-node
|
||||
{
|
||||
"name": "CyberChef",
|
||||
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
|
||||
"image": "mcr.microsoft.com/devcontainers/javascript-node:1-18-bookworm",
|
||||
|
||||
// Features to add to the dev container. More info: https://containers.dev/features.
|
||||
"features": {
|
||||
"ghcr.io/devcontainers/features/github-cli": "latest"
|
||||
},
|
||||
|
||||
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
||||
"forwardPorts": [8080],
|
||||
|
||||
// Use 'postCreateCommand' to run commands after the container is created.
|
||||
"postCreateCommand": {
|
||||
"npm": "bash -c \"sudo chown node node_modules && npm install\""
|
||||
},
|
||||
|
||||
"containerEnv": {
|
||||
"DISPLAY": ":99"
|
||||
},
|
||||
|
||||
"mounts": [
|
||||
"source=${localWorkspaceFolderBasename}-node_modules,target=${containerWorkspaceFolder}/node_modules,type=volume"
|
||||
],
|
||||
|
||||
// Configure tool-specific properties.
|
||||
"customizations": {
|
||||
"vscode": {
|
||||
"extensions": [
|
||||
"dbaeumer.vscode-eslint",
|
||||
"GitHub.vscode-github-actions"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
|
||||
// "remoteUser": "root"
|
||||
}
|
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
* text=auto eol=lf
|
19
package-lock.json
generated
19
package-lock.json
generated
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "cyberchef",
|
||||
"version": "10.8.0",
|
||||
"version": "10.8.2",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "cyberchef",
|
||||
"version": "10.8.0",
|
||||
"version": "10.8.2",
|
||||
"hasInstallScript": true,
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
|
@ -40,6 +40,7 @@
|
|||
"escodegen": "^2.1.0",
|
||||
"esprima": "^4.0.1",
|
||||
"exif-parser": "^0.1.12",
|
||||
"fernet": "^0.3.2",
|
||||
"file-saver": "^2.0.5",
|
||||
"flat": "^6.0.1",
|
||||
"geodesy": "1.1.3",
|
||||
|
@ -7100,6 +7101,15 @@
|
|||
"pend": "~1.2.0"
|
||||
}
|
||||
},
|
||||
"node_modules/fernet": {
|
||||
"version": "0.3.2",
|
||||
"resolved": "https://registry.npmjs.org/fernet/-/fernet-0.3.2.tgz",
|
||||
"integrity": "sha512-VPwO4hF9sp8YrCeiOjMb4HTg5WV5VC7Nk2EG3pfotqW9ZHa3aNnR+oGiOZu8k0Jp4VxJi0RTJwHmloyjWs+Mzg==",
|
||||
"dependencies": {
|
||||
"crypto-js": "~4.2.0",
|
||||
"urlsafe-base64": "1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/file-entry-cache": {
|
||||
"version": "6.0.1",
|
||||
"dev": true,
|
||||
|
@ -14081,6 +14091,11 @@
|
|||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/urlsafe-base64": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/urlsafe-base64/-/urlsafe-base64-1.0.0.tgz",
|
||||
"integrity": "sha512-RtuPeMy7c1UrHwproMZN9gN6kiZ0SvJwRaEzwZY0j9MypEkFqyBaKv176jvlPtg58Zh36bOkS0NFABXMHvvGCA=="
|
||||
},
|
||||
"node_modules/utf8": {
|
||||
"version": "3.0.0",
|
||||
"license": "MIT"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "cyberchef",
|
||||
"version": "10.8.0",
|
||||
"version": "10.8.2",
|
||||
"description": "The Cyber Swiss Army Knife for encryption, encoding, compression and data analysis.",
|
||||
"author": "n1474335 <n1474335@gmail.com>",
|
||||
"homepage": "https://gchq.github.io/CyberChef",
|
||||
|
@ -122,6 +122,7 @@
|
|||
"escodegen": "^2.1.0",
|
||||
"esprima": "^4.0.1",
|
||||
"exif-parser": "^0.1.12",
|
||||
"fernet": "^0.3.2",
|
||||
"file-saver": "^2.0.5",
|
||||
"flat": "^6.0.1",
|
||||
"geodesy": "1.1.3",
|
||||
|
|
|
@ -70,6 +70,7 @@
|
|||
"Avro to JSON",
|
||||
"CBOR Encode",
|
||||
"CBOR Decode",
|
||||
"Caret/M-decode",
|
||||
"Rison Encode",
|
||||
"Rison Decode"
|
||||
]
|
||||
|
@ -85,6 +86,8 @@
|
|||
"DES Decrypt",
|
||||
"Triple DES Encrypt",
|
||||
"Triple DES Decrypt",
|
||||
"Fernet Encrypt",
|
||||
"Fernet Decrypt",
|
||||
"LS47 Encrypt",
|
||||
"LS47 Decrypt",
|
||||
"RC2 Encrypt",
|
||||
|
@ -333,7 +336,8 @@
|
|||
"CSS selector",
|
||||
"Extract EXIF",
|
||||
"Extract ID3",
|
||||
"Extract Files"
|
||||
"Extract Files",
|
||||
"RAKE"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
98
src/core/operations/CaretMdecode.mjs
Normal file
98
src/core/operations/CaretMdecode.mjs
Normal file
|
@ -0,0 +1,98 @@
|
|||
/**
|
||||
* @author tedk [tedk@ted.do]
|
||||
* @copyright Crown Copyright 2024
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation.mjs";
|
||||
|
||||
/**
|
||||
* Caret/M-decode operation
|
||||
*
|
||||
* https://gist.githubusercontent.com/JaHIY/3c91bbf7bea5661e6abfbd1349ee81a2/raw/c7b480e9ff24bcb8f5287a8a8a2dcb9bf5628506/decode_m_notation.cpp
|
||||
*/
|
||||
class CaretMdecode extends Operation {
|
||||
|
||||
/**
|
||||
* CaretMdecode constructor
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.name = "Caret/M-decode";
|
||||
this.module = "Default";
|
||||
this.description = "Decodes caret or M-encoded strings, i.e. ^M turns into a newline, M-^] turns into 0x9d. Sources such as `cat -v`.\n\nPlease be aware that when using `cat -v` ^_ (caret-underscore) will not be encoded, but represents a valid encoding (namely that of 0x1f).";
|
||||
this.infoURL = "https://en.wikipedia.org/wiki/Caret_notation";
|
||||
this.inputType = "string";
|
||||
this.outputType = "byteArray";
|
||||
this.args = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {byteArray}
|
||||
*/
|
||||
run(input, args) {
|
||||
|
||||
const bytes = [];
|
||||
|
||||
let prev = "";
|
||||
|
||||
for (let i = 0; i < input.length; i++) {
|
||||
|
||||
const charCode = input.charCodeAt(i);
|
||||
const curChar = input.charAt(i);
|
||||
|
||||
if (prev === "M-^") {
|
||||
if (charCode > 63 && charCode <= 95) {
|
||||
bytes.push(charCode + 64);
|
||||
} else if (charCode === 63) {
|
||||
bytes.push(255);
|
||||
} else {
|
||||
bytes.push(77, 45, 94, charCode);
|
||||
}
|
||||
prev = "";
|
||||
} else if (prev === "M-") {
|
||||
if (curChar === "^") {
|
||||
prev = prev + "^";
|
||||
} else if (charCode >= 32 && charCode <= 126) {
|
||||
bytes.push(charCode + 128);
|
||||
prev = "";
|
||||
} else {
|
||||
bytes.push(77, 45, charCode);
|
||||
prev = "";
|
||||
}
|
||||
} else if (prev === "M") {
|
||||
if (curChar === "-") {
|
||||
prev = prev + "-";
|
||||
} else {
|
||||
bytes.push(77, charCode);
|
||||
prev = "";
|
||||
}
|
||||
} else if (prev === "^") {
|
||||
if (charCode > 63 && charCode <= 126) {
|
||||
bytes.push(charCode - 64);
|
||||
} else if (charCode === 63) {
|
||||
bytes.push(127);
|
||||
} else {
|
||||
bytes.push(94, charCode);
|
||||
}
|
||||
prev = "";
|
||||
} else {
|
||||
if (curChar === "M") {
|
||||
prev = "M";
|
||||
} else if (curChar === "^") {
|
||||
prev = "^";
|
||||
} else {
|
||||
bytes.push(charCode);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default CaretMdecode;
|
|
@ -119,9 +119,9 @@ class Diff extends Operation {
|
|||
|
||||
for (let i = 0; i < diff.length; i++) {
|
||||
if (diff[i].added) {
|
||||
if (showAdded) output += "<span class='hl5'>" + Utils.escapeHtml(diff[i].value) + "</span>";
|
||||
if (showAdded) output += "<ins>" + Utils.escapeHtml(diff[i].value) + "</ins>";
|
||||
} else if (diff[i].removed) {
|
||||
if (showRemoved) output += "<span class='hl3'>" + Utils.escapeHtml(diff[i].value) + "</span>";
|
||||
if (showRemoved) output += "<del>" + Utils.escapeHtml(diff[i].value) + "</del>";
|
||||
} else if (!showSubtraction) {
|
||||
output += Utils.escapeHtml(diff[i].value);
|
||||
}
|
||||
|
|
63
src/core/operations/FernetDecrypt.mjs
Normal file
63
src/core/operations/FernetDecrypt.mjs
Normal file
|
@ -0,0 +1,63 @@
|
|||
/**
|
||||
* @author Karsten Silkenbäumer [github.com/kassi]
|
||||
* @copyright Karsten Silkenbäumer 2019
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation.mjs";
|
||||
import OperationError from "../errors/OperationError.mjs";
|
||||
import fernet from "fernet";
|
||||
|
||||
/**
|
||||
* FernetDecrypt operation
|
||||
*/
|
||||
class FernetDecrypt extends Operation {
|
||||
/**
|
||||
* FernetDecrypt constructor
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.name = "Fernet Decrypt";
|
||||
this.module = "Default";
|
||||
this.description = "Fernet is a symmetric encryption method which makes sure that the message encrypted cannot be manipulated/read without the key. It uses URL safe encoding for the keys. Fernet uses 128-bit AES in CBC mode and PKCS7 padding, with HMAC using SHA256 for authentication. The IV is created from os.random().<br><br><b>Key:</b> The key must be 32 bytes (256 bits) encoded with Base64.";
|
||||
this.infoURL = "https://asecuritysite.com/encryption/fer";
|
||||
this.inputType = "string";
|
||||
this.outputType = "string";
|
||||
this.args = [
|
||||
{
|
||||
"name": "Key",
|
||||
"type": "string",
|
||||
"value": ""
|
||||
},
|
||||
];
|
||||
this.patterns = [
|
||||
{
|
||||
match: "^[A-Z\\d\\-_=]{20,}$",
|
||||
flags: "i",
|
||||
args: []
|
||||
},
|
||||
];
|
||||
}
|
||||
/**
|
||||
* @param {String} input
|
||||
* @param {Object[]} args
|
||||
* @returns {String}
|
||||
*/
|
||||
run(input, args) {
|
||||
const [secretInput] = args;
|
||||
try {
|
||||
const secret = new fernet.Secret(secretInput);
|
||||
const token = new fernet.Token({
|
||||
secret: secret,
|
||||
token: input,
|
||||
ttl: 0
|
||||
});
|
||||
return token.decode();
|
||||
} catch (err) {
|
||||
throw new OperationError(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default FernetDecrypt;
|
54
src/core/operations/FernetEncrypt.mjs
Normal file
54
src/core/operations/FernetEncrypt.mjs
Normal file
|
@ -0,0 +1,54 @@
|
|||
/**
|
||||
* @author Karsten Silkenbäumer [github.com/kassi]
|
||||
* @copyright Karsten Silkenbäumer 2019
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation.mjs";
|
||||
import OperationError from "../errors/OperationError.mjs";
|
||||
import fernet from "fernet";
|
||||
|
||||
/**
|
||||
* FernetEncrypt operation
|
||||
*/
|
||||
class FernetEncrypt extends Operation {
|
||||
/**
|
||||
* FernetEncrypt constructor
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.name = "Fernet Encrypt";
|
||||
this.module = "Default";
|
||||
this.description = "Fernet is a symmetric encryption method which makes sure that the message encrypted cannot be manipulated/read without the key. It uses URL safe encoding for the keys. Fernet uses 128-bit AES in CBC mode and PKCS7 padding, with HMAC using SHA256 for authentication. The IV is created from os.random().<br><br><b>Key:</b> The key must be 32 bytes (256 bits) encoded with Base64.";
|
||||
this.infoURL = "https://asecuritysite.com/encryption/fer";
|
||||
this.inputType = "string";
|
||||
this.outputType = "string";
|
||||
this.args = [
|
||||
{
|
||||
"name": "Key",
|
||||
"type": "string",
|
||||
"value": ""
|
||||
},
|
||||
];
|
||||
}
|
||||
/**
|
||||
* @param {String} input
|
||||
* @param {Object[]} args
|
||||
* @returns {String}
|
||||
*/
|
||||
run(input, args) {
|
||||
const [secretInput] = args;
|
||||
try {
|
||||
const secret = new fernet.Secret(secretInput);
|
||||
const token = new fernet.Token({
|
||||
secret: secret,
|
||||
});
|
||||
return token.encode(input);
|
||||
} catch (err) {
|
||||
throw new OperationError(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default FernetEncrypt;
|
149
src/core/operations/RAKE.mjs
Normal file
149
src/core/operations/RAKE.mjs
Normal file
|
@ -0,0 +1,149 @@
|
|||
/**
|
||||
* @author sw5678
|
||||
* @copyright Crown Copyright 2024
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation.mjs";
|
||||
|
||||
/**
|
||||
* RAKE operation
|
||||
*/
|
||||
class RAKE extends Operation {
|
||||
|
||||
/**
|
||||
* RAKE constructor
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.name = "RAKE";
|
||||
this.module = "Default";
|
||||
this.description = [
|
||||
"Rapid Keyword Extraction (RAKE)",
|
||||
"<br><br>",
|
||||
"RAKE is a domain-independent keyword extraction algorithm in Natural Language Processing.",
|
||||
"<br><br>",
|
||||
"The list of stop words are from the NLTK python package",
|
||||
].join("\n");
|
||||
this.inputType = "string";
|
||||
this.outputType = "string";
|
||||
this.args = [
|
||||
{
|
||||
name: "Word Delimiter (Regex)",
|
||||
type: "text",
|
||||
value: "\\s"
|
||||
},
|
||||
{
|
||||
name: "Sentence Delimiter (Regex)",
|
||||
type: "text",
|
||||
value: "\\.\\s|\\n"
|
||||
},
|
||||
{
|
||||
name: "Stop Words",
|
||||
type: "text",
|
||||
value: "i,me,my,myself,we,our,ours,ourselves,you,you're,you've,you'll,you'd,your,yours,yourself,yourselves,he,him,his,himself,she,she's,her,hers,herself,it,it's,its,itsef,they,them,their,theirs,themselves,what,which,who,whom,this,that,that'll,these,those,am,is,are,was,were,be,been,being,have,has,had,having,do,does',did,doing,a,an,the,and,but,if,or,because,as,until,while,of,at,by,for,with,about,against,between,into,through,during,before,after,above,below,to,from,up,down,in,out,on,off,over,under,again,further,then,once,here,there,when,where,why,how,all,any,both,each,few,more,most,other,some,such,no,nor,not,only,own,same,so,than,too,very,s,t,can,will,just,don,don't,should,should've,now,d,ll,m,o,re,ve,y,ain,aren,aren't,couldn,couldn't,didn,didn't,doesn,doesn't,hadn,hadn't,hasn,hasn't,haven,haven't,isn,isn't,ma,mightn,mightn't,mustn,mustn't,needn,needn't,shan,shan't,shouldn,shouldn't,wasn,wasn't,weren,weren't,won,won't,wouldn,wouldn't"
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
run(input, args) {
|
||||
|
||||
// Get delimiter regexs
|
||||
const wordDelim = new RegExp(args[0], "g");
|
||||
const sentDelim = new RegExp(args[1], "g");
|
||||
|
||||
// Deduplicate the stop words and add the empty string
|
||||
const stopWords = args[2].toLowerCase().replace(/ /g, "").split(",").unique();
|
||||
stopWords.push("");
|
||||
|
||||
// Lower case input and remove start and ending whitespace
|
||||
input = input.toLowerCase().trim();
|
||||
|
||||
// Get tokens, token count, and phrases
|
||||
const tokens = [];
|
||||
const wordFrequencies = [];
|
||||
let phrases = [];
|
||||
|
||||
// Build up list of phrases and token counts
|
||||
const sentences = input.split(sentDelim);
|
||||
for (const sent of sentences) {
|
||||
|
||||
// Split sentence into words
|
||||
const splitSent = sent.split(wordDelim);
|
||||
let startIndex = 0;
|
||||
|
||||
for (let i = 0; i < splitSent.length; i++) {
|
||||
const token = splitSent[i];
|
||||
if (stopWords.includes(token)) {
|
||||
// If token is stop word then split to create phrase
|
||||
phrases.push(splitSent.slice(startIndex, i));
|
||||
startIndex = i + 1;
|
||||
} else {
|
||||
// If token is not a stop word add to the count of the list of words
|
||||
if (tokens.includes(token)) {
|
||||
wordFrequencies[tokens.indexOf(token)]+=1;
|
||||
} else {
|
||||
tokens.push(token);
|
||||
wordFrequencies.push(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
phrases.push(splitSent.slice(startIndex));
|
||||
}
|
||||
|
||||
// remove empty phrases
|
||||
phrases = phrases.filter(subArray => subArray.length > 0);
|
||||
|
||||
// Remove duplicate phrases
|
||||
const uniquePhrases = [...new Set(phrases.map(function (phrase) {
|
||||
return phrase.join(" ");
|
||||
}))];
|
||||
phrases = uniquePhrases.map(function (phrase) {
|
||||
return phrase.split(" ");
|
||||
});
|
||||
|
||||
// Generate word_degree_matrix and populate
|
||||
const wordDegreeMatrix = Array.from(Array(tokens.length), _ => Array(tokens.length).fill(0));
|
||||
phrases.forEach(function (phrase) {
|
||||
phrase.forEach(function (word1) {
|
||||
phrase.forEach(function (word2) {
|
||||
wordDegreeMatrix[tokens.indexOf(word1)][tokens.indexOf(word2)]++;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Calculate degree score for each token
|
||||
const degreeScores = Array(tokens.length).fill(0);
|
||||
for (let i=0; i<tokens.length; i++) {
|
||||
let wordDegree = 0;
|
||||
for (let j=0; j<wordDegreeMatrix.length; j++) {
|
||||
wordDegree += wordDegreeMatrix[j][i];
|
||||
}
|
||||
degreeScores[i] = wordDegree / wordFrequencies[i];
|
||||
}
|
||||
|
||||
// Calculate score for each phrase
|
||||
const scores = phrases.map(function (phrase) {
|
||||
let score = 0;
|
||||
phrase.forEach(function (token) {
|
||||
score += degreeScores[tokens.indexOf(token)];
|
||||
});
|
||||
return new Array(score, phrase.join(" "));
|
||||
});
|
||||
scores.sort((a, b) => b[0] - a[0]);
|
||||
scores.unshift(new Array("Scores: ", "Keywords: "));
|
||||
|
||||
// Output works with the 'To Table' functionality already built into CC
|
||||
return scores.map(function (score) {
|
||||
return score.join(", ");
|
||||
}).join("\n");
|
||||
}
|
||||
}
|
||||
|
||||
export default RAKE;
|
|
@ -36,4 +36,5 @@
|
|||
@import "./layout/_structure.css";
|
||||
|
||||
/* Operations */
|
||||
@import "./operations/diff.css";
|
||||
@import "./operations/json.css";
|
||||
|
|
8
src/web/stylesheets/operations/diff.css
Normal file
8
src/web/stylesheets/operations/diff.css
Normal file
|
@ -0,0 +1,8 @@
|
|||
del {
|
||||
background-color: var(--hl3);
|
||||
}
|
||||
|
||||
ins {
|
||||
text-decoration: underline; /* shouldn't be needed, but Chromium doesn't copy to clipboard without it */
|
||||
background-color: var(--hl5);
|
||||
}
|
|
@ -44,7 +44,8 @@ ul.json-dict, ol.json-array {
|
|||
display: contents;
|
||||
}
|
||||
.json-summary {
|
||||
display: contents;
|
||||
display: inline;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
/* Display object and array brackets when closed */
|
||||
|
|
|
@ -108,7 +108,7 @@ module.exports = {
|
|||
// testOp(browser, "Derive EVP key", "test input", "test_output");
|
||||
// testOp(browser, "Derive PBKDF2 key", "test input", "test_output");
|
||||
// testOp(browser, "Detect File Type", "test input", "test_output");
|
||||
testOpHtml(browser, "Diff", "The cat sat on the mat\n\nThe mat cat on the sat", ".hl5:first-child", "mat", ["\\n\\n", "Word", true, true, false, false]);
|
||||
testOpHtml(browser, "Diff", "The cat sat on the mat\n\nThe mat cat on the sat", "ins:first-child", "mat", ["\\n\\n", "Word", true, true, false, false]);
|
||||
// testOp(browser, "Disassemble x86", "test input", "test_output");
|
||||
testOpImage(browser, "Dither Image", "files/Hitchhikers_Guide.jpeg");
|
||||
// testOp(browser, "Divide", "test input", "test_output");
|
||||
|
|
|
@ -136,7 +136,7 @@ TestRegister.addApiTests([
|
|||
|
||||
it("chef.help: returns multiple results", () => {
|
||||
const result = chef.help("base 64");
|
||||
assert.strictEqual(result.length, 11);
|
||||
assert.strictEqual(result.length, 13);
|
||||
}),
|
||||
|
||||
it("chef.help: looks in description for matches too", () => {
|
||||
|
|
|
@ -34,6 +34,7 @@ import "./tests/Bombe.mjs";
|
|||
import "./tests/BSON.mjs";
|
||||
import "./tests/ByteRepr.mjs";
|
||||
import "./tests/CaesarBoxCipher.mjs";
|
||||
import "./tests/CaretMdecode.mjs";
|
||||
import "./tests/CartesianProduct.mjs";
|
||||
import "./tests/CBORDecode.mjs";
|
||||
import "./tests/CBOREncode.mjs";
|
||||
|
@ -117,6 +118,7 @@ import "./tests/PHP.mjs";
|
|||
import "./tests/PowerSet.mjs";
|
||||
import "./tests/Protobuf.mjs";
|
||||
import "./tests/Rabbit.mjs";
|
||||
import "./tests/RAKE.mjs";
|
||||
import "./tests/Regex.mjs";
|
||||
import "./tests/Register.mjs";
|
||||
import "./tests/RisonEncodeDecode.mjs";
|
||||
|
|
39
tests/operations/tests/CaretMdecode.mjs
Normal file
39
tests/operations/tests/CaretMdecode.mjs
Normal file
|
@ -0,0 +1,39 @@
|
|||
/**
|
||||
* Caesar Box Cipher tests.
|
||||
*
|
||||
* @author tedk [tedk@ted.do]
|
||||
*
|
||||
* @copyright Crown Copyright 2020
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
import TestRegister from "../../lib/TestRegister.mjs";
|
||||
|
||||
TestRegister.addTests([
|
||||
{
|
||||
name: "Caret/M-decode: nothing",
|
||||
input: "",
|
||||
expectedOutput: "",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Caret/M-decode",
|
||||
args: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
/*
|
||||
* Tests the full range.
|
||||
* Everything except "^_" (\x5e\x5f) will decode correctly.
|
||||
*/
|
||||
name: "Caret/M-decode: Full set",
|
||||
input: "^@^A^B^C^D^E^F^G^H^I^J^K^L^M^N^O^P^Q^R^S^T^U^V^W^X^Y^Z^[^\\^]^^^_ !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~^?M-^@M-^AM-^BM-^CM-^DM-^EM-^FM-^GM-^HM-^IM-^JM-^KM-^LM-^MM-^NM-^OM-^PM-^QM-^RM-^SM-^TM-^UM-^VM-^WM-^XM-^YM-^ZM-^[M-^\\M-^]M-^^M-^_M- M-!M-\"M-#M-$M-%M-&M-'M-(M-)M-*M-+M-,M--M-.M-/M-0M-1M-2M-3M-4M-5M-6M-7M-8M-9M-:M-;M-<M-=M->M-?M-@M-AM-BM-CM-DM-EM-FM-GM-HM-IM-JM-KM-LM-MM-NM-OM-PM-QM-RM-SM-TM-UM-VM-WM-XM-YM-ZM-[M-\\M-]M-^M-_M-`M-aM-bM-cM-dM-eM-fM-gM-hM-iM-jM-kM-lM-mM-nM-oM-pM-qM-rM-sM-tM-uM-vM-wM-xM-yM-zM-{M-|M-}M-~M-^?",
|
||||
expectedOutput: "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x1f\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\x8d\x2d\x5f\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Caret/M-decode",
|
||||
args: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
|
80
tests/operations/tests/Fernet.mjs
Normal file
80
tests/operations/tests/Fernet.mjs
Normal file
|
@ -0,0 +1,80 @@
|
|||
/**
|
||||
* Fernet tests.
|
||||
*
|
||||
* @author Karsten Silkenbäumer [github.com/kassi]
|
||||
* @copyright Karsten Silkenbäumer 2019
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
import TestRegister from "../TestRegister";
|
||||
|
||||
TestRegister.addTests([
|
||||
{
|
||||
name: "Fernet Decrypt: no input",
|
||||
input: "",
|
||||
expectedOutput: "Error: Invalid version",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Fernet Decrypt",
|
||||
args: ["MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI="]
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Fernet Decrypt: no secret",
|
||||
input: "gAAAAABce-Tycae8klRxhDX2uenJ-uwV8-A1XZ2HRnfOXlNzkKKfRxviNLlgtemhT_fd1Fw5P_zFUAjd69zaJBQyWppAxVV00SExe77ql8c5n62HYJOnoIU=",
|
||||
expectedOutput: "Error: Secret must be 32 url-safe base64-encoded bytes.",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Fernet Decrypt",
|
||||
args: [""]
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Fernet Decrypt: valid arguments",
|
||||
input: "gAAAAABce-Tycae8klRxhDX2uenJ-uwV8-A1XZ2HRnfOXlNzkKKfRxviNLlgtemhT_fd1Fw5P_zFUAjd69zaJBQyWppAxVV00SExe77ql8c5n62HYJOnoIU=",
|
||||
expectedOutput: "This is a secret message.\n",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Fernet Decrypt",
|
||||
args: ["VGhpc0lzVGhpcnR5VHdvQ2hhcmFjdGVyc0xvbmdLZXk="]
|
||||
}
|
||||
],
|
||||
}
|
||||
]);
|
||||
|
||||
TestRegister.addTests([
|
||||
{
|
||||
name: "Fernet Encrypt: no input",
|
||||
input: "",
|
||||
expectedMatch: /^gAAAAABce-[\w-]+={0,2}$/,
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Fernet Encrypt",
|
||||
args: ["MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI="]
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Fernet Encrypt: no secret",
|
||||
input: "This is a secret message.\n",
|
||||
expectedOutput: "Error: Secret must be 32 url-safe base64-encoded bytes.",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Fernet Encrypt",
|
||||
args: [""]
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Fernet Encrypt: valid arguments",
|
||||
input: "This is a secret message.\n",
|
||||
expectedMatch: /^gAAAAABce-[\w-]+={0,2}$/,
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Fernet Encrypt",
|
||||
args: ["MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI="]
|
||||
}
|
||||
],
|
||||
}
|
||||
]);
|
22
tests/operations/tests/RAKE.mjs
Normal file
22
tests/operations/tests/RAKE.mjs
Normal file
|
@ -0,0 +1,22 @@
|
|||
/**
|
||||
* RAKE, Rapid Automatic Keyword Extraction tests.
|
||||
*
|
||||
* @author sw5678
|
||||
* @copyright Crown Copyright 2024
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
import TestRegister from "../../lib/TestRegister.mjs";
|
||||
|
||||
TestRegister.addTests([
|
||||
{
|
||||
"name": "RAKE: Basic Example",
|
||||
"input": "test1 test2. test2",
|
||||
"expectedOutput": "Scores: , Keywords: \n3.5, test1 test2\n1.5, test2",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "RAKE",
|
||||
"args": ["\\s", "\\.\\s|\\n", "i,me,my,myself,we,our"]
|
||||
},
|
||||
],
|
||||
}
|
||||
]);
|
|
@ -11,7 +11,7 @@ TestRegister.addTests([
|
|||
{
|
||||
name: "Diff, basic usage",
|
||||
input: "testing23\n\ntesting123",
|
||||
expectedOutput: "testing<span class='hl5'>1</span>23",
|
||||
expectedOutput: "testing<ins>1</ins>23",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "Diff",
|
||||
|
@ -22,7 +22,7 @@ TestRegister.addTests([
|
|||
{
|
||||
name: "Diff added with subtraction, basic usage",
|
||||
input: "testing23\n\ntesting123",
|
||||
expectedOutput: "<span class='hl5'>1</span>",
|
||||
expectedOutput: "<ins>1</ins>",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "Diff",
|
||||
|
@ -33,7 +33,7 @@ TestRegister.addTests([
|
|||
{
|
||||
name: "Diff removed with subtraction, basic usage",
|
||||
input: "testing123\n\ntesting3",
|
||||
expectedOutput: "<span class='hl3'>12</span>",
|
||||
expectedOutput: "<del>12</del>",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "Diff",
|
||||
|
|
Loading…
Add table
Reference in a new issue