diff --git a/README.md b/README.md index 0c831ba2..56e63b62 100755 --- a/README.md +++ b/README.md @@ -6,11 +6,14 @@ This is a fork of original CyberChef by GCHQ. This project has implemented my ow - opeartion **nTcpdump**: tcpdump hexdump convert - operation **From 0x[Hex]**: e.g. 0x217e21 to !~! +- operation **From char(hex)**: + - e.g. chr(33) to ! + - This operation supports char() and chr() + - Combining the usage of **From 0x[Hex]** and **From char(hex)** can decode chr(0x3333) to ! ## Todo - operation GZip HTTP data -- operation char() data - operation SQL comment strip function diff --git a/src/js/config/Categories.js b/src/js/config/Categories.js index f1d2749c..ec4f3bfb 100755 --- a/src/js/config/Categories.js +++ b/src/js/config/Categories.js @@ -29,6 +29,7 @@ var Categories = [ "From Hexdump", "From nTcpdump", "From 0x[Hex]", + "From Char(Hex)", "To Hex", "From Hex", "To Charcode", diff --git a/src/js/config/OperationConfig.js b/src/js/config/OperationConfig.js index f4bb2ca8..2ec7e013 100755 --- a/src/js/config/OperationConfig.js +++ b/src/js/config/OperationConfig.js @@ -400,6 +400,15 @@ var OperationConfig = { outputType: "string", args: [] }, + "From Char(Hex)": { + description: "Converts a hexadecimal byte string back into a its raw value.

e.g. chr(33) becomes the UTF-8 encoded string !", + run: ByteRepr.runFromCharHex, + highlight: ByteRepr.highlightFrom, + highlightReverse: ByteRepr.highlightTo, + inputType: "string", + outputType: "string", + args: [] + }, "From Hex": { description: "Converts a hexadecimal byte string back into a its raw value.

e.g. ce 93 ce b5 ce b9 ce ac 20 cf 83 ce bf cf 85 0a becomes the UTF-8 encoded string Γειά σου", run: ByteRepr.runFromHex, diff --git a/src/js/operations/ByteRepr.js b/src/js/operations/ByteRepr.js index ebbae924..4168d7b6 100755 --- a/src/js/operations/ByteRepr.js +++ b/src/js/operations/ByteRepr.js @@ -69,6 +69,25 @@ var ByteRepr = { }); return data; }, + + + /** + * From char(hex) operation. + * + * @param {string} input (Starting with chr or char only in the raw input) + * @param {Object[]} args + * @returns {byteArray} + */ + runFromCharHex: function(input, args) { + var data = input.replace(/cha?r\((\d{1,3})\)/ig, + function(match, p1) { + if (p1) { + console.log(p1); + return Utils.byteArrayToChars([parseInt(p1)]); + }; + }); + return data; + }, /**