Tidied up 'Text Encoding Brute Force' operations and updated CHANGELOG
parent
d96ef37d81
commit
076a1f97c2
|
@ -2,6 +2,9 @@
|
|||
All major and minor version changes will be documented in this file. Details of patch-level version changes can be found in [commit messages](https://github.com/gchq/CyberChef/commits/master).
|
||||
|
||||
|
||||
### [8.15.0] - 2018-12-18
|
||||
- 'Text Encoding Brute Force' operation added [@Cynser] | [#439]
|
||||
|
||||
### [8.14.0] - 2018-12-18
|
||||
- 'To Base62' and 'From Base62' operations added [@tcode2k16] | [#443]
|
||||
|
||||
|
@ -73,6 +76,7 @@ All major and minor version changes will be documented in this file. Details of
|
|||
|
||||
|
||||
|
||||
[8.15.0]: https://github.com/gchq/CyberChef/releases/tag/v8.15.0
|
||||
[8.14.0]: https://github.com/gchq/CyberChef/releases/tag/v8.14.0
|
||||
[8.13.0]: https://github.com/gchq/CyberChef/releases/tag/v8.13.0
|
||||
[8.12.0]: https://github.com/gchq/CyberChef/releases/tag/v8.12.0
|
||||
|
@ -107,6 +111,7 @@ All major and minor version changes will be documented in this file. Details of
|
|||
[@bwhitn]: https://github.com/bwhitn
|
||||
[@jarmovanlenthe]: https://github.com/jarmovanlenthe
|
||||
[@tcode2k16]: https://github.com/tcode2k16
|
||||
[@Cynser]: https://github.com/Cynser
|
||||
|
||||
[#95]: https://github.com/gchq/CyberChef/pull/299
|
||||
[#173]: https://github.com/gchq/CyberChef/pull/173
|
||||
|
@ -130,5 +135,6 @@ All major and minor version changes will be documented in this file. Details of
|
|||
[#387]: https://github.com/gchq/CyberChef/pull/387
|
||||
[#394]: https://github.com/gchq/CyberChef/pull/394
|
||||
[#428]: https://github.com/gchq/CyberChef/pull/428
|
||||
[#439]: https://github.com/gchq/CyberChef/pull/439
|
||||
[#441]: https://github.com/gchq/CyberChef/pull/441
|
||||
[#443]: https://github.com/gchq/CyberChef/pull/443
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/**
|
||||
* @author Cynser
|
||||
* @author n1474335 [n1474335@gmail.com]
|
||||
* @copyright Crown Copyright 2018
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
@ -22,10 +23,18 @@ class TextEncodingBruteForce extends Operation {
|
|||
|
||||
this.name = "Text Encoding Brute Force";
|
||||
this.module = "CharEnc";
|
||||
this.description = "Enumerate all possible text encodings for input.";
|
||||
this.description = [
|
||||
"Enumerates all supported text encodings for the input, allowing you to quickly spot the correct one.",
|
||||
"<br><br>",
|
||||
"Supported charsets are:",
|
||||
"<ul>",
|
||||
Object.keys(IO_FORMAT).map(e => `<li>${e}</li>`).join("\n"),
|
||||
"</ul>"
|
||||
].join("\n");
|
||||
this.infoURL = "https://wikipedia.org/wiki/Character_encoding";
|
||||
this.inputType = "string";
|
||||
this.outputType = "string";
|
||||
this.outputType = "json";
|
||||
this.presentType = "html";
|
||||
this.args = [
|
||||
{
|
||||
name: "Mode",
|
||||
|
@ -38,30 +47,44 @@ class TextEncodingBruteForce extends Operation {
|
|||
/**
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
* @returns {json}
|
||||
*/
|
||||
run(input, args) {
|
||||
const output = [],
|
||||
charSets = Object.keys(IO_FORMAT),
|
||||
const output = {},
|
||||
charsets = Object.keys(IO_FORMAT),
|
||||
mode = args[0];
|
||||
|
||||
for (let i = 0; i < charSets.length; i++) {
|
||||
let currentEncoding = charSets[i] + ": ";
|
||||
|
||||
charsets.forEach(charset => {
|
||||
try {
|
||||
if (mode === "Decode") {
|
||||
currentEncoding += cptable.utils.decode(IO_FORMAT[charSets[i]], input);
|
||||
output[charset] = cptable.utils.decode(IO_FORMAT[charset], input);
|
||||
} else {
|
||||
currentEncoding += cptable.utils.encode(IO_FORMAT[charSets[i]], input);
|
||||
output[charset] = Utils.arrayBufferToStr(cptable.utils.encode(IO_FORMAT[charset], input));
|
||||
}
|
||||
} catch (err) {
|
||||
currentEncoding += "Could not decode.";
|
||||
output[charset] = "Could not decode.";
|
||||
}
|
||||
});
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
output.push(Utils.printable(currentEncoding, true));
|
||||
/**
|
||||
* Displays the encodings in an HTML table for web apps.
|
||||
*
|
||||
* @param {Object[]} encodings
|
||||
* @returns {html}
|
||||
*/
|
||||
present(encodings) {
|
||||
let table = "<table class='table table-hover table-sm table-bordered table-nonfluid'><tr><th>Encoding</th><th>Value</th></tr>";
|
||||
|
||||
for (const enc in encodings) {
|
||||
const value = Utils.printable(encodings[enc], true);
|
||||
table += `<tr><td>${enc}</td><td>${value}</td></tr>`;
|
||||
}
|
||||
|
||||
return output.join("\n");
|
||||
table += "<table>";
|
||||
return table;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ class ToBase62 extends Operation {
|
|||
this.name = "To Base62";
|
||||
this.module = "Default";
|
||||
this.description = "Base62 is a notation for encoding arbitrary byte data using a restricted set of symbols that can be conveniently used by humans and processed by computers. The high number base results in shorter strings than with the decimal or hexadecimal system.";
|
||||
this.infoURL = "https://en.wikipedia.org/wiki/List_of_numeral_systems";
|
||||
this.infoURL = "https://wikipedia.org/wiki/List_of_numeral_systems";
|
||||
this.inputType = "byteArray";
|
||||
this.outputType = "string";
|
||||
this.args = [
|
||||
|
|
|
@ -12,7 +12,7 @@ TestRegister.addTests([
|
|||
{
|
||||
name: "Text Encoding Brute Force - Encode",
|
||||
input: "Булкі праз ляніва сабаку.",
|
||||
expectedMatch: /Windows-1251 Cyrillic \(1251\): Булкі праз ляніва сабаку\./,
|
||||
expectedMatch: /Windows-1251 Cyrillic \(1251\).{1,10}Булкі праз ляніва сабаку\./,
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Text Encoding Brute Force",
|
||||
|
@ -23,7 +23,7 @@ TestRegister.addTests([
|
|||
{
|
||||
name: "Text Encoding Brute Force - Decode",
|
||||
input: "Áóëê³ ïðàç ëÿí³âà ñàáàêó.",
|
||||
expectedMatch: /Windows-1251 Cyrillic \(1251\): Булкі праз ляніва сабаку\./,
|
||||
expectedMatch: /Windows-1251 Cyrillic \(1251\).{1,10}Булкі праз ляніва сабаку\./,
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Text Encoding Brute Force",
|
||||
|
|
Loading…
Reference in New Issue