X 归档 2020-09-02
Here is a nice little hack to hide code inside a #BigInt. The idea is use octal escape sequences and replace the backslash \ with the digit 9.
// the encoded `alert(1)`
x = 91419154914591629164950961951n;
// the decoder
[`'${x}'`.replace(/9/g, "\\")].map(eval).map(eval)
// the encoded `alert(1)`
x = 91419154914591629164950961951n;
// the decoder
[`'${x}'`.replace(/9/g, "\\")].map(eval).map(eval)
这里有一个很妙的小技巧,可以把代码藏进 #BigInt 里。思路是使用八进制转义序列,并把反斜杠 \ 替换成数字 9。
// 编码后的 `alert(1)`
x = 91419154914591629164950961951n;
// 解码器
[`'${x}'`.replace(/9/g, "\\")].map(eval).map(eval)
// 编码后的 `alert(1)`
x = 91419154914591629164950961951n;
// 解码器
[`'${x}'`.replace(/9/g, "\\")].map(eval).map(eval)

