Merge branch 'master' into feature/remove-letter-accents

This commit is contained in:
Klaxon 2018-10-11 21:28:04 +10:00
commit f1ffe19ec8
12 changed files with 2135 additions and 1629 deletions

View File

@ -1,6 +1,6 @@
{
"presets": [
["env", {
["@babel/preset-env", {
"targets": {
"chrome": 40,
"firefox": 35,
@ -8,7 +8,7 @@
"node": "6.5"
},
"modules": false,
"useBuiltIns": true
"useBuiltIns": "usage"
}]
],
"plugins": [

View File

@ -1,6 +1,8 @@
# Changelog
All notable changes to CyberChef will be documented in this file.
### [8.8.0] - 2018-10-10
- 'Parse TLV' operation added [@GCHQ77703] | [#351]
### [8.7.0] - 2018-08-31
- 'JWT Sign', 'JWT Verify' and 'JWT Decode' operations added [@GCHQ77703] | [#348]
@ -51,6 +53,7 @@ All notable changes to CyberChef will be documented in this file.
- Initial open source commit [@n1474335] | [b1d73a72](https://github.com/gchq/CyberChef/commit/b1d73a725dc7ab9fb7eb789296efd2b7e4b08306)
[8.8.0]: https://github.com/gchq/CyberChef/releases/tag/v8.8.0
[8.7.0]: https://github.com/gchq/CyberChef/releases/tag/v8.7.0
[8.6.0]: https://github.com/gchq/CyberChef/releases/tag/v8.6.0
[8.5.0]: https://github.com/gchq/CyberChef/releases/tag/v8.5.0
@ -91,3 +94,4 @@ All notable changes to CyberChef will be documented in this file.
[#340]: https://github.com/gchq/CyberChef/pull/340
[#344]: https://github.com/gchq/CyberChef/pull/344
[#348]: https://github.com/gchq/CyberChef/pull/348
[#351]: https://github.com/gchq/CyberChef/pull/351

View File

@ -280,7 +280,11 @@ module.exports = function (grunt) {
chunks: false,
modules: false,
entrypoints: false,
warningsFilter: [/source-map/, /dependency is an expression/],
warningsFilter: [
/source-map/,
/dependency is an expression/,
/export 'default'/
],
}
},
start: {

3476
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "cyberchef",
"version": "8.7.0",
"version": "8.8.2",
"description": "The Cyber Swiss Army Knife for encryption, encoding, compression and data analysis.",
"author": "n1474335 <n1474335@gmail.com>",
"homepage": "https://gchq.github.io/CyberChef",
@ -30,45 +30,45 @@
"main": "build/node/CyberChef.js",
"bugs": "https://github.com/gchq/CyberChef/issues",
"devDependencies": {
"autoprefixer": "^9.1.0",
"babel-core": "^6.26.3",
"babel-loader": "^7.1.5",
"babel-preset-env": "^1.7.0",
"@babel/core": "^7.1.2",
"@babel/preset-env": "^7.1.0",
"autoprefixer": "^9.1.5",
"babel-loader": "^8.0.4",
"bootstrap": "^4.1.3",
"colors": "^1.3.1",
"colors": "^1.3.2",
"css-loader": "^1.0.0",
"eslint": "^5.3.0",
"eslint": "^5.6.1",
"exports-loader": "^0.7.0",
"extract-text-webpack-plugin": "^4.0.0-alpha0",
"file-loader": "^1.1.11",
"file-loader": "^2.0.0",
"grunt": "^1.0.3",
"grunt-accessibility": "~6.0.0",
"grunt-chmod": "~1.1.1",
"grunt-concurrent": "^2.3.1",
"grunt-contrib-clean": "~1.1.0",
"grunt-contrib-clean": "~2.0.0",
"grunt-contrib-copy": "~1.0.0",
"grunt-contrib-watch": "^1.1.0",
"grunt-eslint": "^21.0.0",
"grunt-exec": "~3.0.0",
"grunt-jsdoc": "^2.2.1",
"grunt-webpack": "^3.1.2",
"grunt-jsdoc": "^2.3.0",
"grunt-webpack": "^3.1.3",
"html-webpack-plugin": "^3.2.0",
"imports-loader": "^0.8.0",
"ink-docstrap": "^1.3.2",
"js-to-mjs": "^0.2.0",
"jsdoc-babel": "^0.4.0",
"node-sass": "^4.9.2",
"postcss-css-variables": "^0.9.0",
"jsdoc-babel": "^0.5.0",
"node-sass": "^4.9.3",
"postcss-css-variables": "^0.11.0",
"postcss-import": "^12.0.0",
"postcss-loader": "^2.1.6",
"postcss-loader": "^3.0.0",
"prompt": "^1.0.0",
"sass-loader": "^7.1.0",
"sitemap": "^1.13.0",
"style-loader": "^0.21.0",
"url-loader": "^1.0.1",
"sitemap": "^2.0.1",
"style-loader": "^0.23.1",
"url-loader": "^1.1.2",
"web-resource-inliner": "^4.2.1",
"webpack": "^4.16.4",
"webpack-dev-server": "^3.1.5",
"webpack": "^4.20.2",
"webpack-dev-server": "^3.1.9",
"webpack-node-externals": "^1.7.2",
"worker-loader": "^2.0.0"
},
@ -91,24 +91,24 @@
"esmangle": "^1.0.1",
"esprima": "^4.0.1",
"exif-parser": "^0.1.12",
"file-saver": "^1.3.8",
"file-saver": "^2.0.0-rc.3",
"highlight.js": "^9.12.0",
"jquery": "^3.3.1",
"js-crc": "^0.2.0",
"js-sha3": "^0.7.0",
"js-sha3": "^0.8.0",
"jsbn": "^1.1.0",
"jsesc": "^2.5.1",
"jsonpath": "^1.0.0",
"jsonwebtoken": "^8.3.0",
"jsrsasign": "8.0.12",
"kbpgp": "^2.0.77",
"lodash": "^4.17.10",
"kbpgp": "^2.0.80",
"lodash": "^4.17.11",
"loglevel": "^1.6.1",
"loglevel-message-prefix": "^3.0.0",
"moment": "^2.22.2",
"moment-timezone": "^0.5.21",
"ngeohash": "^0.6.0",
"node-forge": "^0.7.5",
"node-forge": "^0.7.6",
"node-md6": "^0.1.0",
"notepack.io": "^2.1.3",
"nwmatcher": "^1.4.4",
@ -117,7 +117,7 @@
"scryptsy": "^2.0.0",
"snackbarjs": "^1.1.0",
"sortablejs": "^1.7.0",
"split.js": "^1.3.5",
"split.js": "^1.5.2",
"ssdeep.js": "0.0.2",
"ua-parser-js": "^0.7.18",
"utf8": "^3.0.0",

View File

@ -555,8 +555,6 @@ class Utils {
if (renderNext) {
cell += b;
renderNext = false;
} else if (b === "\\") {
renderNext = true;
} else if (b === "\"" && !inString) {
inString = true;
} else if (b === "\"" && inString) {

View File

@ -53,7 +53,8 @@
"To MessagePack",
"From MessagePack",
"To Braille",
"From Braille"
"From Braille",
"Parse TLV"
]
},
{

View File

@ -0,0 +1,78 @@
/**
* Parser for Type-length-value data.
*
* @author gchq77703 []
* @author n1474335 [n1474335@gmail.com]
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
const defaults = {
location: 0,
bytesInLength: 1,
basicEncodingRules: false
};
/**
* TLVParser library
*/
export default class TLVParser {
/**
* TLVParser constructor
*
* @param {byteArray} input
* @param {Object} options
*/
constructor(input, options) {
this.input = input;
Object.assign(this, defaults, options);
}
/**
* @returns {number}
*/
getLength() {
if (this.basicEncodingRules) {
const bit = this.input[this.location];
if (bit & 0x80) {
this.bytesInLength = bit & ~0x80;
} else {
this.location++;
return bit & ~0x80;
}
}
let length = 0;
for (let i = 0; i < this.bytesInLength; i++) {
length += this.input[this.location] * Math.pow(Math.pow(2, 8), i);
this.location++;
}
return length;
}
/**
* @param {number} length
* @returns {number[]}
*/
getValue(length) {
const value = [];
for (let i = 0; i < length; i++) {
if (this.location > this.input.length) return value;
value.push(this.input[this.location]);
this.location++;
}
return value;
}
/**
* @returns {boolean}
*/
atEnd() {
return this.input.length <= this.location;
}
}

View File

@ -0,0 +1,76 @@
/**
* @author gchq77703 []
* @author n1474335 [n1474335@gmail.com]
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import Operation from "../Operation";
import TLVParser from "../lib/TLVParser";
import OperationError from "../errors/OperationError";
/**
* Parse TLV operation
*/
class ParseTLV extends Operation {
/**
* ParseTLV constructor
*/
constructor() {
super();
this.name = "Parse TLV";
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.outputType = "JSON";
this.args = [
{
name: "Type/Key size",
type: "number",
value: 1
},
{
name: "Length size",
type: "number",
value: 1
},
{
name: "Use BER",
type: "boolean",
value: false
}
];
}
/**
* @param {byteArray} input
* @param {Object[]} args
* @returns {string}
*/
run(input, args) {
const [bytesInKey, bytesInLength, basicEncodingRules] = args;
if (bytesInKey <= 0 && bytesInLength <= 0)
throw new OperationError("Type or Length size must be greater than 0");
const tlv = new TLVParser(input, { bytesInLength, basicEncodingRules });
const data = [];
while (!tlv.atEnd()) {
const key = bytesInKey ? tlv.getValue(bytesInKey) : undefined;
const length = tlv.getLength();
const value = tlv.getValue(length);
data.push({ key, length, value });
}
return data;
}
}
export default ParseTLV;

View File

@ -71,6 +71,7 @@ import "./tests/operations/SymmetricDifference";
import "./tests/operations/ToGeohash.mjs";
import "./tests/operations/TranslateDateTimeFormat";
import "./tests/operations/Magic";
import "./tests/operations/ParseTLV";
let allTestsPassing = true;
const testStatusCounts = {

View File

@ -0,0 +1,56 @@
/**
* Parse TLV tests.
*
* @author gchq77703 []
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import TestRegister from "../../TestRegister";
TestRegister.addTests([
{
name: "Parse TLV: LengthValue",
input: "\x05\x48\x6f\x75\x73\x65\x04\x72\x6f\x6f\x6d\x04\x64\x6f\x6f\x72",
expectedOutput: JSON.stringify([{"length": 5, "value": [72, 111, 117, 115, 101]}, {"length": 4, "value": [114, 111, 111, 109]}, {"length": 4, "value": [100, 111, 111, 114]}], null, 4),
recipeConfig: [
{
"op": "Parse TLV",
"args": [0, 1, false]
}
]
},
{
name: "Parse TLV: LengthValue with BER",
input: "\x05\x48\x6f\x75\x73\x65\x04\x72\x6f\x6f\x6d\x04\x64\x6f\x6f\x72",
expectedOutput: JSON.stringify([{"length": 5, "value": [72, 111, 117, 115, 101]}, {"length": 4, "value": [114, 111, 111, 109]}, {"length": 4, "value": [100, 111, 111, 114]}], null, 4),
recipeConfig: [
{
"op": "Parse TLV",
"args": [0, 4, true] // length value is patently wrong, should be ignored by BER.
}
]
},
{
name: "Parse TLV: KeyLengthValue",
input: "\x04\x05\x48\x6f\x75\x73\x65\x05\x04\x72\x6f\x6f\x6d\x42\x04\x64\x6f\x6f\x72",
expectedOutput: JSON.stringify([{"key": [4], "length": 5, "value": [72, 111, 117, 115, 101]}, {"key": [5], "length": 4, "value": [114, 111, 111, 109]}, {"key": [66], "length": 4, "value": [100, 111, 111, 114]}], null, 4),
recipeConfig: [
{
"op": "Parse TLV",
"args": [1, 1, false]
}
]
},
{
name: "Parse TLV: KeyLengthValue with BER",
input: "\x04\x05\x48\x6f\x75\x73\x65\x05\x04\x72\x6f\x6f\x6d\x42\x04\x64\x6f\x6f\x72",
expectedOutput: JSON.stringify([{"key": [4], "length": 5, "value": [72, 111, 117, 115, 101]}, {"key": [5], "length": 4, "value": [114, 111, 111, 109]}, {"key": [66], "length": 4, "value": [100, 111, 111, 114]}], null, 4),
recipeConfig: [
{
"op": "Parse TLV",
"args": [1, 4, true] // length value is patently wrong, should be ignored by BER.
}
]
}
]);

View File

@ -113,7 +113,11 @@ module.exports = {
chunks: false,
modules: false,
entrypoints: false,
warningsFilter: [/source-map/, /dependency is an expression/],
warningsFilter: [
/source-map/,
/dependency is an expression/,
/export 'default'/
],
},
node: {
fs: "empty"