Compare commits

..

18 Commits

Author SHA1 Message Date
n1474335
078849041f 7.6.3 2018-01-26 19:14:15 +00:00
n1474335
1c711f5e03 Updated dependencies 2018-01-26 19:14:05 +00:00
n1474335
614af0602a 7.6.2 2018-01-25 18:41:53 +00:00
n1474335
e55cfe0bc1 Fixed 'Syntax highlighter' operation. Using highlight.js instead of google-code-prettify. 2018-01-25 18:41:47 +00:00
n1474335
2b703b2b9b HTML outputs are now unescaped correctly when converted to a string 2018-01-25 16:25:19 +00:00
n1474335
170feaaff2 7.6.1 2018-01-25 14:03:19 +00:00
n1474335
870c2b6d8b Fixed deep copy bug with Fork/Register ingredient values. 2018-01-25 14:03:13 +00:00
n1474335
eee8b7db56 Fixed dispatchEvent call in recipe loading chain. 2018-01-25 13:46:06 +00:00
n1474335
3c669a075e 7.6.0 2018-01-25 13:45:05 +00:00
n1474335
f528930ad2 Added 'Sleep' operation. 2018-01-25 13:44:39 +00:00
n1474335
231322eddf 7.5.6 2018-01-24 16:54:42 +00:00
n1474335
8e6763c165 'Register' and 'Fork' now play well together. 2018-01-24 16:54:37 +00:00
n1474335
f091918575 7.5.5 2018-01-24 15:50:10 +00:00
n1474335
bb077c87b3 'Extract file paths' operation now handles 8.3 windows file paths correctly. 2018-01-24 15:50:05 +00:00
n1474335
fe8f8bc712 Setting a text value in the input now closes any open files. 2018-01-22 19:58:21 +00:00
n1474335
abe87830cd Operation tooltips now disappear if you hover over them while dragging an opertion. 2018-01-22 17:51:04 +00:00
n1474335
7490651a06 7.5.4 2018-01-22 17:10:02 +00:00
n1474335
6220128a74 Fixed delimiter options in StrUtils. Closes #238. 2018-01-22 17:09:58 +00:00
24 changed files with 1816 additions and 299 deletions

View File

@@ -186,7 +186,10 @@ module.exports = function (grunt) {
options: webpackConfig,
metaConf: {
target: "node",
entry: "./src/core/config/OperationConfig.js",
entry: [
"babel-polyfill",
"./src/core/config/OperationConfig.js"
],
output: {
filename: "MetaConfig.js",
path: __dirname + "/src/core/config/",
@@ -198,7 +201,10 @@ module.exports = function (grunt) {
},
metaConfDev: {
target: "node",
entry: "./src/core/config/OperationConfig.js",
entry: [
"babel-polyfill",
"./src/core/config/OperationConfig.js"
],
output: {
filename: "MetaConfig.js",
path: __dirname + "/src/core/config/",

1913
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "cyberchef",
"version": "7.5.3",
"version": "7.6.3",
"description": "The Cyber Swiss Army Knife for encryption, encoding, compression and data analysis.",
"author": "n1474335 <n1474335@gmail.com>",
"homepage": "https://gchq.github.io/CyberChef",
@@ -33,7 +33,7 @@
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-preset-env": "^1.6.1",
"css-loader": "^0.28.7",
"css-loader": "^0.28.9",
"exports-loader": "^0.6.4",
"extract-text-webpack-plugin": "^3.0.2",
"file-loader": "^1.1.6",
@@ -46,7 +46,7 @@
"grunt-eslint": "^20.1.0",
"grunt-exec": "~3.0.0",
"grunt-execute": "^0.2.2",
"grunt-jsdoc": "^2.2.0",
"grunt-jsdoc": "^2.2.1",
"grunt-webpack": "^3.0.2",
"html-webpack-plugin": "^2.30.1",
"imports-loader": "^0.7.1",
@@ -56,19 +56,19 @@
"less-loader": "^4.0.5",
"postcss-css-variables": "^0.8.0",
"postcss-import": "^11.0.0",
"postcss-loader": "^2.0.9",
"postcss-loader": "^2.0.10",
"style-loader": "^0.19.1",
"url-loader": "^0.6.2",
"val-loader": "^1.1.0",
"web-resource-inliner": "^4.2.0",
"web-resource-inliner": "^4.2.1",
"webpack": "^3.10.0",
"webpack-dev-server": "^2.9.7",
"webpack-dev-server": "^2.11.1",
"webpack-node-externals": "^1.6.0",
"worker-loader": "^1.1.0"
},
"dependencies": {
"babel-polyfill": "^6.26.0",
"bignumber.js": "^5.0.0",
"bignumber.js": "^6.0.0",
"bootstrap": "^3.3.7",
"bootstrap-colorpicker": "^2.5.2",
"bootstrap-switch": "^3.3.4",
@@ -80,15 +80,15 @@
"esprima": "^4.0.0",
"exif-parser": "^0.1.12",
"file-saver": "^1.3.3",
"google-code-prettify": "^1.0.5",
"jquery": "^3.2.1",
"highlight.js": "^9.12.0",
"jquery": "^3.3.1",
"js-crc": "^0.2.0",
"js-sha3": "^0.7.0",
"jsbn": "^1.1.0",
"jsonpath": "^1.0.0",
"jsrsasign": "8.0.4",
"lodash": "^4.17.4",
"loglevel": "^1.6.0",
"loglevel": "^1.6.1",
"loglevel-message-prefix": "^3.0.0",
"moment": "^2.20.1",
"moment-timezone": "^0.5.14",

View File

@@ -52,14 +52,25 @@ const FlowControl = {
output = "",
progress = 0;
state.forkOffset += state.progress + 1;
recipe.addOperations(subOpList);
// Take a deep(ish) copy of the ingredient values
const ingValues = subOpList.map(op => JSON.parse(JSON.stringify(op.getIngValues())));
// Run recipe over each tranche
for (i = 0; i < inputs.length; i++) {
log.debug(`Entering tranche ${i + 1} of ${inputs.length}`);
// Baseline ing values for each tranche so that registers are reset
subOpList.forEach((op, i) => {
op.setIngValues(JSON.parse(JSON.stringify(ingValues[i])));
});
const dish = new Dish(inputs[i], inputType);
try {
progress = await recipe.execute(dish, 0);
progress = await recipe.execute(dish, 0, state);
} catch (err) {
if (!ignoreErrors) {
throw err;
@@ -117,7 +128,7 @@ const FlowControl = {
if (!registers) return state;
if (ENVIRONMENT_IS_WORKER()) {
self.setRegisters(state.progress, state.numRegisters, registers.slice(1));
self.setRegisters(state.forkOffset + state.progress, state.numRegisters, registers.slice(1));
}
/**

View File

@@ -141,11 +141,14 @@ Recipe.prototype.lastOpIndex = function(startIndex) {
*
* @param {Dish} dish
* @param {number} [startFrom=0] - The index of the Operation to start executing from
* @param {number} [forkState={}] - If this is a forked recipe, the state of the recipe up to this point
* @returns {number} - The final progress through the recipe
*/
Recipe.prototype.execute = async function(dish, startFrom) {
startFrom = startFrom || 0;
let op, input, output, numJumps = 0, numRegisters = 0;
Recipe.prototype.execute = async function(dish, startFrom = 0, forkState = {}) {
let op, input, output,
numJumps = 0,
numRegisters = forkState.numRegisters || 0;
log.debug(`[*] Executing recipe of ${this.opList.length} operations, starting at ${startFrom}`);
for (let i = startFrom; i < this.opList.length; i++) {
@@ -171,7 +174,8 @@ Recipe.prototype.execute = async function(dish, startFrom) {
"dish": dish,
"opList": this.opList,
"numJumps": numJumps,
"numRegisters": numRegisters
"numRegisters": numRegisters,
"forkOffset": forkState.forkOffset || 0
};
state = await op.run(state);
@@ -256,4 +260,5 @@ Recipe.prototype.generateHighlightList = function() {
return highlights;
};
export default Recipe;

View File

@@ -201,6 +201,7 @@ const Categories = [
"Escape string",
"Unescape string",
"Pseudo-Random Number Generator",
"Sleep",
]
},
{
@@ -213,6 +214,7 @@ const Categories = [
"Windows Filetime to UNIX Timestamp",
"UNIX Timestamp to Windows Filetime",
"Extract dates",
"Sleep",
]
},
{

View File

@@ -2154,7 +2154,7 @@ const OperationConfig = {
{
name: "Invert condition",
type: "boolean",
value: SeqUtils.SORT_REVERSE
value: false
},
]
},
@@ -2441,8 +2441,21 @@ const OperationConfig = {
}
]
},
"Sleep": {
module: "Default",
description: "Sleep causes the recipe to wait for a specified number of milliseconds before continuing execution.",
inputType: "ArrayBuffer",
outputType: "ArrayBuffer",
args: [
{
name: "Time (ms)",
type: "number",
value: 1000
}
]
},
"Windows Filetime to UNIX Timestamp": {
module: "JSBN",
module: "Default",
description: "Converts a Windows Filetime value to a UNIX timestamp.<br><br>A Windows Filetime is a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 UTC.<br><br>A UNIX timestamp is a 32-bit value representing the number of seconds since January 1, 1970 UTC (the UNIX epoch).<br><br>This operation also supports UNIX timestamps in milliseconds, microseconds and nanoseconds.",
inputType: "string",
outputType: "string",
@@ -2460,7 +2473,7 @@ const OperationConfig = {
]
},
"UNIX Timestamp to Windows Filetime": {
module: "JSBN",
module: "Default",
description: "Converts a UNIX timestamp to a Windows Filetime value.<br><br>A Windows Filetime is a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 UTC.<br><br>A UNIX timestamp is a 32-bit value representing the number of seconds since January 1, 1970 UTC (the UNIX epoch).<br><br>This operation also supports UNIX timestamps in milliseconds, microseconds and nanoseconds.",
inputType: "string",
outputType: "string",
@@ -3449,15 +3462,10 @@ const OperationConfig = {
outputType: "html",
args: [
{
name: "Language/File extension",
name: "Language",
type: "option",
value: Code.LANGUAGES
},
{
name: "Display line numbers",
type: "boolean",
value: Code.LINE_NUMS
}
]
},
"TCP/IP Checksum": {

View File

@@ -11,7 +11,7 @@ import Code from "../../operations/Code.js";
* - xmldom
* - xpath
* - jpath
* - googlecodeprettify
* - highlight.js
*
* @author n1474335 [n1474335@gmail.com]
* @copyright Crown Copyright 2017

View File

@@ -10,6 +10,7 @@ import Convert from "../../operations/Convert.js";
import DateTime from "../../operations/DateTime.js";
import Endian from "../../operations/Endian.js";
import Entropy from "../../operations/Entropy.js";
import Filetime from "../../operations/Filetime.js";
import FileType from "../../operations/FileType.js";
import Hexdump from "../../operations/Hexdump.js";
import HTML from "../../operations/HTML.js";
@@ -39,6 +40,7 @@ import UUID from "../../operations/UUID.js";
* - Utils.js
* - otp
* - crypto
* - bignumber.js
*
* @author n1474335 [n1474335@gmail.com]
* @copyright Crown Copyright 2017
@@ -130,6 +132,7 @@ OpModules.Default = {
"Translate DateTime Format": DateTime.runTranslateFormat,
"From UNIX Timestamp": DateTime.runFromUnixTimestamp,
"To UNIX Timestamp": DateTime.runToUnixTimestamp,
"Sleep": DateTime.runSleep,
"Microsoft Script Decoder": MS.runDecodeScript,
"Entropy": Entropy.runEntropy,
"Frequency distribution": Entropy.runFreqDistrib,
@@ -156,6 +159,8 @@ OpModules.Default = {
"Mean": Arithmetic.runMean,
"Median": Arithmetic.runMedian,
"Standard Deviation": Arithmetic.runStdDev,
"Windows Filetime to UNIX Timestamp": Filetime.runFromFiletimeToUnix,
"UNIX Timestamp to Windows Filetime": Filetime.runToFiletimeFromUnix,
/*

View File

@@ -1,5 +1,4 @@
import IP from "../../operations/IP.js";
import Filetime from "../../operations/Filetime.js";
/**
@@ -21,8 +20,6 @@ OpModules.JSBN = {
"Parse IPv4 header": IP.runParseIPv4Header,
"Change IP format": IP.runChangeIpFormat,
"Group IP addresses": IP.runGroupIps,
"Windows Filetime to UNIX Timestamp": Filetime.runFromFiletimeToUnix,
"UNIX Timestamp to Windows Filetime": Filetime.runToFiletimeFromUnix,
};
export default OpModules;

View File

@@ -69,7 +69,7 @@ const BCD = {
runToBCD: function(input, args) {
if (input.isNaN())
return "Invalid input";
if (!input.floor().equals(input))
if (!input.integerValue(BigNumber.ROUND_DOWN).isEqualTo(input))
return "Fractional values are not supported by BCD";
const encoding = BCD.ENCODING_LOOKUP[args[0]],

View File

@@ -555,7 +555,7 @@ DES uses a key length of 8 bytes (64 bits).`;
return forge.util.bytesToHex(bytes);
case "Integer":
for (i = bytes.length - 1; i >= 0; i--) {
value = value.mul(256).plus(bytes.charCodeAt(i));
value = value.times(256).plus(bytes.charCodeAt(i));
}
return value.toFixed();
case "Byte array":

View File

@@ -1,12 +1,10 @@
import {camelCase, kebabCase, snakeCase} from "lodash";
import Utils from "../Utils.js";
import vkbeautify from "vkbeautify";
import {DOMParser} from "xmldom";
import xpath from "xpath";
import jpath from "jsonpath";
import nwmatcher from "nwmatcher";
import prettyPrintOne from "imports-loader?window=>global!exports-loader?prettyPrintOne!google-code-prettify/bin/prettify.min.js";
import hljs from "highlight.js";
/**
@@ -24,12 +22,7 @@ const Code = {
* @constant
* @default
*/
LANGUAGES: ["default-code", "default-markup", "bash", "bsh", "c", "cc", "coffee", "cpp", "cs", "csh", "cv", "cxx", "cyc", "htm", "html", "in.tag", "java", "javascript", "js", "json", "m", "mxml", "perl", "pl", "pm", "py", "python", "rb", "rc", "rs", "ruby", "rust", "sh", "uq.val", "xhtml", "xml", "xsl"],
/**
* @constant
* @default
*/
LINE_NUMS: false,
LANGUAGES: ["auto detect"].concat(hljs.listLanguages()),
/**
* Syntax highlighter operation.
@@ -39,9 +32,13 @@ const Code = {
* @returns {html}
*/
runSyntaxHighlight: function(input, args) {
let language = args[0],
lineNums = args[1];
return "<code class='prettyprint'>" + prettyPrintOne(Utils.escapeHtml(input), language, lineNums) + "</code>";
const language = args[0];
if (language === "auto detect") {
return hljs.highlightAuto(input).value;
}
return hljs.highlight(language, input, true).value;
},

View File

@@ -68,7 +68,7 @@ const Convert = {
let inputUnits = args[0],
outputUnits = args[1];
input = input.mul(Convert.DISTANCE_FACTOR[inputUnits]);
input = input.times(Convert.DISTANCE_FACTOR[inputUnits]);
return input.div(Convert.DISTANCE_FACTOR[outputUnits]);
},
@@ -148,7 +148,7 @@ const Convert = {
let inputUnits = args[0],
outputUnits = args[1];
input = input.mul(Convert.DATA_FACTOR[inputUnits]);
input = input.times(Convert.DATA_FACTOR[inputUnits]);
return input.div(Convert.DATA_FACTOR[outputUnits]);
},
@@ -228,7 +228,7 @@ const Convert = {
let inputUnits = args[0],
outputUnits = args[1];
input = input.mul(Convert.AREA_FACTOR[inputUnits]);
input = input.times(Convert.AREA_FACTOR[inputUnits]);
return input.div(Convert.AREA_FACTOR[outputUnits]);
},
@@ -339,7 +339,7 @@ const Convert = {
let inputUnits = args[0],
outputUnits = args[1];
input = input.mul(Convert.MASS_FACTOR[inputUnits]);
input = input.times(Convert.MASS_FACTOR[inputUnits]);
return input.div(Convert.MASS_FACTOR[outputUnits]);
},
@@ -404,7 +404,7 @@ const Convert = {
let inputUnits = args[0],
outputUnits = args[1];
input = input.mul(Convert.SPEED_FACTOR[inputUnits]);
input = input.times(Convert.SPEED_FACTOR[inputUnits]);
return input.div(Convert.SPEED_FACTOR[outputUnits]);
},

View File

@@ -189,6 +189,20 @@ const DateTime = {
},
/**
* Sleep operation.
*
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {ArrayBuffer}
*/
runSleep: async function(input, args) {
const ms = args[0];
await new Promise(r => setTimeout(r, ms));
return input;
},
/**
* @constant
*/

View File

@@ -287,7 +287,7 @@ const Extract = {
includeUnixPath = args[1],
displayTotal = args[2],
winDrive = "[A-Z]:\\\\",
winName = "[A-Z\\d][A-Z\\d\\- '_\\(\\)]{0,61}",
winName = "[A-Z\\d][A-Z\\d\\- '_\\(\\)~]{0,61}",
winExt = "[A-Z\\d]{1,6}",
winPath = winDrive + "(?:" + winName + "\\\\?)*" + winName +
"(?:\\." + winExt + ")?",

View File

@@ -1,4 +1,4 @@
import {BigInteger} from "jsbn";
import BigNumber from "bignumber.js";
/**
* Windows Filetime operations.
@@ -35,27 +35,29 @@ const Filetime = {
let units = args[0],
format = args[1];
if (!input) return "";
if (format === "Hex") {
input = new BigInteger(input, 16);
input = new BigNumber(input, 16);
} else {
input = new BigInteger(input);
input = new BigNumber(input);
}
input = input.subtract(new BigInteger("116444736000000000"));
input = input.minus(new BigNumber("116444736000000000"));
if (units === "Seconds (s)"){
input = input.divide(new BigInteger("10000000"));
input = input.dividedBy(new BigNumber("10000000"));
} else if (units === "Milliseconds (ms)") {
input = input.divide(new BigInteger("10000"));
input = input.dividedBy(new BigNumber("10000"));
} else if (units === "Microseconds (μs)") {
input = input.divide(new BigInteger("10"));
input = input.dividedBy(new BigNumber("10"));
} else if (units === "Nanoseconds (ns)") {
input = input.multiply(new BigInteger("100"));
input = input.multipliedBy(new BigNumber("100"));
} else {
throw "Unrecognised unit";
}
return input.toString();
return input.toFixed();
},
@@ -71,26 +73,28 @@ const Filetime = {
let units = args[0],
format = args[1];
input = new BigInteger(input);
if (!input) return "";
input = new BigNumber(input);
if (units === "Seconds (s)"){
input = input.multiply(new BigInteger("10000000"));
input = input.multipliedBy(new BigNumber("10000000"));
} else if (units === "Milliseconds (ms)") {
input = input.multiply(new BigInteger("10000"));
input = input.multipliedBy(new BigNumber("10000"));
} else if (units === "Microseconds (μs)") {
input = input.multiply(new BigInteger("10"));
input = input.multiplyiedBy(new BigNumber("10"));
} else if (units === "Nanoseconds (ns)") {
input = input.divide(new BigInteger("100"));
input = input.dividedBy(new BigNumber("100"));
} else {
throw "Unrecognised unit";
}
input = input.add(new BigInteger("116444736000000000"));
input = input.plus(new BigNumber("116444736000000000"));
if (format === "Hex"){
return input.toString(16);
} else {
return input.toString();
return input.toFixed();
}
},

View File

@@ -44,7 +44,7 @@ const Regex = {
},
{
name: "Windows file path",
value: "([A-Za-z]):\\\\((?:[A-Za-z\\d][A-Za-z\\d\\- \\x27_\\(\\)]{0,61}\\\\?)*[A-Za-z\\d][A-Za-z\\d\\- \\x27_\\(\\)]{0,61})(\\.[A-Za-z\\d]{1,6})?"
value: "([A-Za-z]):\\\\((?:[A-Za-z\\d][A-Za-z\\d\\- \\x27_\\(\\)~]{0,61}\\\\?)*[A-Za-z\\d][A-Za-z\\d\\- \\x27_\\(\\)]{0,61})(\\.[A-Za-z\\d]{1,6})?"
},
{
name: "UNIX file path",

View File

@@ -104,6 +104,12 @@ const StrUtils = {
},
/**
* @constant
* @default
*/
DELIMITER_OPTIONS: ["Line feed", "CRLF", "Space", "Comma", "Semi-colon", "Colon", "Nothing (separate chars)"],
/**
* Filter operation.
*

View File

@@ -488,7 +488,6 @@ App.prototype.setRecipeConfig = function(recipeConfig) {
// Unpause auto bake
this.autoBakePause = false;
window.disptchEent(this.manager.statechange);
};

View File

@@ -64,6 +64,7 @@ InputWaiter.prototype.set = function(input) {
this.setInputInfo(input.size, null);
} else {
inputText.value = input;
this.closeFile();
window.dispatchEvent(this.manager.statechange);
const lines = input.length < (this.app.options.ioDisplayThreshold * 1024) ?
input.count("\n") + 1 : null;

View File

@@ -167,7 +167,8 @@ OperationsWaiter.prototype.opListCreate = function(e) {
OperationsWaiter.prototype.enableOpsListPopovers = function(el) {
$(el).find("[data-toggle=popover]").addBack("[data-toggle=popover]")
.popover({trigger: "manual"})
.on("mouseenter", function() {
.on("mouseenter", function(e) {
if (e.buttons > 0) return; // Mouse button held down - likely dragging an opertion
const _this = this;
$(this).popover("show");
$(".popover").on("mouseleave", function () {
@@ -178,7 +179,7 @@ OperationsWaiter.prototype.enableOpsListPopovers = function(el) {
setTimeout(function() {
// Determine if the popover associated with this element is being hovered over
if ($(_this).data("bs.popover") &&
!$(_this).data("bs.popover").$tip.is(":hover")) {
($(_this).data("bs.popover").$tip && !$(_this).data("bs.popover").$tip.is(":hover"))) {
$(_this).popover("hide");
}
}, 50);

View File

@@ -64,7 +64,7 @@ OutputWaiter.prototype.set = function(data, type, duration, preserveBuffer) {
outputText.value = "";
outputHtml.innerHTML = data;
this.dishStr = Utils.stripHtmlTags(data, true);
this.dishStr = Utils.unescapeHtml(Utils.stripHtmlTags(data, true));
length = data.length;
lines = this.dishStr.count("\n") + 1;

View File

@@ -7,7 +7,7 @@
*/
/* Libraries */
import "google-code-prettify/src/prettify.css";
import "highlight.js/styles/vs.css";
/* Frameworks */
import "./vendors/bootstrap.less";