mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 14:56:19 -04:00
Began implementing UTF-16 support in the 'Strings' operation.
This commit is contained in:
parent
0ba28dc891
commit
56551712d6
9 changed files with 363 additions and 289 deletions
|
@ -1,3 +1,6 @@
|
|||
import XRegExp from "xregexp";
|
||||
|
||||
|
||||
/**
|
||||
* Identifier extraction operations.
|
||||
*
|
||||
|
@ -49,6 +52,11 @@ const Extract = {
|
|||
* @default
|
||||
*/
|
||||
DISPLAY_TOTAL: false,
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
ENCODING_LIST: ["All", "Single byte", "16-bit littleendian", "16-bit bigendian"],
|
||||
|
||||
/**
|
||||
* Strings operation.
|
||||
|
@ -58,10 +66,27 @@ const Extract = {
|
|||
* @returns {string}
|
||||
*/
|
||||
runStrings: function(input, args) {
|
||||
let minLen = args[0] || Extract.MIN_STRING_LEN,
|
||||
const minLen = args[0] || Extract.MIN_STRING_LEN,
|
||||
displayTotal = args[1],
|
||||
strings = "[A-Z\\d/\\-:.,_$%'\"()<>= !\\[\\]{}@]",
|
||||
regex = new RegExp(strings + "{" + minLen + ",}", "ig");
|
||||
encoding = args[2];
|
||||
let strings = "[A-Z\\d/\\-:.,_$%'\"()<>= !\\[\\]{}@]";
|
||||
|
||||
switch (encoding) {
|
||||
case "All":
|
||||
strings = "(\x00?" + strings + "\x00?)";
|
||||
break;
|
||||
case "16-bit littleendian":
|
||||
strings = "(" + strings + "\x00)";
|
||||
break;
|
||||
case "16-bit bigendian":
|
||||
strings = "(\x00" + strings + ")";
|
||||
break;
|
||||
case "Single byte":
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
const regex = new XRegExp(strings + "{" + minLen + ",}", "ig");
|
||||
|
||||
return Extract._search(input, regex, null, displayTotal);
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue