ESM: Added remaining Base64 ops and created a Base64 library. Added the prefer-const eslint rule.

This commit is contained in:
n1474335 2018-04-02 17:10:51 +01:00
parent 9b4fc3d3aa
commit 041cd9fb8e
30 changed files with 986 additions and 825 deletions

View file

@ -21,340 +21,340 @@ const Categories = [
{
name: "Favourites",
ops: []
}/*,
},
{
name: "Data format",
ops: [
"To Hexdump",
"From Hexdump",
"To Hex",
"From Hex",
"To Charcode",
"From Charcode",
"To Decimal",
"From Decimal",
"To Binary",
"From Binary",
"To Octal",
"From Octal",
// "To Hexdump",
// "From Hexdump",
// "To Hex",
// "From Hex",
// "To Charcode",
// "From Charcode",
// "To Decimal",
// "From Decimal",
// "To Binary",
// "From Binary",
// "To Octal",
// "From Octal",
"To Base64",
"From Base64",
"Show Base64 offsets",
"To Base32",
"From Base32",
"To Base58",
"From Base58",
"To Base",
"From Base",
"To BCD",
"From BCD",
"To HTML Entity",
"From HTML Entity",
"URL Encode",
"URL Decode",
"Escape Unicode Characters",
"Unescape Unicode Characters",
"To Quoted Printable",
"From Quoted Printable",
"To Punycode",
"From Punycode",
"To Hex Content",
"From Hex Content",
"PEM to Hex",
"Hex to PEM",
"Parse ASN.1 hex string",
"Change IP format",
"Encode text",
"Decode text",
"Swap endianness",
// "To Base58",
// "From Base58",
// "To Base",
// "From Base",
// "To BCD",
// "From BCD",
// "To HTML Entity",
// "From HTML Entity",
// "URL Encode",
// "URL Decode",
// "Escape Unicode Characters",
// "Unescape Unicode Characters",
// "To Quoted Printable",
// "From Quoted Printable",
// "To Punycode",
// "From Punycode",
// "To Hex Content",
// "From Hex Content",
// "PEM to Hex",
// "Hex to PEM",
// "Parse ASN.1 hex string",
// "Change IP format",
// "Encode text",
// "Decode text",
// "Swap endianness",
// ]
// },
// {
// name: "Encryption / Encoding",
// ops: [
// "AES Encrypt",
// "AES Decrypt",
// "Blowfish Encrypt",
// "Blowfish Decrypt",
// "DES Encrypt",
// "DES Decrypt",
// "Triple DES Encrypt",
// "Triple DES Decrypt",
// "RC2 Encrypt",
// "RC2 Decrypt",
// "RC4",
// "RC4 Drop",
// "ROT13",
// "ROT47",
// "XOR",
// "XOR Brute Force",
// "Vigenère Encode",
// "Vigenère Decode",
// "To Morse Code",
// "From Morse Code",
// "Bifid Cipher Encode",
// "Bifid Cipher Decode",
// "Affine Cipher Encode",
// "Affine Cipher Decode",
// "Atbash Cipher",
// "Substitute",
// "Derive PBKDF2 key",
// "Derive EVP key",
// "Bcrypt",
// "Scrypt",
// "Pseudo-Random Number Generator",
]
},
{
name: "Encryption / Encoding",
ops: [
"AES Encrypt",
"AES Decrypt",
"Blowfish Encrypt",
"Blowfish Decrypt",
"DES Encrypt",
"DES Decrypt",
"Triple DES Encrypt",
"Triple DES Decrypt",
"RC2 Encrypt",
"RC2 Decrypt",
"RC4",
"RC4 Drop",
"ROT13",
"ROT47",
"XOR",
"XOR Brute Force",
"Vigenère Encode",
"Vigenère Decode",
"To Morse Code",
"From Morse Code",
"Bifid Cipher Encode",
"Bifid Cipher Decode",
"Affine Cipher Encode",
"Affine Cipher Decode",
"Atbash Cipher",
"Substitute",
"Derive PBKDF2 key",
"Derive EVP key",
"Bcrypt",
"Scrypt",
"Pseudo-Random Number Generator",
]
},
{
name: "Public Key",
ops: [
"Parse X.509 certificate",
"Parse ASN.1 hex string",
"PEM to Hex",
"Hex to PEM",
"Hex to Object Identifier",
"Object Identifier to Hex",
]
},
{
name: "Arithmetic / Logic",
ops: [
"XOR",
"XOR Brute Force",
"OR",
"NOT",
"AND",
"ADD",
"SUB",
"Sum",
"Subtract",
"Multiply",
"Divide",
"Mean",
"Median",
"Standard Deviation",
"Bit shift left",
"Bit shift right",
"Rotate left",
"Rotate right",
"ROT13",
]
},
{
name: "Networking",
ops: [
"HTTP request",
"Strip HTTP headers",
"Parse User Agent",
"Parse IP range",
"Parse IPv6 address",
"Parse IPv4 header",
"Parse URI",
"URL Encode",
"URL Decode",
"Format MAC addresses",
"Change IP format",
"Group IP addresses",
"Encode NetBIOS Name",
"Decode NetBIOS Name",
]
},
{
name: "Language",
ops: [
"Encode text",
"Decode text",
"Unescape Unicode Characters",
]
},
{
name: "Utils",
ops: [
"Diff",
"Remove whitespace",
"Remove null bytes",
"To Upper case",
"To Lower case",
"Add line numbers",
"Remove line numbers",
"Reverse",
"Sort",
"Unique",
"Split",
"Filter",
"Head",
"Tail",
"Count occurrences",
"Expand alphabet range",
"Drop bytes",
"Take bytes",
"Pad lines",
"Find / Replace",
"Regular expression",
"Offset checker",
"Hamming Distance",
"Convert distance",
"Convert area",
"Convert mass",
"Convert speed",
"Convert data units",
"Parse UNIX file permissions",
"Swap endianness",
"Parse colour code",
"Escape string",
"Unescape string",
"Pseudo-Random Number Generator",
"Sleep",
]
},
{
name: "Date / Time",
ops: [
"Parse DateTime",
"Translate DateTime Format",
"From UNIX Timestamp",
"To UNIX Timestamp",
"Windows Filetime to UNIX Timestamp",
"UNIX Timestamp to Windows Filetime",
"Extract dates",
"Sleep",
]
},
{
name: "Extractors",
ops: [
"Strings",
"Extract IP addresses",
"Extract email addresses",
"Extract MAC addresses",
"Extract URLs",
"Extract domains",
"Extract file paths",
"Extract dates",
"Regular expression",
"XPath expression",
"JPath expression",
"CSS selector",
"Extract EXIF",
]
},
{
name: "Compression",
ops: [
"Raw Deflate",
"Raw Inflate",
"Zlib Deflate",
"Zlib Inflate",
"Gzip",
"Gunzip",
"Zip",
"Unzip",
"Bzip2 Decompress",
"Tar",
"Untar",
]
},
{
name: "Hashing",
ops: [
"Analyse hash",
"Generate all hashes",
"MD2",
"MD4",
"MD5",
"MD6",
"SHA0",
"SHA1",
"SHA2",
"SHA3",
"Keccak",
"Shake",
"RIPEMD",
"HAS-160",
"Whirlpool",
"Snefru",
"SSDEEP",
"CTPH",
"Compare SSDEEP hashes",
"Compare CTPH hashes",
"HMAC",
"Bcrypt",
"Bcrypt compare",
"Bcrypt parse",
"Scrypt",
"Fletcher-8 Checksum",
"Fletcher-16 Checksum",
"Fletcher-32 Checksum",
"Fletcher-64 Checksum",
"Adler-32 Checksum",
"CRC-16 Checksum",
"CRC-32 Checksum",
"TCP/IP Checksum",
]
},
{
name: "Code tidy",
ops: [
"Syntax highlighter",
"Generic Code Beautify",
"JavaScript Parser",
"JavaScript Beautify",
"JavaScript Minify",
"JSON Beautify",
"JSON Minify",
"XML Beautify",
"XML Minify",
"SQL Beautify",
"SQL Minify",
"CSS Beautify",
"CSS Minify",
"XPath expression",
"JPath expression",
"CSS selector",
"PHP Deserialize",
"Microsoft Script Decoder",
"Strip HTML tags",
"Diff",
"To Snake case",
"To Camel case",
"To Kebab case",
"BSON serialise",
"BSON deserialise",
]
},
{
name: "Other",
ops: [
"Entropy",
"Frequency distribution",
"Chi Square",
"Detect File Type",
"Scan for Embedded Files",
"Disassemble x86",
"Pseudo-Random Number Generator",
"Generate UUID",
"Generate TOTP",
"Generate HOTP",
"Render Image",
"Remove EXIF",
"Extract EXIF",
"Numberwang",
"XKCD Random Number",
]
},
{
name: "Flow control",
ops: [
"Fork",
"Merge",
"Register",
"Label",
"Jump",
"Conditional Jump",
"Return",
"Comment"
]
},*/
// {
// name: "Public Key",
// ops: [
// "Parse X.509 certificate",
// "Parse ASN.1 hex string",
// "PEM to Hex",
// "Hex to PEM",
// "Hex to Object Identifier",
// "Object Identifier to Hex",
// ]
// },
// {
// name: "Arithmetic / Logic",
// ops: [
// "XOR",
// "XOR Brute Force",
// "OR",
// "NOT",
// "AND",
// "ADD",
// "SUB",
// "Sum",
// "Subtract",
// "Multiply",
// "Divide",
// "Mean",
// "Median",
// "Standard Deviation",
// "Bit shift left",
// "Bit shift right",
// "Rotate left",
// "Rotate right",
// "ROT13",
// ]
// },
// {
// name: "Networking",
// ops: [
// "HTTP request",
// "Strip HTTP headers",
// "Parse User Agent",
// "Parse IP range",
// "Parse IPv6 address",
// "Parse IPv4 header",
// "Parse URI",
// "URL Encode",
// "URL Decode",
// "Format MAC addresses",
// "Change IP format",
// "Group IP addresses",
// "Encode NetBIOS Name",
// "Decode NetBIOS Name",
// ]
// },
// {
// name: "Language",
// ops: [
// "Encode text",
// "Decode text",
// "Unescape Unicode Characters",
// ]
// },
// {
// name: "Utils",
// ops: [
// "Diff",
// "Remove whitespace",
// "Remove null bytes",
// "To Upper case",
// "To Lower case",
// "Add line numbers",
// "Remove line numbers",
// "Reverse",
// "Sort",
// "Unique",
// "Split",
// "Filter",
// "Head",
// "Tail",
// "Count occurrences",
// "Expand alphabet range",
// "Drop bytes",
// "Take bytes",
// "Pad lines",
// "Find / Replace",
// "Regular expression",
// "Offset checker",
// "Hamming Distance",
// "Convert distance",
// "Convert area",
// "Convert mass",
// "Convert speed",
// "Convert data units",
// "Parse UNIX file permissions",
// "Swap endianness",
// "Parse colour code",
// "Escape string",
// "Unescape string",
// "Pseudo-Random Number Generator",
// "Sleep",
// ]
// },
// {
// name: "Date / Time",
// ops: [
// "Parse DateTime",
// "Translate DateTime Format",
// "From UNIX Timestamp",
// "To UNIX Timestamp",
// "Windows Filetime to UNIX Timestamp",
// "UNIX Timestamp to Windows Filetime",
// "Extract dates",
// "Sleep",
// ]
// },
// {
// name: "Extractors",
// ops: [
// "Strings",
// "Extract IP addresses",
// "Extract email addresses",
// "Extract MAC addresses",
// "Extract URLs",
// "Extract domains",
// "Extract file paths",
// "Extract dates",
// "Regular expression",
// "XPath expression",
// "JPath expression",
// "CSS selector",
// "Extract EXIF",
// ]
// },
// {
// name: "Compression",
// ops: [
// "Raw Deflate",
// "Raw Inflate",
// "Zlib Deflate",
// "Zlib Inflate",
// "Gzip",
// "Gunzip",
// "Zip",
// "Unzip",
// "Bzip2 Decompress",
// "Tar",
// "Untar",
// ]
// },
// {
// name: "Hashing",
// ops: [
// "Analyse hash",
// "Generate all hashes",
// "MD2",
// "MD4",
// "MD5",
// "MD6",
// "SHA0",
// "SHA1",
// "SHA2",
// "SHA3",
// "Keccak",
// "Shake",
// "RIPEMD",
// "HAS-160",
// "Whirlpool",
// "Snefru",
// "SSDEEP",
// "CTPH",
// "Compare SSDEEP hashes",
// "Compare CTPH hashes",
// "HMAC",
// "Bcrypt",
// "Bcrypt compare",
// "Bcrypt parse",
// "Scrypt",
// "Fletcher-8 Checksum",
// "Fletcher-16 Checksum",
// "Fletcher-32 Checksum",
// "Fletcher-64 Checksum",
// "Adler-32 Checksum",
// "CRC-16 Checksum",
// "CRC-32 Checksum",
// "TCP/IP Checksum",
// ]
// },
// {
// name: "Code tidy",
// ops: [
// "Syntax highlighter",
// "Generic Code Beautify",
// "JavaScript Parser",
// "JavaScript Beautify",
// "JavaScript Minify",
// "JSON Beautify",
// "JSON Minify",
// "XML Beautify",
// "XML Minify",
// "SQL Beautify",
// "SQL Minify",
// "CSS Beautify",
// "CSS Minify",
// "XPath expression",
// "JPath expression",
// "CSS selector",
// "PHP Deserialize",
// "Microsoft Script Decoder",
// "Strip HTML tags",
// "Diff",
// "To Snake case",
// "To Camel case",
// "To Kebab case",
// "BSON serialise",
// "BSON deserialise",
// ]
// },
// {
// name: "Other",
// ops: [
// "Entropy",
// "Frequency distribution",
// "Chi Square",
// "Detect File Type",
// "Scan for Embedded Files",
// "Disassemble x86",
// "Pseudo-Random Number Generator",
// "Generate UUID",
// "Generate TOTP",
// "Generate HOTP",
// "Render Image",
// "Remove EXIF",
// "Extract EXIF",
// "Numberwang",
// "XKCD Random Number",
// ]
// },
// {
// name: "Flow control",
// ops: [
// "Fork",
// "Merge",
// "Register",
// "Label",
// "Jump",
// "Conditional Jump",
// "Return",
// "Comment"
// ]
// },
];
export default Categories;

View file

@ -1,68 +1,20 @@
{
"To Base64": {
"From Base32": {
"module": "Default",
"description": "Base64 is a notation for encoding arbitrary byte data using a restricted set of symbols that can be conveniently used by humans and processed by computers.<br><br>This operation decodes data from an ASCII Base64 string back into its raw format.<br><br>e.g. <code>aGVsbG8=</code> becomes <code>hello</code>",
"inputType": "ArrayBuffer",
"outputType": "string",
"description": "Base32 is a notation for encoding arbitrary byte data using a restricted set of symbols that can be conveniently used by humans and processed by computers. It uses a smaller set of characters than Base64, usually the uppercase alphabet and the numbers 2 to 7.",
"inputType": "string",
"outputType": "byteArray",
"flowControl": false,
"args": [
{
"name": "Alphabet",
"type": "editableOption",
"value": [
{
"name": "Standard: A-Za-z0-9+/=",
"value": "A-Za-z0-9+/="
},
{
"name": "URL safe: A-Za-z0-9-_",
"value": "A-Za-z0-9-_"
},
{
"name": "Filename safe: A-Za-z0-9+-=",
"value": "A-Za-z0-9+\\-="
},
{
"name": "itoa64: ./0-9A-Za-z=",
"value": "./0-9A-Za-z="
},
{
"name": "XML: A-Za-z0-9_.",
"value": "A-Za-z0-9_."
},
{
"name": "y64: A-Za-z0-9._-",
"value": "A-Za-z0-9._-"
},
{
"name": "z64: 0-9a-zA-Z+/=",
"value": "0-9a-zA-Z+/="
},
{
"name": "Radix-64: 0-9A-Za-z+/=",
"value": "0-9A-Za-z+/="
},
{
"name": "Uuencoding: [space]-_",
"value": " -_"
},
{
"name": "Xxencoding: +-0-9A-Za-z",
"value": "+\\-0-9A-Za-z"
},
{
"name": "BinHex: !-,-0-689@A-NP-VX-Z[`a-fh-mp-r",
"value": "!-,-0-689@A-NP-VX-Z[`a-fh-mp-r"
},
{
"name": "ROT13: N-ZA-Mn-za-m0-9+/=",
"value": "N-ZA-Mn-za-m0-9+/="
},
{
"name": "UNIX crypt: ./0-9A-Za-z",
"value": "./0-9A-Za-z"
}
]
"type": "binaryString",
"value": "A-Z2-7="
},
{
"name": "Remove non-alphabet chars",
"type": "boolean",
"value": true
}
]
},
@ -137,5 +89,105 @@
"value": true
}
]
},
"Show Base64 offsets": {
"module": "Default",
"description": "When a string is within a block of data and the whole block is Base64'd, the string itself could be represented in Base64 in three distinct ways depending on its offset within the block.<br><br>This operation shows all possible offsets for a given string so that each possible encoding can be considered.",
"inputType": "byteArray",
"outputType": "html",
"flowControl": false,
"args": [
{
"name": "Alphabet",
"type": "binaryString",
"value": "A-Za-z0-9+/="
},
{
"name": "Show variable chars and padding",
"type": "boolean",
"value": true
}
]
},
"To Base32": {
"module": "Default",
"description": "Base32 is a notation for encoding arbitrary byte data using a restricted set of symbols that can be conveniently used by humans and processed by computers. It uses a smaller set of characters than Base64, usually the uppercase alphabet and the numbers 2 to 7.",
"inputType": "byteArray",
"outputType": "string",
"flowControl": false,
"args": [
{
"name": "Alphabet",
"type": "binaryString",
"value": "A-Z2-7="
}
]
},
"To Base64": {
"module": "Default",
"description": "Base64 is a notation for encoding arbitrary byte data using a restricted set of symbols that can be conveniently used by humans and processed by computers.<br><br>This operation decodes data from an ASCII Base64 string back into its raw format.<br><br>e.g. <code>aGVsbG8=</code> becomes <code>hello</code>",
"inputType": "ArrayBuffer",
"outputType": "string",
"flowControl": false,
"args": [
{
"name": "Alphabet",
"type": "editableOption",
"value": [
{
"name": "Standard: A-Za-z0-9+/=",
"value": "A-Za-z0-9+/="
},
{
"name": "URL safe: A-Za-z0-9-_",
"value": "A-Za-z0-9-_"
},
{
"name": "Filename safe: A-Za-z0-9+-=",
"value": "A-Za-z0-9+\\-="
},
{
"name": "itoa64: ./0-9A-Za-z=",
"value": "./0-9A-Za-z="
},
{
"name": "XML: A-Za-z0-9_.",
"value": "A-Za-z0-9_."
},
{
"name": "y64: A-Za-z0-9._-",
"value": "A-Za-z0-9._-"
},
{
"name": "z64: 0-9a-zA-Z+/=",
"value": "0-9a-zA-Z+/="
},
{
"name": "Radix-64: 0-9A-Za-z+/=",
"value": "0-9A-Za-z+/="
},
{
"name": "Uuencoding: [space]-_",
"value": " -_"
},
{
"name": "Xxencoding: +-0-9A-Za-z",
"value": "+\\-0-9A-Za-z"
},
{
"name": "BinHex: !-,-0-689@A-NP-VX-Z[`a-fh-mp-r",
"value": "!-,-0-689@A-NP-VX-Z[`a-fh-mp-r"
},
{
"name": "ROT13: N-ZA-Mn-za-m0-9+/=",
"value": "N-ZA-Mn-za-m0-9+/="
},
{
"name": "UNIX crypt: ./0-9A-Za-z",
"value": "./0-9A-Za-z"
}
]
}
]
}
}

View file

@ -14,7 +14,7 @@
import path from "path";
import fs from "fs";
import process from "process";
import OpIndex from "../operations/index";
import * as Ops from "../operations/index";
const dir = path.join(process.cwd() + "/src/core/config/");
if (!fs.existsSync(dir)) {
@ -25,14 +25,14 @@ if (!fs.existsSync(dir)) {
}
let operationConfig = {},
const operationConfig = {},
modules = {};
/**
* Generate operation config and module lists.
*/
OpIndex.forEach(opObj => {
const op = new opObj();
for (const opObj in Ops) {
const op = new Ops[opObj]();
operationConfig[op.name] = {
module: op.module,
@ -45,8 +45,8 @@ OpIndex.forEach(opObj => {
if (!modules.hasOwnProperty(op.module))
modules[op.module] = {};
modules[op.module][op.name] = op.name.replace(/\s/g, "");
});
modules[op.module][op.name] = opObj;
}
/**
@ -67,7 +67,7 @@ fs.writeFile(
/**
* Write modules.
*/
for (let module in modules) {
for (const module in modules) {
let code = `/**
* THIS FILE IS AUTOMATICALLY GENERATED BY src/core/config/generateConfig.mjs
*
@ -77,17 +77,17 @@ for (let module in modules) {
*/
`;
for (let opName in modules[module]) {
for (const opName in modules[module]) {
const objName = modules[module][opName];
code += `import ${objName} from "../../operations/${objName}";\n`;
}
code += `
let OpModules = typeof self === "undefined" ? {} : self.OpModules || {};
const OpModules = typeof self === "undefined" ? {} : self.OpModules || {};
OpModules.${module} = {
`;
for (let opName in modules[module]) {
for (const opName in modules[module]) {
const objName = modules[module][opName];
code += ` "${opName}": ${objName},\n`;
}
@ -123,18 +123,18 @@ let opModulesCode = `/**
*/
`;
for (let module in modules) {
for (const module in modules) {
opModulesCode += `import ${module}Module from "./${module}";\n`;
}
opModulesCode += `
let OpModules = {};
const OpModules = {};
Object.assign(
OpModules,
`;
for (let module in modules) {
for (const module in modules) {
opModulesCode += ` ${module}Module,\n`;
}

View file

@ -5,14 +5,20 @@
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import ToBase64 from "../../operations/ToBase64";
import FromBase32 from "../../operations/FromBase32";
import FromBase64 from "../../operations/FromBase64";
import ShowBase64Offsets from "../../operations/ShowBase64Offsets";
import ToBase32 from "../../operations/ToBase32";
import ToBase64 from "../../operations/ToBase64";
let OpModules = typeof self === "undefined" ? {} : self.OpModules || {};
const OpModules = typeof self === "undefined" ? {} : self.OpModules || {};
OpModules.Default = {
"To Base64": ToBase64,
"From Base32": FromBase32,
"From Base64": FromBase64,
"Show Base64 offsets": ShowBase64Offsets,
"To Base32": ToBase32,
"To Base64": ToBase64,
};
export default OpModules;

View file

@ -9,7 +9,7 @@
*/
import DefaultModule from "./Default";
let OpModules = {};
const OpModules = {};
Object.assign(
OpModules,