-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhangul_js_attack.js
41 lines (33 loc) · 966 Bytes
/
hangul_js_attack.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
function convertToHangul(str) {
var hangulHalfWidth = "\uffa0";
var hangulFullWidth = "\u3164";
let result = "";
for (let i = 0; i < str.length; i++) {
const char = str.charAt(i);
const binary = char.charCodeAt(0).toString(2).padStart(8, "0");
result += binary
.replace(/0/g, hangulHalfWidth)
.replace(/1/g, hangulFullWidth);
}
return result;
}
const payload = `
console.log("Hello world");
`;
const obfuscatedPayload = convertToHangul(payload);
const trojanObj = {
code: obfuscatedPayload,
};
function decodeHangul(str) {
let result = str.replace(/\uffa0/g, "0").replace(/\u3164/g, "1");
console.log(result);
let decodedCode = "";
for (let i = 0; i < result.length; i += 8) {
const binary = result.slice(i, i + 8);
decodedCode += String.fromCharCode(parseInt(binary, 2));
}
return decodedCode;
}
console.log(trojanObj);
console.log(decodeHangul(trojanObj.code));
eval(decodeHangul(trojanObj.code));