2
0
mirror of https://github.com/gchq/CyberChef synced 2025-12-05 23:53:27 +00:00

Compare commits

..

23 Commits

Author SHA1 Message Date
n1474335
fad3db1556 5.1.2 2017-04-07 22:24:51 +01:00
n1474335
9d4862b5c8 Merge pull request #111 from gchq/bug-autobake-reorder
BUGFIX #98: Auto-Bake now triggers when operations are re-ordered.
2017-04-07 22:34:32 +01:00
n1474335
2a07999db6 BUGFIX #98: Auto-Bake now triggers when operations are re-ordered. 2017-04-07 22:23:23 +01:00
n1474335
ce2ffcafd3 5.1.1 2017-04-07 21:59:07 +01:00
n1474335
3093794f72 Merge pull request #109 from gchq/bug-search
Fixed popover bug in search. Fixes #107
2017-04-07 22:08:12 +01:00
n1474335
abd05f5105 Fixed popover bug in search and removed popovers when favourites are dragged out. 2017-04-07 21:50:53 +01:00
n1474335
dcb2ad9d2d Merge branch 'l50741-feature/accessibility' 2017-04-07 21:28:22 +01:00
n1474335
1770205ee1 5.1.0 2017-04-05 23:07:40 +01:00
n1474335
5c7dfcb4a2 Updated .travis.yml 2017-04-05 23:07:33 +01:00
n1474335
35e7460be8 Fixed lint error 2017-04-05 22:03:30 +01:00
n1474335
87ebe77dfb Merge branch 'artemisbot-feature-octal' 2017-04-05 22:00:33 +01:00
n1474335
5f85bff315 Fixed tests for octal operations. 2017-04-05 22:00:06 +01:00
l50741
03ad87d651 add a grunt plugin to check accessibility 2017-04-05 21:30:22 +01:00
Matt C
a36c9ca339 Merge remote-tracking branch 'upstream/master' into feature-octal 2017-03-31 18:44:38 +00:00
n1474335
f07709e80b Merge branch 'master' of https://github.com/gchq/CyberChef 2017-03-31 16:01:26 +00:00
n1474335
7272c86592 5.0.1 2017-03-31 16:00:30 +00:00
n1474335
706423462d 'From Base' operation now supports numbers with fractional parts. 2017-03-31 16:00:23 +00:00
n1474335
bace0c5b2c Updated .travis.yml 2017-03-31 11:27:39 +01:00
n1474335
3788a9161a Updated .travis.yml to add GA code to GH Pages 2017-03-31 09:56:08 +00:00
Matt C
7ab6c88774 Made fixes so that tests might work 2017-03-28 16:21:57 +00:00
Matt C
96e40a6479 Made requested changes. 2017-03-27 20:30:32 +00:00
Matt C
497824ff21 Merge branch 'master' into feature-octal 2017-03-27 18:50:42 +00:00
Matt C
b8ce10ae96 Adds Octal functions
- To Octal
- From Octal
2017-03-14 21:26:10 +00:00
13 changed files with 189 additions and 25 deletions

View File

@@ -10,6 +10,8 @@ script:
- grunt docs
- grunt node
- grunt prod
before_deploy:
- grunt copy:ghPages
deploy:
- provider: pages
skip_cleanup: true
@@ -21,7 +23,7 @@ deploy:
- provider: releases
skip_cleaup: true
api_key:
secure: Lbya9e1a6bUeJLKsjuqRaNF/BNr7iqSjV0/9rhWbTCc5d1cd+A6DGnDqvw47S2x/+8b08XR5Umas5dS6KU4lLAZQ5DFJgKEuOqUDqz7fOfIZyaRKe8HBTrUn3c1zaqpbrIDQHAOwwEMSx3W+SXmFuniIHRkBFALfK/luyHb4u6e1vq9AsX59A6ICOl5fpGD8kHDtdFZtgCrrZ5tkX5wweiRUbro+LBNlfBCaXeuUwnigU0chAGx8wJWeSvHrndGoPPFEXc0MT4QPlI+q6R3AiO/mwS2/nLhEIGt4jrWUtyFQD9gFLZXg7Z6GC5pKqyf2EQXzgC8Kggybmbg5/MiWj1ns0d1XMK26r50bHD/9K7Kzlh5vq8Sum4DYWtuT4AsWgL/PfUEvB1FbF4InRJoIlbT3pWj9zNFKTyBNcvUchPk1uBE1Ldn5yPPZoSgdKO0ZiGjn/Qx0ByaDMGJbM5KMg3ALewJmaCiCbnvAaVvAm2UY6GrVK15JiGVn08GhliSzsx6E48ZcFtNJBwHK8MAimbTRyHR6aStJbEYIgoNiAjVv5m0twee/XknDvhULG2tor9chwhnqKb4kvaYPqbVuHNPyDT8VkLsHcpgeD2MKxGTq81NBgPz3rP3T1yWMxsuvhxoH91tIT8mU1jo8/e3BJYogKyRZXxwIHaF7ScDQZ4c=
secure: "HV1WSKv4l/0Y2bKKs1iBJocBcmLj08PCRUeEM/jTwA4jqJ8EiLHWiXtER/D5sEg2iibRVKd2OQjfrmS6bo4AiwdeVgAKmv0FtS2Jw+391N8Nd5AkEANHa5Om/IpHLTL2YRAjpJTsDpY72bMUTJIwjQA3TFJkgrpOw6KYfohOcgbxLpZ4XuNJRU3VL4Hsxdv5V9aOVmfFOmMOVPQlakXy7NgtW5POp1f2WJwgcZxylkR1CjwaqMyXmSoVl46pyH3tr5+dptsQoKSGdi6sIHGA60oDotFPcm+0ifa47wZw+vapuuDi4tdNxhrHGaDMG8xiE0WFDHwQUDlk2/+W7j9SEX0H3Em7us371JXRp56EDwEcDa34VpVkC6i8HGcHK55hnxVbMZXGf3qhOFD8wY7qMbjMRvIpucrMHBi86OfkDfv0vDj2LyvIl5APj/AX50BrE0tfH1MZbH26Jkx4NdlkcxQ14GumarmUqfmVvbX/fsoA6oUuAAE9ZgRRi3KHO4wci6KUcRfdm+XOeUkaBFsL86G3EEYIvrtBTuaypdz+Cx7nd1iPZyWMx5Y1gXnVzha4nBdV4+7l9JIsFggD8QVpw2uHXQiS1KXFjOeqA3DBD8tjMB7q26Fl2fD3jkOo4BTbQ2NrRIZUu/iL+fOmMPsyMt2qulB0yaSBCfkbEq8xrUA="
file:
- build/prod/cyberchef.htm
- build/node/CyberChef.js

View File

@@ -28,10 +28,6 @@ module.exports = function (grunt) {
"Creates a production-ready build. Use the --msg flag to add a compile message.",
["eslint", "clean:prod", "webpack:webProd", "inline", "chmod"]);
grunt.registerTask("release",
"Prepares and deploys a production version of CyberChef to the gh-pages branch.",
["copy:ghPages", "exec:deployGhPages"]);
grunt.registerTask("default",
"Lints the code base",
["eslint", "exec:repoSize"]);
@@ -54,6 +50,7 @@ module.exports = function (grunt) {
grunt.loadNpmTasks("grunt-chmod");
grunt.loadNpmTasks("grunt-exec");
grunt.loadNpmTasks("grunt-execute");
grunt.loadNpmTasks("grunt-accessibility");
// Project configuration
@@ -137,6 +134,14 @@ module.exports = function (grunt) {
],
}
},
accessibility: {
options: {
accessibilityLevel: "WCAG2A"
},
test: {
src: ["build/**/*.html"]
}
},
webpack: {
options: {
plugins: [
@@ -295,7 +300,7 @@ module.exports = function (grunt) {
process: function (content, srcpath) {
// Add Google Analytics code to index.html
content = content.replace("</body></html>",
grunt.file.read("src/static/ga.html") + "</body></html>");
grunt.file.read("src/web/static/ga.html") + "</body></html>");
return grunt.template.process(content);
}
},
@@ -328,16 +333,6 @@ module.exports = function (grunt) {
cleanGit: {
command: "git gc --prune=now --aggressive"
},
deployGhPages: {
command: [
"git add build/prod/index.html -v",
"COMMIT_HASH=$(git rev-parse HEAD)",
"git commit -m \"GitHub Pages release for ${COMMIT_HASH}\"",
"git push origin `git subtree split --prefix build/prod master`:gh-pages --force",
"git reset HEAD~",
"git checkout build/prod/index.html"
].join(";")
}
},
execute: {
test: "build/test/index.js"

View File

@@ -1,6 +1,6 @@
{
"name": "cyberchef",
"version": "5.0.0",
"version": "5.1.2",
"description": "CyberChef is a simple, intuitive web app for analysing and decoding data within a web browser.",
"author": "n1474335 <n1474335@gmail.com>",
"homepage": "https://gchq.github.io/CyberChef",
@@ -35,6 +35,7 @@
"extract-text-webpack-plugin": "^2.1.0",
"file-loader": "^0.10.1",
"grunt": ">=0.4.5",
"grunt-accessibility": "~5.0.0",
"grunt-chmod": "~1.1.1",
"grunt-contrib-clean": "~1.0.0",
"grunt-contrib-copy": "~1.0.0",

View File

@@ -212,7 +212,7 @@ const Utils = {
* @returns {string}
*/
printable: function(str, preserveWs) {
if (window && window.app && !window.app.options.treatAsUtf8) {
if (typeof window !== "undefined" && window.app && !window.app.options.treatAsUtf8) {
str = Utils.byteArrayToChars(Utils.strToByteArray(str));
}
@@ -388,8 +388,9 @@ const Utils = {
var wordArray = CryptoJS.enc.Utf8.parse(str),
byteArray = Utils.wordArrayToByteArray(wordArray);
if (window && str.length !== wordArray.sigBytes)
if (typeof window !== "undefined" && str.length !== wordArray.sigBytes) {
window.app.options.attemptHighlight = false;
}
return byteArray;
},
@@ -440,7 +441,7 @@ const Utils = {
var wordArray = new CryptoJS.lib.WordArray.init(words, byteArray.length),
str = CryptoJS.enc.Utf8.stringify(wordArray);
if (window && str.length !== wordArray.sigBytes)
if (typeof window !== "undefined" && str.length !== wordArray.sigBytes)
window.app.options.attemptHighlight = false;
return str;
} catch (err) {

View File

@@ -35,6 +35,8 @@ const Categories = [
"From Decimal",
"To Binary",
"From Binary",
"To Octal",
"From Octal",
"To Base64",
"From Base64",
"Show Base64 offsets",

View File

@@ -425,7 +425,7 @@ const OperationConfig = {
]
},
"From Hex": {
description: "Converts a hexadecimal byte string back into a its raw value.<br><br>e.g. <code>ce 93 ce b5 ce b9 ce ac 20 cf 83 ce bf cf 85 0a</code> becomes the UTF-8 encoded string <code>Γειά σου</code>",
description: "Converts a hexadecimal byte string back into its raw value.<br><br>e.g. <code>ce 93 ce b5 ce b9 ce ac 20 cf 83 ce bf cf 85 0a</code> becomes the UTF-8 encoded string <code>Γειά σου</code>",
run: ByteRepr.runFromHex,
highlight: ByteRepr.highlightFrom,
highlightReverse: ByteRepr.highlightTo,
@@ -454,6 +454,36 @@ const OperationConfig = {
}
]
},
"From Octal": {
description: "Converts an octal byte string back into its raw value.<br><br>e.g. <code>316 223 316 265 316 271 316 254 40 317 203 316 277 317 205</code> becomes the UTF-8 encoded string <code>Γειά σου</code>",
run: ByteRepr.runFromOct,
highlight: false,
highlightReverse: false,
inputType: "string",
outputType: "byteArray",
args: [
{
name: "Delimiter",
type: "option",
value: ByteRepr.DELIM_OPTIONS
}
]
},
"To Octal": {
description: "Converts the input string to octal bytes separated by the specified delimiter.<br><br>e.g. The UTF-8 encoded string <code>Γειά σου</code> becomes <code>316 223 316 265 316 271 316 254 40 317 203 316 277 317 205</code>",
run: ByteRepr.runToOct,
highlight: false,
highlightReverse: false,
inputType: "byteArray",
outputType: "string",
args: [
{
name: "Delimiter",
type: "option",
value: ByteRepr.DELIM_OPTIONS
}
]
},
"From Charcode": {
description: "Converts unicode character codes back into text.<br><br>e.g. <code>0393 03b5 03b9 03ac 20 03c3 03bf 03c5</code> becomes <code>Γειά σου</code>",
run: ByteRepr.runFromCharcode,

View File

@@ -46,7 +46,19 @@ const Base = {
if (radix < 2 || radix > 36) {
throw "Error: Radix argument must be between 2 and 36";
}
return parseInt(input.replace(/\s/g, ""), radix);
var number = input.replace(/\s/g, "").split("."),
result = parseInt(number[0], radix) || 0;
if (number.length === 1) return result;
// Fractional part
for (var i = 0; i < number[1].length; i++) {
var digit = parseInt(number[1][i], radix);
result += digit / Math.pow(radix, i+1);
}
return result;
},
};

View File

@@ -55,6 +55,35 @@ const ByteRepr = {
},
/**
* To Octal operation.
*
* @author Matt C [matt@artemisbot.pw]
* @param {byteArray} input
* @param {Object[]} args
* @returns {string}
*/
runToOct: function(input, args) {
var delim = Utils.charRep[args[0] || "Space"];
return input.map(val => val.toString(8)).join(delim);
},
/**
* From Octal operation.
*
* @author Matt C [matt@artemisbot.pw]
* @param {string} input
* @param {Object[]} args
* @returns {byteArray}
*/
runFromOct: function(input, args) {
var delim = Utils.charRep[args[0] || "Space"];
if (input.length === 0) return [];
return input.split(delim).map(val => parseInt(val, 8));
},
/**
* @constant
* @default

View File

@@ -13,7 +13,13 @@ const CyberChef = module.exports = {
bake: function(input, recipeConfig) {
this.chef = new Chef();
return this.chef.bake(input, recipeConfig, {}, 0, false);
return this.chef.bake(
input,
recipeConfig,
{},
0,
false
);
}
};

View File

@@ -73,7 +73,9 @@ OperationsWaiter.prototype.searchOperations = function(e) {
str = el.value;
while (searchResultsEl.firstChild) {
$(searchResultsEl.firstChild).popover("destroy");
try {
$(searchResultsEl.firstChild).popover("destroy");
} catch (err) {}
searchResultsEl.removeChild(searchResultsEl.firstChild);
}
@@ -209,7 +211,10 @@ OperationsWaiter.prototype.editFavouritesClick = function(e) {
}
},
onEnd: function(evt) {
if (this.removeIntent) evt.item.remove();
if (this.removeIntent) {
$(evt.item).popover("destroy");
evt.item.remove();
}
}.bind(this),
});

View File

@@ -43,6 +43,9 @@ RecipeWaiter.prototype.initialiseOperationDragNDrop = function() {
evt.item.remove();
evt.target.dispatchEvent(this.manager.operationremove);
}
}.bind(this),
onSort: function(evt) {
document.dispatchEvent(this.manager.statechange);
}.bind(this)
});

View File

@@ -12,6 +12,7 @@ import "babel-polyfill";
import TestRegister from "./TestRegister.js";
import "./tests/operations/Base58.js";
import "./tests/operations/ByteRepr.js";
import "./tests/operations/Compress.js";
import "./tests/operations/FlowControl.js";
import "./tests/operations/MorseCode.js";

View File

@@ -0,0 +1,77 @@
/**
* ByteRepr tests.
*
* @author Matt C [matt@artemisbot.pw]
* @copyright Crown Copyright 2017
* @license Apache-2.0
*/
import TestRegister from "../../TestRegister.js";
TestRegister.addTests([
{
name: "To Octal: nothing",
input: "",
expectedOutput: "",
recipeConfig: [
{
"op": "To Octal",
"args": ["Space"]
}
]
},
{
name: "From Octal: nothing",
input: "",
expectedOutput: "",
recipeConfig: [
{
"op": "From Octal",
"args": ["Space"]
}
]
},
{
name: "To Octal: hello world",
input: "hello world", // [104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100],
expectedOutput: "150 145 154 154 157 40 167 157 162 154 144",
recipeConfig: [
{
"op": "To Octal",
"args": ["Space"]
}
]
},
{
name: "From Octal: hello world",
input: "150 145 154 154 157 40 167 157 162 154 144",
expectedOutput: "hello world",
recipeConfig: [
{
"op": "From Octal",
"args": ["Space"]
}
]
},
{
name: "To Octal: Γειά σου",
input: "Γειά σου", //[206,147,206,181,206,185,206,172,32,207,131,206,191,207,133],
expectedOutput: "316 223 316 265 316 271 316 254 40 317 203 316 277 317 205",
recipeConfig: [
{
"op": "To Octal",
"args": ["Space"]
}
]
},
{
name: "From Octal: Γειά σου",
input: "316 223 316 265 316 271 316 254 40 317 203 316 277 317 205",
expectedOutput: "Γειά σου",
recipeConfig: [
{
"op": "From Octal",
"args": ["Space"]
}
]
},
]);