diff --git a/src/js/config/Categories.js b/src/js/config/Categories.js index 02c2b1f5..8a645e3e 100755 --- a/src/js/config/Categories.js +++ b/src/js/config/Categories.js @@ -77,6 +77,7 @@ var Categories = [ "RC4", "RC4 Drop", "ROT13", + "ROT47", "XOR", "XOR Brute Force", "Derive PBKDF2 key", diff --git a/src/js/config/OperationConfig.js b/src/js/config/OperationConfig.js index bebaaad4..42e2998b 100755 --- a/src/js/config/OperationConfig.js +++ b/src/js/config/OperationConfig.js @@ -1390,6 +1390,21 @@ var OperationConfig = { }, ] }, + "ROT47": { + description: "A slightly more complex variation of a caesar cipher, which includes ASCII characters too. (default 47)", + run: Rotate.run_rot47, + highlight: true, + highlight_reverse: true, + input_type: "byte_array", + output_type: "byte_array", + args: [ + { + name: "Amount", + type: "number", + value: Rotate.ROT47_AMOUNT + }, + ] + }, "Strip HTTP headers": { description: "Removes HTTP headers from a request or response by looking for the first instance of a double newline.", run: HTTP.run_strip_headers, diff --git a/src/js/operations/Rotate.js b/src/js/operations/Rotate.js index eadad540..3477f08f 100755 --- a/src/js/operations/Rotate.js +++ b/src/js/operations/Rotate.js @@ -1,7 +1,7 @@ /** * Bit rotation operations. * - * @author n1474335 [n1474335@gmail.com] + * @author n1474335 [n1474335@gmail.com] & Matt C [matt@artemisbot.pw] * @copyright Crown Copyright 2016 * @license Apache-2.0 * @@ -91,7 +91,7 @@ var Rotate = { * @default */ ROT13_UPPERCASE: true, - + /** * ROT13 operation. * @@ -124,8 +124,43 @@ var Rotate = { } return output; }, - - + + + /** + * @constant + * @default + */ + ROT47_AMOUNT: 47, + + /** + * ROT47 operation. + * + * @param {byte_array} input + * @param {Object[]} args + * @returns {byte_array} + */ + run_rot47: function(input, args) { + var amount = args[0], + output = input, + chr; + + if (amount) { + if (amount < 0) { + amount = 94 - (Math.abs(amount) % 94); + } + + for (var i = 0; i < input.length; i++) { + chr = input[i]; + if (chr >= 33 && chr <= 126) { + chr = (chr - 33 + amount) % 94; + output[i] = chr + 33; + } + } + } + return output; + }, + + /** * Rotate right bitwise op. *