Sync up to GCHQ master HEAD

Fix syntax issues in multiple files
This commit is contained in:
Windham Wong 2017-10-18 13:22:32 +01:00
parent 6c0cdc8f2a
commit a74d97f2a4
5 changed files with 76 additions and 51 deletions

26
prod_image_list.txt Normal file
View file

@ -0,0 +1,26 @@
./src/web/static/images/bug-16x16.png
./src/web/static/images/clean-16x16.png
./src/web/static/images/cook_male-32x32.png
./src/web/static/images/cyberchef-128x128.png
./src/web/static/images/download-24x24.png
./src/web/static/images/erase-16x16.png
./src/web/static/images/favourite-16x16.png
./src/web/static/images/favourite-24x24.png
./src/web/static/images/fork_me.png
./src/web/static/images/gitter-badge.svg
./src/web/static/images/help-16x16.png
./src/web/static/images/help-22x22.png
./src/web/static/images/layout-16x16.png
./src/web/static/images/maximise-16x16.png
./src/web/static/images/open_yellow-16x16.png
./src/web/static/images/open_yellow-24x24.png
./src/web/static/images/recycle-16x16.png
./src/web/static/images/save-22x22.png
./src/web/static/images/save_as-16x16.png
./src/web/static/images/settings-22x22.png
./src/web/static/images/speech-16x16.png
./src/web/static/images/step-16x16.png
./src/web/static/images/switch-16x16.png
./src/web/static/images/thumb_down-16x16.png
./src/web/static/images/thumb_up-16x16.png
./src/web/static/images/undo-16x16.png

View file

@ -28,8 +28,8 @@ const Categories = [
"To Hexdump", "To Hexdump",
"From Hexdump", "From Hexdump",
"From nTcpdump", "From nTcpdump",
"From 0x[Hex]", "From 0x[Hex]",
"From Char(Hex)", "From Char(Hex)",
"To Hex", "To Hex",
"From Hex", "From Hex",
"To Charcode", "To Charcode",

View file

@ -54,44 +54,44 @@ const ByteRepr = {
}, },
/** /**
* From 0xHex operation. * From 0xHex operation.
* *
* @param {string} input (Starting with 0x only in the raw input) * @param {string} input (Starting with 0x only in the raw input)
* @param {Object[]} args * @param {Object[]} args
* @returns {byteArray} * @returns {byteArray}
*/ */
runFrom0xHex: function(input, args) { runFrom0xHex: function(input, args) {
var data = input.replace(/0x([0-9a-f]{2,})/ig, let data = input.replace(/0x([0-9a-f]{2,})/ig,
function(match, p1) { function(match, p1) {
if (p1) { if (p1) {
return Utils.byteArrayToChars(Utils.fromHex(p1)); return Utils.byteArrayToChars(Utils.fromHex(p1));
}; }
}); });
return data; return data;
}, },
/** /**
* From char(hex) operation. * From char(hex) operation.
* *
* @param {string} input (Starting with chr or char only in the raw input) * @param {string} input (Starting with chr or char only in the raw input)
* @param {Object[]} args * @param {Object[]} args
* @returns {byteArray} * @returns {byteArray}
*/ */
runFromCharHex: function(input, args) { runFromCharHex: function(input, args) {
var re = /cha?r\((((\d{1,3})(,\s?)?)+)\)/ig; let re = /cha?r\((((\d{1,3})(,\s?)?)+)\)/ig;
var inner_re = /(\d{1,3}),?/g let innerRe = /(\d{1,3}),?/g;
var data = input.replace(re, let data = input.replace(re,
function(match, p1) { function(match, p1) {
if (p1) { if (p1) {
var result = "", inner_match; let result = "", innerMatch;
while ((inner_match = inner_re.exec(p1)) != null) { while ((innerMatch = innerRe.exec(p1)) != null) {
result += Utils.byteArrayToChars([parseInt(inner_match[1])]); result += Utils.byteArrayToChars([parseInt(innerMatch[1], 10)]);
} }
return result; return result;
} }
}); });
return data; return data;
}, },

View file

@ -267,7 +267,9 @@ const Compress = {
let regexStr = /1f8b080[0-8][0-9a-f]{12}/; let regexStr = /1f8b080[0-8][0-9a-f]{12}/;
let gzipPos = input.search(regexStr); let gzipPos = input.search(regexStr);
if (gzipPos == -1) {return Utils.hexToByteArray(input);} if (gzipPos === -1) {
return Utils.hexToByteArray(input);
}
let plainData = input.substr(0, gzipPos); let plainData = input.substr(0, gzipPos);
let gzipData = input.substr(gzipPos); let gzipData = input.substr(gzipPos);

View file

@ -37,19 +37,19 @@ const nTcpdump = {
* @returns {string} * @returns {string}
*/ */
runTo: function(input, args) { runTo: function(input, args) {
var length = args[0] || nTcpdump.WIDTH; let length = args[0] || nTcpdump.WIDTH;
var upperCase = args[1]; let upperCase = args[1];
var includeFinalLength = args[2]; let includeFinalLength = args[2];
var output = "", padding = 2; let output = "", padding = 2;
for (var i = 0; i < input.length; i += length) { for (let i = 0; i < input.length; i += length) {
var buff = input.slice(i, i+length); let buff = input.slice(i, i+length);
var hexa = ""; let hexa = "";
for (var j = 0; j < buff.length; j++) { for (let j = 0; j < buff.length; j++) {
hexa += Utils.hex(buff[j], padding) + " "; hexa += Utils.hex(buff[j], padding) + " ";
} }
var lineNo = Utils.hex(i, 8); let lineNo = Utils.hex(i, 8);
if (upperCase) { if (upperCase) {
hexa = hexa.toUpperCase(); hexa = hexa.toUpperCase();
@ -77,21 +77,18 @@ const nTcpdump = {
* @returns {byteArray} * @returns {byteArray}
*/ */
runFrom: function(input, args) { runFrom: function(input, args) {
var output = [], let output = [];
regex = /^\s*(?:0x[\dA-F]{4}:?)?\s*((?:[\dA-F]{4}\s?){1,8})/igm, let regex = /^\s*(?:0x[\dA-F]{4}:?)?\s*((?:[\dA-F]{4}\s?){1,8})/igm;
regex_header = /^\s*(?:0x0000:){1}\s*((?:[\dA-F]{4}\s?){6})/igm, let block = regex.exec(input);
block, line; while (block) {
let line = Utils.fromHex(block[1].replace(/-/g, " "));
while ((block = regex.exec(input))) { for (let i = 0; i < line.length; i++) {
// block[1].replace(regex_header, "0x0000:");
line = Utils.fromHex(block[1].replace(/-/g, " "));
for (var i = 0; i < line.length; i++) {
output.push(line[i]); output.push(line[i]);
} }
} }
// Is this a CyberChef hexdump or is it from a different tool? // Is this a CyberChef hexdump or is it from a different tool?
var width = input.indexOf("\n"); let width = input.indexOf("\n");
var w = (width - 13) / 4; let w = (width - 13) / 4;
// w should be the specified width of the hexdump and therefore a round number // w should be the specified width of the hexdump and therefore a round number
if (Math.floor(w) !== w || input.indexOf("\r") !== -1 || output.indexOf(13) !== -1) { if (Math.floor(w) !== w || input.indexOf("\r") !== -1 || output.indexOf(13) !== -1) {
app.options.attemptHighlight = false; app.options.attemptHighlight = false;
@ -111,7 +108,7 @@ const nTcpdump = {
*/ */
highlightTo: function(pos, args) { highlightTo: function(pos, args) {
// Calculate overall selection // Calculate overall selection
var w = args[0] || 16, let w = args[0] || 16,
width = 14 + (w*4), width = 14 + (w*4),
line = Math.floor(pos[0].start / w), line = Math.floor(pos[0].start / w),
offset = pos[0].start % w, offset = pos[0].start % w,
@ -129,8 +126,8 @@ const nTcpdump = {
pos[0].end = line*width + 10 + offset*3 - 1; pos[0].end = line*width + 10 + offset*3 - 1;
// Set up multiple selections for bytes // Set up multiple selections for bytes
var startLineNum = Math.floor(pos[0].start / width); let startLineNum = Math.floor(pos[0].start / width);
var endLineNum = Math.floor(pos[0].end / width); let endLineNum = Math.floor(pos[0].end / width);
if (startLineNum === endLineNum) { if (startLineNum === endLineNum) {
pos.push(pos[0]); pos.push(pos[0]);
@ -148,10 +145,10 @@ const nTcpdump = {
} }
// Set up multiple selections for ASCII // Set up multiple selections for ASCII
var len = pos.length, lineNum = 0; let len = pos.length, lineNum = 0;
start = 0; start = 0;
end = 0; end = 0;
for (var i = 1; i < len; i++) { for (let i = 1; i < len; i++) {
lineNum = Math.floor(pos[i].start / width); lineNum = Math.floor(pos[i].start / width);
start = (((pos[i].start - (lineNum * width)) - 10) / 3) + (width - w -2) + (lineNum * width); start = (((pos[i].start - (lineNum * width)) - 10) / 3) + (width - w -2) + (lineNum * width);
end = (((pos[i].end + 1 - (lineNum * width)) - 10) / 3) + (width - w -2) + (lineNum * width); end = (((pos[i].end + 1 - (lineNum * width)) - 10) / 3) + (width - w -2) + (lineNum * width);
@ -171,11 +168,11 @@ const nTcpdump = {
* @returns {Object[]} pos * @returns {Object[]} pos
*/ */
highlightFrom: function(pos, args) { highlightFrom: function(pos, args) {
var w = args[0] || 16; let w = args[0] || 16;
var width = 14 + (w*4); let width = 14 + (w*4);
var line = Math.floor(pos[0].start / width); let line = Math.floor(pos[0].start / width);
var offset = pos[0].start % width; let offset = pos[0].start % width;
if (offset < 10) { // In line number section if (offset < 10) { // In line number section
pos[0].start = line*w; pos[0].start = line*w;