Merge remote-tracking branch 'upstream/master' into feature_xpath

feature-extract-files
Mike Schwörer 2016-12-05 20:16:39 +01:00
commit 5c92e49d5d
No known key found for this signature in database
GPG Key ID: D3C7172E0A70F8CF
12 changed files with 116 additions and 57 deletions

View File

@ -9,7 +9,8 @@ module.exports = function(grunt) {
grunt.registerTask("prod", grunt.registerTask("prod",
"Creates a production-ready build. Use the --msg flag to add a compile message.", "Creates a production-ready build. Use the --msg flag to add a compile message.",
["jshint", "exec:stats", "clean", "jsdoc", "concat", "copy", "cssmin", "uglify:prod", "inline", "htmlmin", "chmod"]); ["jshint", "exec:stats", "clean", "jsdoc", "concat", "copy:html_dev", "copy:html_prod", "copy:html_inline",
"copy:static_dev", "copy:static_prod", "cssmin", "uglify:prod", "inline", "htmlmin", "chmod"]);
grunt.registerTask("docs", grunt.registerTask("docs",
"Compiles documentation in the /docs directory.", "Compiles documentation in the /docs directory.",
@ -18,6 +19,10 @@ module.exports = function(grunt) {
grunt.registerTask("stats", grunt.registerTask("stats",
"Provides statistics about the code base such as how many lines there are as well as details of file sizes before and after compression.", "Provides statistics about the code base such as how many lines there are as well as details of file sizes before and after compression.",
["concat:js", "uglify:prod", "exec:stats", "exec:repo_size", "exec:display_stats"]); ["concat:js", "uglify:prod", "exec:stats", "exec:repo_size", "exec:display_stats"]);
grunt.registerTask("release",
"Prepares and deploys a production version of CyberChef to the gh-pages branch.",
["copy:gh_pages", "exec:deploy_gh_pages"]);
grunt.registerTask("default", grunt.registerTask("default",
"Lints the code base and shows stats", "Lints the code base and shows stats",
@ -259,7 +264,7 @@ module.exports = function(grunt) {
process: function(content, srcpath) { process: function(content, srcpath) {
// TODO: Do all this in Jade // TODO: Do all this in Jade
content = content.replace( content = content.replace(
'<a href="cyberchef.htm" style="float: left; margin-left: 10px; margin-right: 80px;" download>Download CyberChef<img src="images/cloud_computing_download-plain-24x24.png" /></a>', '<a href="cyberchef.htm" style="float: left; margin-left: 10px; margin-right: 80px;" download>Download CyberChef<img src="images/download-24x24.png" /></a>',
'<span style="float: left; margin-left: 10px;">Compile time: ' + grunt.template.today("dd/mm/yyyy HH:MM:ss") + ' UTC</span>'); '<span style="float: left; margin-left: 10px;">Compile time: ' + grunt.template.today("dd/mm/yyyy HH:MM:ss") + ' UTC</span>');
return grunt.template.process(content, template_options); return grunt.template.process(content, template_options);
} }
@ -275,7 +280,8 @@ module.exports = function(grunt) {
src: [ src: [
"**/*", "**/*",
"**/.*", "**/.*",
"!stats.txt" "!stats.txt",
"!ga.html"
], ],
dest: "build/dev/" dest: "build/dev/"
} }
@ -289,11 +295,24 @@ module.exports = function(grunt) {
src: [ src: [
"**/*", "**/*",
"**/.*", "**/.*",
"!stats.txt" "!stats.txt",
"!ga.html"
], ],
dest: "build/prod/" dest: "build/prod/"
} }
] ]
},
gh_pages: {
options: {
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>");
return grunt.template.process(content, template_options);
}
},
src: "build/prod/index.html",
dest: "build/prod/index.html"
} }
}, },
uglify: { uglify: {
@ -424,6 +443,16 @@ module.exports = function(grunt) {
clean_git: { clean_git: {
command: "git gc --prune=now --aggressive" command: "git gc --prune=now --aggressive"
}, },
deploy_gh_pages: {
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(";")
}
}, },
watch: { watch: {
css: { css: {
@ -432,7 +461,7 @@ module.exports = function(grunt) {
}, },
js: { js: {
files: "src/js/**/*.js", files: "src/js/**/*.js",
tasks: ["concat:js_all", "chmod:build"] tasks: ["concat:js", "chmod:build"]
}, },
html: { html: {
files: "src/html/**/*.html", files: "src/html/**/*.html",
@ -444,7 +473,7 @@ module.exports = function(grunt) {
}, },
grunt: { grunt: {
files: "Gruntfile.js", files: "Gruntfile.js",
tasks: ["clean:dev", "concat:css", "concat:js_all", "copy:html_dev", "copy:static_dev", "chmod:build"] tasks: ["clean:dev", "concat:css", "concat:js", "copy:html_dev", "copy:static_dev", "chmod:build"]
} }
}, },
}); });

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -209,7 +209,7 @@ var OperationConfig = {
] ]
}, },
"XOR": { "XOR": {
description: "XOR the input with the given key.<br>e.g. <code>fe023da5</code><br><br><strong>Options</strong><br><u>Null preserving:</u> If the current byte is 0x00 or the same as the key, skip it.<br><br><u>Differential:</u> Set the key to the value of the previously decoded byte.", description: "XOR the input with the given key.<br>e.g. <code>fe023da5</code><br><br><strong>Options</strong><br><u>Null preserving:</u> If the current byte is 0x00 or the same as the key, skip it.<br><br><u>Scheme:</u><ul><li>Standard - key is unchanged after each round</li><li>Input differential - key is set to the value of the previous unprocessed byte</li><li>Output differential - key is set to the value of the previous processed byte</li></ul>",
run: BitwiseOp.run_xor, run: BitwiseOp.run_xor,
highlight: true, highlight: true,
highlight_reverse: true, highlight_reverse: true,
@ -222,15 +222,15 @@ var OperationConfig = {
value: "", value: "",
toggle_values: BitwiseOp.KEY_FORMAT toggle_values: BitwiseOp.KEY_FORMAT
}, },
{
name: "Scheme",
type: "option",
value: BitwiseOp.XOR_SCHEME
},
{ {
name: "Null preserving", name: "Null preserving",
type: "boolean", type: "boolean",
value: BitwiseOp.XOR_PRESERVE_NULLS value: BitwiseOp.XOR_PRESERVE_NULLS
},
{
name: "Differential",
type: "boolean",
value: BitwiseOp.XOR_DIFFERENTIAL
} }
] ]
}, },

View File

@ -875,7 +875,10 @@ var Utils = {
* Utils.escape_html("A <script> tag"); * Utils.escape_html("A <script> tag");
*/ */
escape_html: function(str) { escape_html: function(str) {
return str.replace(/</g, "&lt;"); return str.replace(/</g, "&lt;")
.replace(/'/g, "&apos;")
.replace(/"/g, '&quot;')
.replace(/&/g, "&amp;");
}, },

View File

@ -215,21 +215,21 @@ var Base64 = {
if (len0 % 4 == 2) { if (len0 % 4 == 2) {
static_section = offset0.slice(0, -3); static_section = offset0.slice(0, -3);
offset0 = "<span data-toggle='tooltip' data-placement='top' title='" + offset0 = "<span data-toggle='tooltip' data-placement='top' title='" +
Utils.from_base64(static_section, alphabet).slice(0, -2) + "'>" + Utils.escape_html(Utils.from_base64(static_section, alphabet).slice(0, -2)) + "'>" +
static_section + "</span>" + static_section + "</span>" +
"<span class='hlgreen'>" + offset0.substr(offset0.length - 3, 1) + "</span>" + "<span class='hlgreen'>" + offset0.substr(offset0.length - 3, 1) + "</span>" +
"<span class='hlred'>" + offset0.substr(offset0.length - 2) + "</span>"; "<span class='hlred'>" + offset0.substr(offset0.length - 2) + "</span>";
} else if (len0 % 4 == 3) { } else if (len0 % 4 == 3) {
static_section = offset0.slice(0, -2); static_section = offset0.slice(0, -2);
offset0 = "<span data-toggle='tooltip' data-placement='top' title='" + offset0 = "<span data-toggle='tooltip' data-placement='top' title='" +
Utils.from_base64(static_section, alphabet).slice(0, -1) + "'>" + Utils.escape_html(Utils.from_base64(static_section, alphabet).slice(0, -1)) + "'>" +
static_section + "</span>" + static_section + "</span>" +
"<span class='hlgreen'>" + offset0.substr(offset0.length - 2, 1) + "</span>" + "<span class='hlgreen'>" + offset0.substr(offset0.length - 2, 1) + "</span>" +
"<span class='hlred'>" + offset0.substr(offset0.length - 1) + "</span>"; "<span class='hlred'>" + offset0.substr(offset0.length - 1) + "</span>";
} else { } else {
static_section = offset0; static_section = offset0;
offset0 = "<span data-toggle='tooltip' data-placement='top' title='" + offset0 = "<span data-toggle='tooltip' data-placement='top' title='" +
Utils.from_base64(static_section, alphabet) + "'>" + Utils.escape_html(Utils.from_base64(static_section, alphabet)) + "'>" +
static_section + "</span>"; static_section + "</span>";
} }
@ -245,21 +245,21 @@ var Base64 = {
if (len1 % 4 == 2) { if (len1 % 4 == 2) {
static_section = offset1.slice(0, -3); static_section = offset1.slice(0, -3);
offset1 = padding + "<span data-toggle='tooltip' data-placement='top' title='" + offset1 = padding + "<span data-toggle='tooltip' data-placement='top' title='" +
Utils.from_base64("AA" + static_section, alphabet).slice(1, -2) + "'>" + Utils.escape_html(Utils.from_base64("AA" + static_section, alphabet).slice(1, -2)) + "'>" +
static_section + "</span>" + static_section + "</span>" +
"<span class='hlgreen'>" + offset1.substr(offset1.length - 3, 1) + "</span>" + "<span class='hlgreen'>" + offset1.substr(offset1.length - 3, 1) + "</span>" +
"<span class='hlred'>" + offset1.substr(offset1.length - 2) + "</span>"; "<span class='hlred'>" + offset1.substr(offset1.length - 2) + "</span>";
} else if (len1 % 4 == 3) { } else if (len1 % 4 == 3) {
static_section = offset1.slice(0, -2); static_section = offset1.slice(0, -2);
offset1 = padding + "<span data-toggle='tooltip' data-placement='top' title='" + offset1 = padding + "<span data-toggle='tooltip' data-placement='top' title='" +
Utils.from_base64("AA" + static_section, alphabet).slice(1, -1) + "'>" + Utils.escape_html(Utils.from_base64("AA" + static_section, alphabet).slice(1, -1)) + "'>" +
static_section + "</span>" + static_section + "</span>" +
"<span class='hlgreen'>" + offset1.substr(offset1.length - 2, 1) + "</span>" + "<span class='hlgreen'>" + offset1.substr(offset1.length - 2, 1) + "</span>" +
"<span class='hlred'>" + offset1.substr(offset1.length - 1) + "</span>"; "<span class='hlred'>" + offset1.substr(offset1.length - 1) + "</span>";
} else { } else {
static_section = offset1; static_section = offset1;
offset1 = padding + "<span data-toggle='tooltip' data-placement='top' title='" + offset1 = padding + "<span data-toggle='tooltip' data-placement='top' title='" +
Utils.from_base64("AA" + static_section, alphabet).slice(1) + "'>" + Utils.escape_html(Utils.from_base64("AA" + static_section, alphabet).slice(1)) + "'>" +
static_section + "</span>"; static_section + "</span>";
} }
@ -274,21 +274,21 @@ var Base64 = {
if (len2 % 4 == 2) { if (len2 % 4 == 2) {
static_section = offset2.slice(0, -3); static_section = offset2.slice(0, -3);
offset2 = padding + "<span data-toggle='tooltip' data-placement='top' title='" + offset2 = padding + "<span data-toggle='tooltip' data-placement='top' title='" +
Utils.from_base64("AAA" + static_section, alphabet).slice(2, -2) + "'>" + Utils.escape_html(Utils.from_base64("AAA" + static_section, alphabet).slice(2, -2)) + "'>" +
static_section + "</span>" + static_section + "</span>" +
"<span class='hlgreen'>" + offset2.substr(offset2.length - 3, 1) + "</span>" + "<span class='hlgreen'>" + offset2.substr(offset2.length - 3, 1) + "</span>" +
"<span class='hlred'>" + offset2.substr(offset2.length - 2) + "</span>"; "<span class='hlred'>" + offset2.substr(offset2.length - 2) + "</span>";
} else if (len2 % 4 == 3) { } else if (len2 % 4 == 3) {
static_section = offset2.slice(0, -2); static_section = offset2.slice(0, -2);
offset2 = padding + "<span data-toggle='tooltip' data-placement='top' title='" + offset2 = padding + "<span data-toggle='tooltip' data-placement='top' title='" +
Utils.from_base64("AAA" + static_section, alphabet).slice(2, -2) + "'>" + Utils.escape_html(Utils.from_base64("AAA" + static_section, alphabet).slice(2, -2)) + "'>" +
static_section + "</span>" + static_section + "</span>" +
"<span class='hlgreen'>" + offset2.substr(offset2.length - 2, 1) + "</span>" + "<span class='hlgreen'>" + offset2.substr(offset2.length - 2, 1) + "</span>" +
"<span class='hlred'>" + offset2.substr(offset2.length - 1) + "</span>"; "<span class='hlred'>" + offset2.substr(offset2.length - 1) + "</span>";
} else { } else {
static_section = offset2; static_section = offset2;
offset2 = padding + "<span data-toggle='tooltip' data-placement='top' title='" + offset2 = padding + "<span data-toggle='tooltip' data-placement='top' title='" +
Utils.from_base64("AAA" + static_section, alphabet).slice(2) + "'>" + Utils.escape_html(Utils.from_base64("AAA" + static_section, alphabet).slice(2)) + "'>" +
static_section + "</span>"; static_section + "</span>";
} }

View File

@ -19,10 +19,10 @@ var BitwiseOp = {
* @param {byte_array} key * @param {byte_array} key
* @param {function} func - The bitwise calculation to carry out * @param {function} func - The bitwise calculation to carry out
* @param {boolean} null_preserving * @param {boolean} null_preserving
* @param {boolean} differential * @param {string} scheme
* @returns {byte_array} * @returns {byte_array}
*/ */
_bit_op: function (input, key, func, null_preserving, differential) { _bit_op: function (input, key, func, null_preserving, scheme) {
if (!key || !key.length) key = [0]; if (!key || !key.length) key = [0];
var result = [], var result = [],
x = null, x = null,
@ -34,8 +34,15 @@ var BitwiseOp = {
o = input[i]; o = input[i];
x = null_preserving && (o === 0 || o == k) ? o : func(o, k); x = null_preserving && (o === 0 || o == k) ? o : func(o, k);
result.push(x); result.push(x);
if (differential && !(null_preserving && (o === 0 || o == k))) { if (scheme != "Standard" && !(null_preserving && (o === 0 || o == k))) {
key[i % key.length] = x; switch (scheme) {
case "Input differential":
key[i % key.length] = x;
break;
case "Output differential":
key[i % key.length] = o;
break;
}
} }
} }
@ -52,7 +59,7 @@ var BitwiseOp = {
* @constant * @constant
* @default * @default
*/ */
XOR_DIFFERENTIAL: false, XOR_SCHEME: ["Standard", "Input differential", "Output differential"],
/** /**
* @constant * @constant
* @default * @default
@ -68,12 +75,12 @@ var BitwiseOp = {
*/ */
run_xor: function (input, args) { run_xor: function (input, args) {
var key = Utils.format[args[0].option].parse(args[0].string || ""), var key = Utils.format[args[0].option].parse(args[0].string || ""),
null_preserving = args[1], scheme = args[1],
differential = args[2]; null_preserving = args[2];
key = Utils.word_array_to_byte_array(key); key = Utils.word_array_to_byte_array(key);
return BitwiseOp._bit_op(input, key, BitwiseOp._xor, null_preserving, differential); return BitwiseOp._bit_op(input, key, BitwiseOp._xor, null_preserving, scheme);
}, },

View File

@ -64,6 +64,7 @@ var Code = {
*/ */
run_json_beautify: function(input, args) { run_json_beautify: function(input, args) {
var indent_str = args[0]; var indent_str = args[0];
if (!input) return "";
return vkbeautify.json(input, indent_str); return vkbeautify.json(input, indent_str);
}, },
@ -121,6 +122,7 @@ var Code = {
* @returns {string} * @returns {string}
*/ */
run_json_minify: function(input, args) { run_json_minify: function(input, args) {
if (!input) return "";
return vkbeautify.jsonmin(input); return vkbeautify.jsonmin(input);
}, },

View File

@ -279,8 +279,8 @@ HTMLApp.prototype.valid_favourites = function(favourites) {
if (this.operations.hasOwnProperty(favourites[i])) { if (this.operations.hasOwnProperty(favourites[i])) {
valid_favs.push(favourites[i]); valid_favs.push(favourites[i]);
} else { } else {
this.alert("The operation \"" + favourites[i] + "\" is no longer " + this.alert("The operation \"" + Utils.escape_html(favourites[i]) +
"available. It has been removed from your favourites.", "info"); "\" is no longer available. It has been removed from your favourites.", "info");
} }
} }
return valid_favs; return valid_favs;

18
src/static/ga.html Normal file
View File

@ -0,0 +1,18 @@
<!-- Begin Google Analytics -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-85682716-2', 'auto');
// Specifying location.pathname here overrides the default URL which would include arguments.
// This method prevents Google Analytics from logging any recipe or input data in the URL.
ga('send', 'pageview', location.pathname);
</script>
<!-- End Google Analytics -->

View File

@ -1,9 +1,9 @@
202 source files 203 source files
104191 lines 104221 lines
4.0M size 4.0M size
136 JavaScript source files 136 JavaScript source files
95119 lines 95131 lines
3.4M size 3.4M size
78 third party JavaScript source files 78 third party JavaScript source files
@ -11,7 +11,7 @@
2.7M size 2.7M size
58 first party JavaScript source files 58 first party JavaScript source files
18742 lines 18754 lines
724K size 724K size
3.1M uncompressed JavaScript size 3.1M uncompressed JavaScript size