mirror of
https://github.com/gchq/CyberChef
synced 2025-01-27 03:35:02 +00:00
Fixed the replace statements
This commit is contained in:
parent
2a7c0252a0
commit
9c5f06101e
1 changed files with 16 additions and 18 deletions
|
@ -219,24 +219,25 @@ const VBE = {
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
decode: function (data) {
|
decode: function (data) {
|
||||||
let result = "";
|
let result = [];
|
||||||
let index = -1;
|
let index = -1;
|
||||||
data = data.replace("@&", String.fromCharCode(10));
|
data = data.split("@&").join(String.fromCharCode(10));
|
||||||
data = data.replace("@#", String.fromCharCode(13));
|
data = data.split("@#").join(String.fromCharCode(13));
|
||||||
data = data.replace("@*", ">");
|
data = data.split("@*").join(">");
|
||||||
data = data.replace("@!", "<");
|
data = data.split("@!").join("<");
|
||||||
data = data.replace("@$", "@");
|
data = data.split("@$").join("@");
|
||||||
for (let i = 0; i < data.length; i++) {
|
for (let i = 0; i < data.length; i++) {
|
||||||
let byte = data.charCodeAt(i);
|
let byte = data.charCodeAt(i);
|
||||||
if (byte < 128){
|
let char = data.charAt(i);
|
||||||
|
if (byte < 128) {
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
if ((9 === byte || 31 < byte && 128 > byte) && 60 !== byte && 62 !== byte && 64 !== byte) {
|
if ((byte === 9 || byte > 31 && byte < 128) && byte !== 60 && byte !== 62 && byte !== 64) {
|
||||||
let char = VBE.D_DECODE[byte].charAt([VBE.D_COMBINATION[index % 64]]);
|
char = VBE.D_DECODE[byte].charAt([VBE.D_COMBINATION[index % 64]]);
|
||||||
result = result.concat(char);
|
|
||||||
}
|
}
|
||||||
|
result.push(char);
|
||||||
}
|
}
|
||||||
return result;
|
return result.join("");
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -245,13 +246,10 @@ const VBE = {
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
runDecodeVBE: function (data, args) {
|
runDecodeVBE: function (data, args) {
|
||||||
let matcher = /#@~\^......==(.+)......==\^#~@/,
|
let matcher = /#@~\^......==(.+)......==\^#~@/;
|
||||||
result = "",
|
let encodedData = matcher.exec(data);
|
||||||
encodedData;
|
console.log(encodedData[1]);
|
||||||
while ((encodedData = matcher.exec(data))) {
|
return VBE.decode(encodedData[1]);
|
||||||
result = result.concat(VBE.decode(encodedData[1]));
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue