Updated a range of operations to use ArrayBuffers instead of byteArrays to improve performance with large files.

This commit is contained in:
n1474335 2019-07-29 17:09:46 +01:00
parent 3a8b362dfd
commit 0e95ad8ed6
37 changed files with 112 additions and 84 deletions

View File

@ -63,7 +63,7 @@ export function toBase64(data, alphabet="A-Za-z0-9+/=") {
/**
* UnBase64's the input string using the given alphabet, returning a byte array.
*
* @param {byteArray} data
* @param {string} data
* @param {string} [alphabet="A-Za-z0-9+/="]
* @param {string} [returnType="string"] - Either "string" or "byteArray"
* @param {boolean} [removeNonAlphChars=true]

View File

@ -9,7 +9,7 @@
/**
* Runs bitwise operations across the input data.
*
* @param {byteArray} input
* @param {byteArray|Uint8Array} input
* @param {byteArray} key
* @param {function} func - The bitwise calculation to carry out
* @param {boolean} nullPreserving

View File

@ -16,14 +16,14 @@ class Protobuf {
/**
* Protobuf constructor
*
* @param {byteArray} data
* @param {byteArray|Uint8Array} data
*/
constructor(data) {
// Check we have a byteArray
if (data instanceof Array) {
// Check we have a byteArray or Uint8Array
if (data instanceof Array || data instanceof Uint8Array) {
this.data = data;
} else {
throw new Error("Protobuf input must be a byteArray");
throw new Error("Protobuf input must be a byteArray or Uint8Array");
}
// Set up masks

View File

@ -21,7 +21,7 @@ export default class TLVParser {
/**
* TLVParser constructor
*
* @param {byteArray} input
* @param {byteArray|Uint8Array} input
* @param {Object} options
*/
constructor(input, options) {

View File

@ -22,13 +22,13 @@ class Adler32Checksum extends Operation {
this.module = "Crypto";
this.description = "Adler-32 is a checksum algorithm which was invented by Mark Adler in 1995, and is a modification of the Fletcher checksum. Compared to a cyclic redundancy check of the same length, it trades reliability for speed (preferring the latter).<br><br>Adler-32 is more reliable than Fletcher-16, and slightly less reliable than Fletcher-32.";
this.infoURL = "https://wikipedia.org/wiki/Adler-32";
this.inputType = "byteArray";
this.inputType = "ArrayBuffer";
this.outputType = "string";
this.args = [];
}
/**
* @param {byteArray} input
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {string}
*/
@ -36,6 +36,7 @@ class Adler32Checksum extends Operation {
const MOD_ADLER = 65521;
let a = 1,
b = 0;
input = new Uint8Array(input);
for (let i = 0; i < input.length; i++) {
a += input[i];

View File

@ -21,8 +21,8 @@ class BitShiftLeft extends Operation {
this.module = "Default";
this.description = "Shifts the bits in each byte towards the left by the specified amount.";
this.infoURL = "https://wikipedia.org/wiki/Bitwise_operation#Bit_shifts";
this.inputType = "byteArray";
this.outputType = "byteArray";
this.inputType = "ArrayBuffer";
this.outputType = "ArrayBuffer";
this.args = [
{
"name": "Amount",
@ -33,16 +33,17 @@ class BitShiftLeft extends Operation {
}
/**
* @param {byteArray} input
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {byteArray}
* @returns {ArrayBuffer}
*/
run(input, args) {
const amount = args[0];
input = new Uint8Array(input);
return input.map(b => {
return (b << amount) & 0xff;
});
}).buffer;
}
/**

View File

@ -21,8 +21,8 @@ class BitShiftRight extends Operation {
this.module = "Default";
this.description = "Shifts the bits in each byte towards the right by the specified amount.<br><br><i>Logical shifts</i> replace the leftmost bits with zeros.<br><i>Arithmetic shifts</i> preserve the most significant bit (MSB) of the original byte keeping the sign the same (positive or negative).";
this.infoURL = "https://wikipedia.org/wiki/Bitwise_operation#Bit_shifts";
this.inputType = "byteArray";
this.outputType = "byteArray";
this.inputType = "ArrayBuffer";
this.outputType = "ArrayBuffer";
this.args = [
{
"name": "Amount",
@ -38,18 +38,19 @@ class BitShiftRight extends Operation {
}
/**
* @param {byteArray} input
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {byteArray}
* @returns {ArrayBuffer}
*/
run(input, args) {
const amount = args[0],
type = args[1],
mask = type === "Logical shift" ? 0 : 0x80;
input = new Uint8Array(input);
return input.map(b => {
return (b >>> amount) ^ (b & mask);
});
}).buffer;
}
/**

View File

@ -23,17 +23,18 @@ class CitrixCTX1Decode extends Operation {
this.module = "Encodings";
this.description = "Decodes strings in a Citrix CTX1 password format to plaintext.";
this.infoURL = "https://www.reddit.com/r/AskNetsec/comments/1s3r6y/citrix_ctx1_hash_decoding/";
this.inputType = "byteArray";
this.inputType = "ArrayBuffer";
this.outputType = "string";
this.args = [];
}
/**
* @param {byteArray} input
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {string}
*/
run(input, args) {
input = new Uint8Array(input);
if (input.length % 4 !== 0) {
throw new OperationError("Incorrect hash length");
}

View File

@ -30,7 +30,7 @@ class DecodeText extends Operation {
"</ul>",
].join("\n");
this.infoURL = "https://wikipedia.org/wiki/Character_encoding";
this.inputType = "byteArray";
this.inputType = "ArrayBuffer";
this.outputType = "string";
this.args = [
{
@ -42,13 +42,13 @@ class DecodeText extends Operation {
}
/**
* @param {byteArray} input
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {string}
*/
run(input, args) {
const format = IO_FORMAT[args[0]];
return cptable.utils.decode(format, input);
return cptable.utils.decode(format, new Uint8Array(input));
}
}

View File

@ -31,7 +31,7 @@ class EncodeText extends Operation {
].join("\n");
this.infoURL = "https://wikipedia.org/wiki/Character_encoding";
this.inputType = "string";
this.outputType = "byteArray";
this.outputType = "ArrayBuffer";
this.args = [
{
"name": "Encoding",
@ -44,13 +44,12 @@ class EncodeText extends Operation {
/**
* @param {string} input
* @param {Object[]} args
* @returns {byteArray}
* @returns {ArrayBuffer}
*/
run(input, args) {
const format = IO_FORMAT[args[0]];
let encoded = cptable.utils.encode(format, input);
encoded = Array.from(encoded);
return encoded;
const encoded = cptable.utils.encode(format, input);
return new Uint8Array(encoded).buffer;
}
}

View File

@ -22,19 +22,20 @@ class Fletcher16Checksum extends Operation {
this.module = "Crypto";
this.description = "The Fletcher checksum is an algorithm for computing a position-dependent checksum devised by John Gould Fletcher at Lawrence Livermore Labs in the late 1970s.<br><br>The objective of the Fletcher checksum was to provide error-detection properties approaching those of a cyclic redundancy check but with the lower computational effort associated with summation techniques.";
this.infoURL = "https://wikipedia.org/wiki/Fletcher%27s_checksum#Fletcher-16";
this.inputType = "byteArray";
this.inputType = "ArrayBuffer";
this.outputType = "string";
this.args = [];
}
/**
* @param {byteArray} input
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {string}
*/
run(input, args) {
let a = 0,
b = 0;
input = new Uint8Array(input);
for (let i = 0; i < input.length; i++) {
a = (a + input[i]) % 0xff;

View File

@ -22,19 +22,20 @@ class Fletcher32Checksum extends Operation {
this.module = "Crypto";
this.description = "The Fletcher checksum is an algorithm for computing a position-dependent checksum devised by John Gould Fletcher at Lawrence Livermore Labs in the late 1970s.<br><br>The objective of the Fletcher checksum was to provide error-detection properties approaching those of a cyclic redundancy check but with the lower computational effort associated with summation techniques.";
this.infoURL = "https://wikipedia.org/wiki/Fletcher%27s_checksum#Fletcher-32";
this.inputType = "byteArray";
this.inputType = "ArrayBuffer";
this.outputType = "string";
this.args = [];
}
/**
* @param {byteArray} input
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {string}
*/
run(input, args) {
let a = 0,
b = 0;
input = new Uint8Array(input);
for (let i = 0; i < input.length; i++) {
a = (a + input[i]) % 0xffff;

View File

@ -22,19 +22,20 @@ class Fletcher64Checksum extends Operation {
this.module = "Crypto";
this.description = "The Fletcher checksum is an algorithm for computing a position-dependent checksum devised by John Gould Fletcher at Lawrence Livermore Labs in the late 1970s.<br><br>The objective of the Fletcher checksum was to provide error-detection properties approaching those of a cyclic redundancy check but with the lower computational effort associated with summation techniques.";
this.infoURL = "https://wikipedia.org/wiki/Fletcher%27s_checksum#Fletcher-64";
this.inputType = "byteArray";
this.inputType = "ArrayBuffer";
this.outputType = "string";
this.args = [];
}
/**
* @param {byteArray} input
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {string}
*/
run(input, args) {
let a = 0,
b = 0;
input = new Uint8Array(input);
for (let i = 0; i < input.length; i++) {
a = (a + input[i]) % 0xffffffff;

View File

@ -22,19 +22,20 @@ class Fletcher8Checksum extends Operation {
this.module = "Crypto";
this.description = "The Fletcher checksum is an algorithm for computing a position-dependent checksum devised by John Gould Fletcher at Lawrence Livermore Labs in the late 1970s.<br><br>The objective of the Fletcher checksum was to provide error-detection properties approaching those of a cyclic redundancy check but with the lower computational effort associated with summation techniques.";
this.infoURL = "https://wikipedia.org/wiki/Fletcher%27s_checksum";
this.inputType = "byteArray";
this.inputType = "ArrayBuffer";
this.outputType = "string";
this.args = [];
}
/**
* @param {byteArray} input
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {string}
*/
run(input, args) {
let a = 0,
b = 0;
input = new Uint8Array(input);
for (let i = 0; i < input.length; i++) {
a = (a + input[i]) % 0xf;

View File

@ -106,9 +106,9 @@ class FromBase64 extends Operation {
}
/**
* @param {ArrayBuffer} input
* @param {string} input
* @param {Object[]} args
* @returns {string}
* @returns {byteArray}
*/
run(input, args) {
const [alphabet, removeNonAlphChars] = args;

View File

@ -23,7 +23,7 @@ class GenerateHOTP extends Operation {
this.module = "Default";
this.description = "The HMAC-based One-Time Password algorithm (HOTP) is an algorithm that computes a one-time password from a shared secret key and an incrementing counter. It has been adopted as Internet Engineering Task Force standard RFC 4226, is the cornerstone of Initiative For Open Authentication (OATH), and is used in a number of two-factor authentication systems.<br><br>Enter the secret as the input or leave it blank for a random secret to be generated.";
this.infoURL = "https://wikipedia.org/wiki/HMAC-based_One-time_Password_algorithm";
this.inputType = "byteArray";
this.inputType = "ArrayBuffer";
this.outputType = "string";
this.args = [
{
@ -50,7 +50,7 @@ class GenerateHOTP extends Operation {
}
/**
* @param {byteArray} input
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {string}
*/

View File

@ -23,7 +23,7 @@ class GenerateTOTP extends Operation {
this.module = "Default";
this.description = "The Time-based One-Time Password algorithm (TOTP) is an algorithm that computes a one-time password from a shared secret key and the current time. It has been adopted as Internet Engineering Task Force standard RFC 6238, is the cornerstone of Initiative For Open Authentication (OATH), and is used in a number of two-factor authentication systems. A TOTP is an HOTP where the counter is the current time.<br><br>Enter the secret as the input or leave it blank for a random secret to be generated. T0 and T1 are in seconds.";
this.infoURL = "https://wikipedia.org/wiki/Time-based_One-time_Password_algorithm";
this.inputType = "byteArray";
this.inputType = "ArrayBuffer";
this.outputType = "string";
this.args = [
{
@ -55,7 +55,7 @@ class GenerateTOTP extends Operation {
}
/**
* @param {byteArray} input
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {string}
*/

View File

@ -22,17 +22,18 @@ class NOT extends Operation {
this.module = "Default";
this.description = "Returns the inverse of each byte.";
this.infoURL = "https://wikipedia.org/wiki/Bitwise_operation#NOT";
this.inputType = "byteArray";
this.inputType = "ArrayBuffer";
this.outputType = "byteArray";
this.args = [];
}
/**
* @param {byteArray} input
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {byteArray}
*/
run(input, args) {
input = new Uint8Array(input);
return bitOp(input, null, not);
}

View File

@ -23,7 +23,7 @@ class OR extends Operation {
this.module = "Default";
this.description = "OR the input with the given key.<br>e.g. <code>fe023da5</code>";
this.infoURL = "https://wikipedia.org/wiki/Bitwise_operation#OR";
this.inputType = "byteArray";
this.inputType = "ArrayBuffer";
this.outputType = "byteArray";
this.args = [
{
@ -36,12 +36,13 @@ class OR extends Operation {
}
/**
* @param {byteArray} input
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {byteArray}
*/
run(input, args) {
const key = Utils.convertToByteArray(args[0].string || "", args[0].option);
input = new Uint8Array(input);
return bitOp(input, key, or);
}

View File

@ -24,7 +24,7 @@ class ParseTLV extends Operation {
this.module = "Default";
this.description = "Converts a Type-Length-Value (TLV) encoded string into a JSON object. Can optionally include a <code>Key</code> / <code>Type</code> entry. <br><br>Tags: Key-Length-Value, KLV, Length-Value, LV";
this.infoURL = "https://wikipedia.org/wiki/Type-length-value";
this.inputType = "byteArray";
this.inputType = "ArrayBuffer";
this.outputType = "JSON";
this.args = [
{
@ -46,12 +46,13 @@ class ParseTLV extends Operation {
}
/**
* @param {byteArray} input
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {string}
*/
run(input, args) {
const [bytesInKey, bytesInLength, basicEncodingRules] = args;
input = new Uint8Array(input);
if (bytesInKey <= 0 && bytesInLength <= 0)
throw new OperationError("Type or Length size must be greater than 0");

View File

@ -23,17 +23,18 @@ class ProtobufDecode extends Operation {
this.module = "Default";
this.description = "Decodes any Protobuf encoded data to a JSON representation of the data using the field number as the field key.";
this.infoURL = "https://wikipedia.org/wiki/Protocol_Buffers";
this.inputType = "byteArray";
this.inputType = "ArrayBuffer";
this.outputType = "JSON";
this.args = [];
}
/**
* @param {byteArray} input
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {JSON}
*/
run(input, args) {
input = new Uint8Array(input);
try {
return Protobuf.decode(input);
} catch (err) {

View File

@ -27,17 +27,18 @@ class RemoveEXIF extends Operation {
"EXIF data embedded in photos usually contains information about the image file itself as well as the device used to create it.",
].join("\n");
this.infoURL = "https://wikipedia.org/wiki/Exif";
this.inputType = "byteArray";
this.inputType = "ArrayBuffer";
this.outputType = "byteArray";
this.args = [];
}
/**
* @param {byteArray} input
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {byteArray}
*/
run(input, args) {
input = new Uint8Array(input);
// Do nothing if input is empty
if (input.length === 0) return input;

View File

@ -20,17 +20,18 @@ class RemoveNullBytes extends Operation {
this.name = "Remove null bytes";
this.module = "Default";
this.description = "Removes all null bytes (<code>0x00</code>) from the input.";
this.inputType = "byteArray";
this.inputType = "ArrayBuffer";
this.outputType = "byteArray";
this.args = [];
}
/**
* @param {byteArray} input
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {byteArray}
*/
run(input, args) {
input = new Uint8Array(input);
const output = [];
for (let i = 0; i < input.length; i++) {
if (input[i] !== 0) output.push(input[i]);

View File

@ -26,18 +26,19 @@ class SplitColourChannels extends Operation {
this.module = "Image";
this.description = "Splits the given image into its red, green and blue colour channels.";
this.infoURL = "https://wikipedia.org/wiki/Channel_(digital_image)";
this.inputType = "byteArray";
this.inputType = "ArrayBuffer";
this.outputType = "List<File>";
this.presentType = "html";
this.args = [];
}
/**
* @param {byteArray} input
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {List<File>}
*/
async run(input, args) {
input = new Uint8Array(input);
// Make sure that the input is an image
if (!isImage(input)) throw new OperationError("Invalid file type.");

View File

@ -22,17 +22,18 @@ class TCPIPChecksum extends Operation {
this.module = "Crypto";
this.description = "Calculates the checksum for a TCP (Transport Control Protocol) or IP (Internet Protocol) header from an input of raw bytes.";
this.infoURL = "https://wikipedia.org/wiki/IPv4_header_checksum";
this.inputType = "byteArray";
this.inputType = "ArrayBuffer";
this.outputType = "string";
this.args = [];
}
/**
* @param {byteArray} input
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {string}
*/
run(input, args) {
input = new Uint8Array(input);
let csum = 0;
for (let i = 0; i < input.length; i++) {

View File

@ -22,7 +22,7 @@ class Tar extends Operation {
this.module = "Compression";
this.description = "Packs the input into a tarball.<br><br>No support for multiple files at this time.";
this.infoURL = "https://wikipedia.org/wiki/Tar_(computing)";
this.inputType = "byteArray";
this.inputType = "ArrayBuffer";
this.outputType = "File";
this.args = [
{
@ -34,11 +34,13 @@ class Tar extends Operation {
}
/**
* @param {byteArray} input
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {byteArray}
*/
run(input, args) {
input = new Uint8Array(input);
const Tarball = function() {
this.bytes = new Array(512);
this.position = 0;

View File

@ -22,7 +22,7 @@ class ToBase32 extends Operation {
this.module = "Default";
this.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.";
this.infoURL = "https://wikipedia.org/wiki/Base32";
this.inputType = "byteArray";
this.inputType = "ArrayBuffer";
this.outputType = "string";
this.args = [
{
@ -34,12 +34,13 @@ class ToBase32 extends Operation {
}
/**
* @param {byteArray} input
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {string}
*/
run(input, args) {
if (!input) return "";
input = new Uint8Array(input);
const alphabet = args[0] ? Utils.expandAlphRange(args[0]).join("") : "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=";
let output = "",

View File

@ -24,7 +24,7 @@ class ToBase58 extends Operation {
this.module = "Default";
this.description = "Base58 (similar to Base64) is a notation for encoding arbitrary byte data. It differs from Base64 by removing easily misread characters (i.e. l, I, 0 and O) to improve human readability.<br><br>This operation encodes data in an ASCII string (with an alphabet of your choosing, presets included).<br><br>e.g. <code>hello world</code> becomes <code>StV1DL6CwTryKyV</code><br><br>Base58 is commonly used in cryptocurrencies (Bitcoin, Ripple, etc).";
this.infoURL = "https://wikipedia.org/wiki/Base58";
this.inputType = "byteArray";
this.inputType = "ArrayBuffer";
this.outputType = "string";
this.args = [
{
@ -36,11 +36,12 @@ class ToBase58 extends Operation {
}
/**
* @param {byteArray} input
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {string}
*/
run(input, args) {
input = new Uint8Array(input);
let alphabet = args[0] || ALPHABET_OPTIONS[0].value,
result = [0];

View File

@ -24,7 +24,7 @@ class ToBase62 extends Operation {
this.module = "Default";
this.description = "Base62 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. The high number base results in shorter strings than with the decimal or hexadecimal system.";
this.infoURL = "https://wikipedia.org/wiki/List_of_numeral_systems";
this.inputType = "byteArray";
this.inputType = "ArrayBuffer";
this.outputType = "string";
this.args = [
{
@ -36,11 +36,12 @@ class ToBase62 extends Operation {
}
/**
* @param {string} input
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {string}
*/
run(input, args) {
input = new Uint8Array(input);
if (input.length < 1) return "";
const ALPHABET = Utils.expandAlphRange(args[0]).join("");

View File

@ -24,7 +24,7 @@ class ToBase85 extends Operation {
this.module = "Default";
this.description = "Base85 (also called Ascii85) is a notation for encoding arbitrary byte data. It is usually more efficient that Base64.<br><br>This operation encodes data in an ASCII string (with an alphabet of your choosing, presets included).<br><br>e.g. <code>hello world</code> becomes <code>BOu!rD]j7BEbo7</code><br><br>Base85 is commonly used in Adobe's PostScript and PDF file formats.<br><br><strong>Options</strong><br><u>Alphabet</u><ul><li>Standard - The standard alphabet, referred to as Ascii85</li><li>Z85 (ZeroMQ) - A string-safe variant of Base85, which avoids quote marks and backslash characters</li><li>IPv6 - A variant of Base85 suitable for encoding IPv6 addresses (RFC 1924)</li></ul><u>Include delimiter</u><br>Adds a '<~' and '~>' delimiter to the start and end of the data. This is standard for Adobe's implementation of Base85.";
this.infoURL = "https://wikipedia.org/wiki/Ascii85";
this.inputType = "byteArray";
this.inputType = "ArrayBuffer";
this.outputType = "string";
this.args = [
{
@ -41,11 +41,12 @@ class ToBase85 extends Operation {
}
/**
* @param {byteArray} input
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {string}
*/
run(input, args) {
input = new Uint8Array(input);
const alphabet = Utils.expandAlphRange(args[0]).join(""),
encoding = alphabetName(alphabet),
includeDelim = args[1];

View File

@ -24,7 +24,7 @@ class ToBinary extends Operation {
this.module = "Default";
this.description = "Displays the input data as a binary string.<br><br>e.g. <code>Hi</code> becomes <code>01001000 01101001</code>";
this.infoURL = "https://wikipedia.org/wiki/Binary_code";
this.inputType = "byteArray";
this.inputType = "ArrayBuffer";
this.outputType = "string";
this.args = [
{
@ -36,11 +36,12 @@ class ToBinary extends Operation {
}
/**
* @param {byteArray} input
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {string}
*/
run(input, args) {
input = new Uint8Array(input);
return toBinary(input, args[0]);
}

View File

@ -23,7 +23,7 @@ class ToDecimal extends Operation {
this.name = "To Decimal";
this.module = "Default";
this.description = "Converts the input data to an ordinal integer array.<br><br>e.g. <code>Hello</code> becomes <code>72 101 108 108 111</code>";
this.inputType = "byteArray";
this.inputType = "ArrayBuffer";
this.outputType = "string";
this.args = [
{
@ -40,11 +40,12 @@ class ToDecimal extends Operation {
}
/**
* @param {byteArray} input
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {string}
*/
run(input, args) {
input = new Uint8Array(input);
const delim = Utils.charRep(args[0]),
signed = args[1];
if (signed) {

View File

@ -23,7 +23,7 @@ class ToHexContent extends Operation {
this.module = "Default";
this.description = "Converts special characters in a string to hexadecimal. This format is used by SNORT for representing hex within ASCII text.<br><br>e.g. <code>foo=bar</code> becomes <code>foo|3d|bar</code>.";
this.infoURL = "http://manual-snort-org.s3-website-us-east-1.amazonaws.com/node32.html#SECTION00451000000000000000";
this.inputType = "byteArray";
this.inputType = "ArrayBuffer";
this.outputType = "string";
this.args = [
{
@ -40,11 +40,12 @@ class ToHexContent extends Operation {
}
/**
* @param {byteArray} input
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {string}
*/
run(input, args) {
input = new Uint8Array(input);
const convert = args[0];
const spaces = args[1];
if (convert === "All chars") {

View File

@ -25,17 +25,18 @@ class ToQuotedPrintable extends Operation {
this.module = "Default";
this.description = "Quoted-Printable, or QP encoding, is an encoding using printable ASCII characters (alphanumeric and the equals sign '=') to transmit 8-bit data over a 7-bit data path or, generally, over a medium which is not 8-bit clean. It is defined as a MIME content transfer encoding for use in e-mail.<br><br>QP works by using the equals sign '=' as an escape character. It also limits line length to 76, as some software has limits on line length.";
this.infoURL = "https://wikipedia.org/wiki/Quoted-printable";
this.inputType = "byteArray";
this.inputType = "ArrayBuffer";
this.outputType = "string";
this.args = [];
}
/**
* @param {byteArray} input
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {string}
*/
run(input, args) {
input = new Uint8Array(input);
let mimeEncodedStr = this.mimeEncode(input);
// fix line breaks
@ -73,7 +74,7 @@ class ToQuotedPrintable extends Operation {
/**
* Encodes mime data.
*
* @param {byteArray} buffer
* @param {byteArray|Uint8Array} buffer
* @returns {string}
*/
mimeEncode(buffer) {

View File

@ -23,7 +23,7 @@ class Untar extends Operation {
this.module = "Compression";
this.description = "Unpacks a tarball and displays it per file.";
this.infoURL = "https://wikipedia.org/wiki/Tar_(computing)";
this.inputType = "byteArray";
this.inputType = "ArrayBuffer";
this.outputType = "List<File>";
this.presentType = "html";
this.args = [];
@ -37,11 +37,12 @@ class Untar extends Operation {
}
/**
* @param {byteArray} input
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {List<File>}
*/
run(input, args) {
input = new Uint8Array(input);
const stream = new Stream(input),
files = [];

View File

@ -23,7 +23,7 @@ class XOR extends Operation {
this.module = "Default";
this.description = "XOR the input with the given key.<br>e.g. <code>fe023da5</code><br><br><strong>Options</strong><br><u>Null preserving:</u> If the current byte is 0x00 or the same as the key, skip it.<br><br><u>Scheme:</u><ul><li>Standard - key is unchanged after each round</li><li>Input differential - key is set to the value of the previous unprocessed byte</li><li>Output differential - key is set to the value of the previous processed byte</li><li>Cascade - key is set to the input byte shifted by one</li></ul>";
this.infoURL = "https://wikipedia.org/wiki/XOR";
this.inputType = "byteArray";
this.inputType = "ArrayBuffer";
this.outputType = "byteArray";
this.args = [
{
@ -46,11 +46,12 @@ class XOR extends Operation {
}
/**
* @param {byteArray} input
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {byteArray}
*/
run(input, args) {
input = new Uint8Array(input);
const key = Utils.convertToByteArray(args[0].string || "", args[0].option),
[, scheme, nullPreserving] = args;

View File

@ -25,7 +25,7 @@ class XORBruteForce extends Operation {
this.module = "Default";
this.description = "Enumerate all possible XOR solutions. Current maximum key length is 2 due to browser performance.<br><br>Optionally enter a string that you expect to find in the plaintext to filter results (crib).";
this.infoURL = "https://wikipedia.org/wiki/Exclusive_or";
this.inputType = "byteArray";
this.inputType = "ArrayBuffer";
this.outputType = "string";
this.args = [
{
@ -72,11 +72,12 @@ class XORBruteForce extends Operation {
}
/**
* @param {byteArray} input
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {string}
*/
run(input, args) {
input = new Uint8Array(input);
const [
keyLength,
sampleLength,