mirror of
https://github.com/gchq/CyberChef.git
synced 2025-05-11 16:51:31 -04:00
Merging with upstream master
This commit is contained in:
commit
b5078599dc
11 changed files with 102 additions and 67 deletions
|
@ -151,6 +151,10 @@ var FlowControl = {
|
|||
jumpNum = ings[0],
|
||||
maxJumps = ings[1];
|
||||
|
||||
if (jumpNum < 0) {
|
||||
jumpNum--;
|
||||
}
|
||||
|
||||
if (state.numJumps >= maxJumps) {
|
||||
return state;
|
||||
}
|
||||
|
@ -178,6 +182,10 @@ var FlowControl = {
|
|||
jumpNum = ings[1],
|
||||
maxJumps = ings[2];
|
||||
|
||||
if (jumpNum < 0) {
|
||||
jumpNum--;
|
||||
}
|
||||
|
||||
if (state.numJumps >= maxJumps) {
|
||||
return state;
|
||||
}
|
||||
|
|
|
@ -1028,20 +1028,37 @@ var Utils = {
|
|||
};
|
||||
|
||||
var formatFile = function(file, i) {
|
||||
var blob = new Blob(
|
||||
[new Uint8Array(file.bytes)],
|
||||
{type: "octet/stream"}
|
||||
);
|
||||
var blobUrl = URL.createObjectURL(blob);
|
||||
|
||||
var downloadAnchorElem = "<a href='" + blobUrl + "' " +
|
||||
"title='Download " + Utils.escapeHtml(file.fileName) + "' " +
|
||||
"download='" + Utils.escapeHtml(file.fileName) + "'>\u21B4</a>";
|
||||
|
||||
var expandFileContentsElem = "<a href='#collapse" + i + "' " +
|
||||
"class='collapsed' " +
|
||||
"data-toggle='collapse' " +
|
||||
"aria-expanded='true' " +
|
||||
"aria-controls='collapse" + i + "' " +
|
||||
"title=\"Show/hide contents of '" + Utils.escapeHtml(file.fileName) + "'\">🔍</a>";
|
||||
|
||||
var html = "<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' " +
|
||||
"href='#collapse" + i + "' " +
|
||||
"aria-expanded='true' aria-controls='collapse" + i +"'>" +
|
||||
file.fileName +
|
||||
"<div>" +
|
||||
Utils.escapeHtml(file.fileName) +
|
||||
" " + expandFileContentsElem +
|
||||
" " + downloadAnchorElem +
|
||||
"<span class='pull-right'>" +
|
||||
// These are for formatting when stripping HTML
|
||||
"<span style='display: none'>\n</span>" +
|
||||
file.size.toLocaleString() + " bytes" +
|
||||
"<span style='display: none'>\n</span>" +
|
||||
"</span>" +
|
||||
"</a>" +
|
||||
"</div>" +
|
||||
"</h4>" +
|
||||
"</div>" +
|
||||
"<div id='collapse" + i + "' class='panel-collapse collapse' " +
|
||||
|
|
|
@ -31,6 +31,7 @@ var Base64 = {
|
|||
{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"},
|
||||
],
|
||||
|
||||
/**
|
||||
|
|
|
@ -309,9 +309,8 @@ var Compress = {
|
|||
files = [];
|
||||
|
||||
filenames.forEach(function(fileName) {
|
||||
var contents = unzip.decompress(fileName);
|
||||
|
||||
contents = Utils.byteArrayToUtf8(contents);
|
||||
var bytes = unzip.decompress(fileName);
|
||||
var contents = Utils.byteArrayToUtf8(bytes);
|
||||
|
||||
var file = {
|
||||
fileName: fileName,
|
||||
|
@ -320,6 +319,7 @@ var Compress = {
|
|||
|
||||
var isDir = contents.length === 0 && fileName.endsWith("/");
|
||||
if (!isDir) {
|
||||
file.bytes = bytes;
|
||||
file.contents = contents;
|
||||
}
|
||||
|
||||
|
@ -477,6 +477,13 @@ var Compress = {
|
|||
this.position = 0;
|
||||
};
|
||||
|
||||
Stream.prototype.getBytes = function(bytesToGet) {
|
||||
var newPosition = this.position + bytesToGet;
|
||||
var bytes = this.bytes.slice(this.position, newPosition);
|
||||
this.position = newPosition;
|
||||
return bytes;
|
||||
};
|
||||
|
||||
Stream.prototype.readString = function(numBytes) {
|
||||
var result = "";
|
||||
for (var i = this.position; i < this.position + numBytes; i++) {
|
||||
|
@ -535,11 +542,9 @@ var Compress = {
|
|||
endPosition += 512 - (file.size % 512);
|
||||
}
|
||||
|
||||
file.contents = "";
|
||||
|
||||
while (stream.position < endPosition) {
|
||||
file.contents += stream.readString(512);
|
||||
}
|
||||
file.bytes = stream.getBytes(file.size);
|
||||
file.contents = Utils.byteArrayToUtf8(file.bytes);
|
||||
stream.position = endPosition;
|
||||
} else if (file.type === "5") {
|
||||
// Directory
|
||||
files.push(file);
|
||||
|
|
|
@ -19,8 +19,8 @@ var HTTP = {
|
|||
* @returns {string}
|
||||
*/
|
||||
runStripHeaders: function(input, args) {
|
||||
var headerEnd = input.indexOf("\r\n\r\n") +
|
||||
(headerEnd < 0) ? input.indexOf("\n\n") + 2 : headerEnd + 4;
|
||||
var headerEnd = input.indexOf("\r\n\r\n");
|
||||
headerEnd = (headerEnd < 0) ? input.indexOf("\n\n") + 2 : headerEnd + 4;
|
||||
|
||||
return (headerEnd < 2) ? input : input.slice(headerEnd, input.length);
|
||||
},
|
||||
|
|
|
@ -209,6 +209,22 @@ var IP = {
|
|||
output += "\nThis is a reserved multicast address.";
|
||||
output += "\nMulticast addresses range: ff00::/8";
|
||||
}
|
||||
|
||||
|
||||
// Detect possible EUI-64 addresses
|
||||
if ((ipv6[5] & 0xff === 0xff) && (ipv6[6] >>> 8 === 0xfe)) {
|
||||
output += "\n\nThis IPv6 address contains a modified EUI-64 address, identified by the presence of FF:FE in the 12th and 13th octets.";
|
||||
|
||||
var intIdent = Utils.hex(ipv6[4] >>> 8) + ":" + Utils.hex(ipv6[4] & 0xff) + ":" +
|
||||
Utils.hex(ipv6[5] >>> 8) + ":" + Utils.hex(ipv6[5] & 0xff) + ":" +
|
||||
Utils.hex(ipv6[6] >>> 8) + ":" + Utils.hex(ipv6[6] & 0xff) + ":" +
|
||||
Utils.hex(ipv6[7] >>> 8) + ":" + Utils.hex(ipv6[7] & 0xff),
|
||||
mac = Utils.hex((ipv6[4] >>> 8) ^ 2) + ":" + Utils.hex(ipv6[4] & 0xff) + ":" +
|
||||
Utils.hex(ipv6[5] >>> 8) + ":" + Utils.hex(ipv6[6] & 0xff) + ":" +
|
||||
Utils.hex(ipv6[7] >>> 8) + ":" + Utils.hex(ipv6[7] & 0xff);
|
||||
output += "\nInterface identifier: " + intIdent +
|
||||
"\nMAC address: " + mac;
|
||||
}
|
||||
} else {
|
||||
return "Invalid IPv6 address";
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue