mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-21 23:36:16 -04:00
eslint autofix
This commit is contained in:
parent
0d42541860
commit
ad730d806b
60 changed files with 13067 additions and 13014 deletions
|
@ -9,38 +9,38 @@
|
|||
*
|
||||
* @namespace
|
||||
*/
|
||||
var Compress = {
|
||||
const Compress = {
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
COMPRESSION_TYPE: ["Dynamic Huffman Coding", "Fixed Huffman Coding", "None (Store)"],
|
||||
COMPRESSION_TYPE: ['Dynamic Huffman Coding', 'Fixed Huffman Coding', 'None (Store)'],
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
INFLATE_BUFFER_TYPE: ["Adaptive", "Block"],
|
||||
INFLATE_BUFFER_TYPE: ['Adaptive', 'Block'],
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
COMPRESSION_METHOD: ["Deflate", "None (Store)"],
|
||||
COMPRESSION_METHOD: ['Deflate', 'None (Store)'],
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
OS: ["MSDOS", "Unix", "Macintosh"],
|
||||
OS: ['MSDOS', 'Unix', 'Macintosh'],
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
RAW_COMPRESSION_TYPE_LOOKUP: {
|
||||
"Fixed Huffman Coding" : Zlib.RawDeflate.CompressionType.FIXED,
|
||||
"Dynamic Huffman Coding" : Zlib.RawDeflate.CompressionType.DYNAMIC,
|
||||
"None (Store)" : Zlib.RawDeflate.CompressionType.NONE,
|
||||
},
|
||||
|
||||
RAW_COMPRESSION_TYPE_LOOKUP: {
|
||||
'Fixed Huffman Coding': Zlib.RawDeflate.CompressionType.FIXED,
|
||||
'Dynamic Huffman Coding': Zlib.RawDeflate.CompressionType.DYNAMIC,
|
||||
'None (Store)': Zlib.RawDeflate.CompressionType.NONE,
|
||||
},
|
||||
|
||||
/**
|
||||
* Raw Deflate operation.
|
||||
*
|
||||
|
@ -48,43 +48,43 @@ var Compress = {
|
|||
* @param {Object[]} args
|
||||
* @returns {byte_array}
|
||||
*/
|
||||
run_raw_deflate: function(input, args) {
|
||||
var deflate = new Zlib.RawDeflate(input, {
|
||||
compressionType: Compress.RAW_COMPRESSION_TYPE_LOOKUP[args[0]]
|
||||
});
|
||||
return Array.prototype.slice.call(deflate.compress());
|
||||
},
|
||||
|
||||
|
||||
run_raw_deflate(input, args) {
|
||||
const deflate = new Zlib.RawDeflate(input, {
|
||||
compressionType: Compress.RAW_COMPRESSION_TYPE_LOOKUP[args[0]],
|
||||
});
|
||||
return Array.prototype.slice.call(deflate.compress());
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
INFLATE_INDEX: 0,
|
||||
INFLATE_INDEX: 0,
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
INFLATE_BUFFER_SIZE: 0,
|
||||
INFLATE_BUFFER_SIZE: 0,
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
INFLATE_RESIZE: false,
|
||||
INFLATE_RESIZE: false,
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
INFLATE_VERIFY: false,
|
||||
INFLATE_VERIFY: false,
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
RAW_BUFFER_TYPE_LOOKUP: {
|
||||
"Adaptive" : Zlib.RawInflate.BufferType.ADAPTIVE,
|
||||
"Block" : Zlib.RawInflate.BufferType.BLOCK,
|
||||
},
|
||||
|
||||
RAW_BUFFER_TYPE_LOOKUP: {
|
||||
Adaptive: Zlib.RawInflate.BufferType.ADAPTIVE,
|
||||
Block: Zlib.RawInflate.BufferType.BLOCK,
|
||||
},
|
||||
|
||||
/**
|
||||
* Raw Inflate operation.
|
||||
*
|
||||
|
@ -92,51 +92,51 @@ var Compress = {
|
|||
* @param {Object[]} args
|
||||
* @returns {byte_array}
|
||||
*/
|
||||
run_raw_inflate: function(input, args) {
|
||||
run_raw_inflate(input, args) {
|
||||
// Deal with character encoding issues
|
||||
input = Utils.str_to_byte_array(Utils.byte_array_to_utf8(input));
|
||||
var inflate = new Zlib.RawInflate(input, {
|
||||
index: args[0],
|
||||
bufferSize: args[1],
|
||||
bufferType: Compress.RAW_BUFFER_TYPE_LOOKUP[args[2]],
|
||||
resize: args[3],
|
||||
verify: args[4]
|
||||
}),
|
||||
result = Array.prototype.slice.call(inflate.decompress());
|
||||
|
||||
input = Utils.str_to_byte_array(Utils.byte_array_to_utf8(input));
|
||||
let inflate = new Zlib.RawInflate(input, {
|
||||
index: args[0],
|
||||
bufferSize: args[1],
|
||||
bufferType: Compress.RAW_BUFFER_TYPE_LOOKUP[args[2]],
|
||||
resize: args[3],
|
||||
verify: args[4],
|
||||
}),
|
||||
result = Array.prototype.slice.call(inflate.decompress());
|
||||
|
||||
// Raw Inflate somethimes messes up and returns nonsense like this:
|
||||
// ]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]...
|
||||
// e.g. Input data of [8b, 1d, dc, 44]
|
||||
// Look for the first two square brackets:
|
||||
if (result.length > 158 && result[0] == 93 && result[5] == 93) {
|
||||
if (result.length > 158 && result[0] == 93 && result[5] == 93) {
|
||||
// If the first two square brackets are there, check that the others
|
||||
// are also there. If they are, throw an error. If not, continue.
|
||||
var valid = false;
|
||||
for (var i = 0; i < 155; i += 5) {
|
||||
if (result[i] != 93) {
|
||||
valid = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!valid) {
|
||||
throw "Error: Unable to inflate data";
|
||||
}
|
||||
let valid = false;
|
||||
for (let i = 0; i < 155; i += 5) {
|
||||
if (result[i] != 93) {
|
||||
valid = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!valid) {
|
||||
throw 'Error: Unable to inflate data';
|
||||
}
|
||||
}
|
||||
// Trust me, this is the easiest way...
|
||||
return result;
|
||||
},
|
||||
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
ZLIB_COMPRESSION_TYPE_LOOKUP: {
|
||||
"Fixed Huffman Coding" : Zlib.Deflate.CompressionType.FIXED,
|
||||
"Dynamic Huffman Coding" : Zlib.Deflate.CompressionType.DYNAMIC,
|
||||
"None (Store)" : Zlib.Deflate.CompressionType.NONE,
|
||||
},
|
||||
|
||||
ZLIB_COMPRESSION_TYPE_LOOKUP: {
|
||||
'Fixed Huffman Coding': Zlib.Deflate.CompressionType.FIXED,
|
||||
'Dynamic Huffman Coding': Zlib.Deflate.CompressionType.DYNAMIC,
|
||||
'None (Store)': Zlib.Deflate.CompressionType.NONE,
|
||||
},
|
||||
|
||||
/**
|
||||
* Zlib Deflate operation.
|
||||
*
|
||||
|
@ -144,23 +144,23 @@ var Compress = {
|
|||
* @param {Object[]} args
|
||||
* @returns {byte_array}
|
||||
*/
|
||||
run_zlib_deflate: function(input, args) {
|
||||
var deflate = new Zlib.Deflate(input, {
|
||||
compressionType: Compress.ZLIB_COMPRESSION_TYPE_LOOKUP[args[0]]
|
||||
});
|
||||
return Array.prototype.slice.call(deflate.compress());
|
||||
},
|
||||
|
||||
|
||||
run_zlib_deflate(input, args) {
|
||||
const deflate = new Zlib.Deflate(input, {
|
||||
compressionType: Compress.ZLIB_COMPRESSION_TYPE_LOOKUP[args[0]],
|
||||
});
|
||||
return Array.prototype.slice.call(deflate.compress());
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
ZLIB_BUFFER_TYPE_LOOKUP: {
|
||||
"Adaptive" : Zlib.Inflate.BufferType.ADAPTIVE,
|
||||
"Block" : Zlib.Inflate.BufferType.BLOCK,
|
||||
},
|
||||
|
||||
ZLIB_BUFFER_TYPE_LOOKUP: {
|
||||
Adaptive: Zlib.Inflate.BufferType.ADAPTIVE,
|
||||
Block: Zlib.Inflate.BufferType.BLOCK,
|
||||
},
|
||||
|
||||
/**
|
||||
* Zlib Inflate operation.
|
||||
*
|
||||
|
@ -168,26 +168,26 @@ var Compress = {
|
|||
* @param {Object[]} args
|
||||
* @returns {byte_array}
|
||||
*/
|
||||
run_zlib_inflate: function(input, args) {
|
||||
run_zlib_inflate(input, args) {
|
||||
// Deal with character encoding issues
|
||||
input = Utils.str_to_byte_array(Utils.byte_array_to_utf8(input));
|
||||
var inflate = new Zlib.Inflate(input, {
|
||||
index: args[0],
|
||||
bufferSize: args[1],
|
||||
bufferType: Compress.ZLIB_BUFFER_TYPE_LOOKUP[args[2]],
|
||||
resize: args[3],
|
||||
verify: args[4]
|
||||
});
|
||||
return Array.prototype.slice.call(inflate.decompress());
|
||||
},
|
||||
|
||||
|
||||
input = Utils.str_to_byte_array(Utils.byte_array_to_utf8(input));
|
||||
const inflate = new Zlib.Inflate(input, {
|
||||
index: args[0],
|
||||
bufferSize: args[1],
|
||||
bufferType: Compress.ZLIB_BUFFER_TYPE_LOOKUP[args[2]],
|
||||
resize: args[3],
|
||||
verify: args[4],
|
||||
});
|
||||
return Array.prototype.slice.call(inflate.decompress());
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
GZIP_CHECKSUM: false,
|
||||
|
||||
GZIP_CHECKSUM: false,
|
||||
|
||||
/**
|
||||
* Gzip operation.
|
||||
*
|
||||
|
@ -195,32 +195,32 @@ var Compress = {
|
|||
* @param {Object[]} args
|
||||
* @returns {byte_array}
|
||||
*/
|
||||
run_gzip: function(input, args) {
|
||||
var filename = args[1],
|
||||
comment = args[2],
|
||||
options = {
|
||||
deflateOptions: {
|
||||
compressionType: Compress.ZLIB_COMPRESSION_TYPE_LOOKUP[args[0]]
|
||||
},
|
||||
flags: {
|
||||
fhcrc: args[3]
|
||||
}
|
||||
};
|
||||
|
||||
if (filename.length) {
|
||||
options.flags.fname = true;
|
||||
options.filename = filename;
|
||||
}
|
||||
if (comment.length) {
|
||||
options.flags.fcommenct = true;
|
||||
options.comment = comment;
|
||||
}
|
||||
|
||||
var gzip = new Zlib.Gzip(input, options);
|
||||
return Array.prototype.slice.call(gzip.compress());
|
||||
},
|
||||
|
||||
|
||||
run_gzip(input, args) {
|
||||
let filename = args[1],
|
||||
comment = args[2],
|
||||
options = {
|
||||
deflateOptions: {
|
||||
compressionType: Compress.ZLIB_COMPRESSION_TYPE_LOOKUP[args[0]],
|
||||
},
|
||||
flags: {
|
||||
fhcrc: args[3],
|
||||
},
|
||||
};
|
||||
|
||||
if (filename.length) {
|
||||
options.flags.fname = true;
|
||||
options.filename = filename;
|
||||
}
|
||||
if (comment.length) {
|
||||
options.flags.fcommenct = true;
|
||||
options.comment = comment;
|
||||
}
|
||||
|
||||
const gzip = new Zlib.Gzip(input, options);
|
||||
return Array.prototype.slice.call(gzip.compress());
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Gunzip operation.
|
||||
*
|
||||
|
@ -228,37 +228,37 @@ var Compress = {
|
|||
* @param {Object[]} args
|
||||
* @returns {byte_array}
|
||||
*/
|
||||
run_gunzip: function(input, args) {
|
||||
run_gunzip(input, args) {
|
||||
// Deal with character encoding issues
|
||||
input = Utils.str_to_byte_array(Utils.byte_array_to_utf8(input));
|
||||
var gunzip = new Zlib.Gunzip(input);
|
||||
return Array.prototype.slice.call(gunzip.decompress());
|
||||
},
|
||||
|
||||
|
||||
input = Utils.str_to_byte_array(Utils.byte_array_to_utf8(input));
|
||||
const gunzip = new Zlib.Gunzip(input);
|
||||
return Array.prototype.slice.call(gunzip.decompress());
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
PKZIP_FILENAME: "file.txt",
|
||||
PKZIP_FILENAME: 'file.txt',
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
ZIP_COMPRESSION_METHOD_LOOKUP: {
|
||||
"Deflate" : Zlib.Zip.CompressionMethod.DEFLATE,
|
||||
"None (Store)" : Zlib.Zip.CompressionMethod.STORE
|
||||
},
|
||||
ZIP_COMPRESSION_METHOD_LOOKUP: {
|
||||
Deflate: Zlib.Zip.CompressionMethod.DEFLATE,
|
||||
'None (Store)': Zlib.Zip.CompressionMethod.STORE,
|
||||
},
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
ZIP_OS_LOOKUP: {
|
||||
"MSDOS" : Zlib.Zip.OperatingSystem.MSDOS,
|
||||
"Unix" : Zlib.Zip.OperatingSystem.UNIX,
|
||||
"Macintosh" : Zlib.Zip.OperatingSystem.MACINTOSH
|
||||
},
|
||||
|
||||
ZIP_OS_LOOKUP: {
|
||||
MSDOS: Zlib.Zip.OperatingSystem.MSDOS,
|
||||
Unix: Zlib.Zip.OperatingSystem.UNIX,
|
||||
Macintosh: Zlib.Zip.OperatingSystem.MACINTOSH,
|
||||
},
|
||||
|
||||
/**
|
||||
* Zip operation.
|
||||
*
|
||||
|
@ -266,32 +266,31 @@ var Compress = {
|
|||
* @param {Object[]} args
|
||||
* @returns {byte_array}
|
||||
*/
|
||||
run_pkzip: function(input, args) {
|
||||
var password = Utils.str_to_byte_array(args[2]),
|
||||
options = {
|
||||
filename: Utils.str_to_byte_array(args[0]),
|
||||
comment: Utils.str_to_byte_array(args[1]),
|
||||
compressionMethod: Compress.ZIP_COMPRESSION_METHOD_LOOKUP[args[3]],
|
||||
os: Compress.ZIP_OS_LOOKUP[args[4]],
|
||||
deflateOption: {
|
||||
compressionType: Compress.ZLIB_COMPRESSION_TYPE_LOOKUP[args[5]]
|
||||
},
|
||||
},
|
||||
zip = new Zlib.Zip();
|
||||
|
||||
if (password.length)
|
||||
zip.setPassword(password);
|
||||
zip.addFile(input, options);
|
||||
return Array.prototype.slice.call(zip.compress());
|
||||
},
|
||||
|
||||
|
||||
run_pkzip(input, args) {
|
||||
let password = Utils.str_to_byte_array(args[2]),
|
||||
options = {
|
||||
filename: Utils.str_to_byte_array(args[0]),
|
||||
comment: Utils.str_to_byte_array(args[1]),
|
||||
compressionMethod: Compress.ZIP_COMPRESSION_METHOD_LOOKUP[args[3]],
|
||||
os: Compress.ZIP_OS_LOOKUP[args[4]],
|
||||
deflateOption: {
|
||||
compressionType: Compress.ZLIB_COMPRESSION_TYPE_LOOKUP[args[5]],
|
||||
},
|
||||
},
|
||||
zip = new Zlib.Zip();
|
||||
|
||||
if (password.length) { zip.setPassword(password); }
|
||||
zip.addFile(input, options);
|
||||
return Array.prototype.slice.call(zip.compress());
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
PKUNZIP_VERIFY: false,
|
||||
|
||||
PKUNZIP_VERIFY: false,
|
||||
|
||||
/**
|
||||
* Unzip operation.
|
||||
*
|
||||
|
@ -299,36 +298,36 @@ var Compress = {
|
|||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
run_pkunzip: function(input, args) {
|
||||
var options = {
|
||||
password: Utils.str_to_byte_array(args[0]),
|
||||
verify: args[1]
|
||||
},
|
||||
file = "",
|
||||
unzip = new Zlib.Unzip(input, options),
|
||||
filenames = unzip.getFilenames(),
|
||||
output = "<div style='padding: 5px;'>" + filenames.length + " file(s) found</div>\n";
|
||||
|
||||
output += "<div class='panel-group' id='zip-accordion' role='tablist' aria-multiselectable='true'>";
|
||||
|
||||
window.uzip = unzip;
|
||||
for (var i = 0; i < filenames.length; i++) {
|
||||
file = Utils.byte_array_to_utf8(unzip.decompress(filenames[i]));
|
||||
output += "<div class='panel panel-default'>" +
|
||||
"<div class='panel-heading' role='tab' id='heading" + i + "'>" +
|
||||
"<h4 class='panel-title'>" +
|
||||
"<a class='collapsed' role='button' data-toggle='collapse' data-parent='#zip-accordion' href='#collapse" + i +
|
||||
"' aria-expanded='true' aria-controls='collapse" + i + "'>" +
|
||||
filenames[i] + "<span class='pull-right'>" + file.length.toLocaleString() + " bytes</span></a></h4></div>" +
|
||||
"<div id='collapse" + i + "' class='panel-collapse collapse' role='tabpanel' aria-labelledby='heading" + i + "'>" +
|
||||
"<div class='panel-body'>" +
|
||||
Utils.escape_html(file) + "</div></div></div>";
|
||||
}
|
||||
|
||||
return output + "</div>";
|
||||
},
|
||||
|
||||
|
||||
run_pkunzip(input, args) {
|
||||
let options = {
|
||||
password: Utils.str_to_byte_array(args[0]),
|
||||
verify: args[1],
|
||||
},
|
||||
file = '',
|
||||
unzip = new Zlib.Unzip(input, options),
|
||||
filenames = unzip.getFilenames(),
|
||||
output = `<div style='padding: 5px;'>${filenames.length} file(s) found</div>\n`;
|
||||
|
||||
output += "<div class='panel-group' id='zip-accordion' role='tablist' aria-multiselectable='true'>";
|
||||
|
||||
window.uzip = unzip;
|
||||
for (let i = 0; i < filenames.length; i++) {
|
||||
file = Utils.byte_array_to_utf8(unzip.decompress(filenames[i]));
|
||||
output += `${"<div class='panel panel-default'>" +
|
||||
"<div class='panel-heading' role='tab' id='heading"}${i}'>` +
|
||||
'<h4 class=\'panel-title\'>' +
|
||||
`<a class='collapsed' role='button' data-toggle='collapse' data-parent='#zip-accordion' href='#collapse${i
|
||||
}' aria-expanded='true' aria-controls='collapse${i}'>${
|
||||
filenames[i]}<span class='pull-right'>${file.length.toLocaleString()} bytes</span></a></h4></div>` +
|
||||
`<div id='collapse${i}' class='panel-collapse collapse' role='tabpanel' aria-labelledby='heading${i}'>` +
|
||||
`<div class='panel-body'>${
|
||||
Utils.escape_html(file)}</div></div></div>`;
|
||||
}
|
||||
|
||||
return `${output}</div>`;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Bzip2 Decompress operation.
|
||||
*
|
||||
|
@ -336,14 +335,14 @@ var Compress = {
|
|||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
run_bzip2_decompress: function(input, args) {
|
||||
var compressed = new Uint8Array(input),
|
||||
bzip2_reader,
|
||||
plain = "";
|
||||
|
||||
bzip2_reader = bzip2.array(compressed);
|
||||
plain = bzip2.simple(bzip2_reader);
|
||||
return plain;
|
||||
},
|
||||
|
||||
run_bzip2_decompress(input, args) {
|
||||
let compressed = new Uint8Array(input),
|
||||
bzip2_reader,
|
||||
plain = '';
|
||||
|
||||
bzip2_reader = bzip2.array(compressed);
|
||||
plain = bzip2.simple(bzip2_reader);
|
||||
return plain;
|
||||
},
|
||||
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue