I am trying to convert some obfuscated js code using shift-ast.
I want to replace some CallExpressions with their string values.
So far I’ve been able to get the strings that I should use for the replacement in a stringArray by using the shift-refactor library.
I also have an array of all callExpressions names that I want to replace.
Here is a sample of the code:
function O(t, e) {
var n = 392,
r = 584,
o = 407,
i = 867,
a = 392,
c = 584,
u = 867,
s = 633,
f = 985,
l = 532,
p = 392,
h = 584,
v = 631,
d = 988,
g = 1020,
m = 677,
y = I,
b = Object[y(735)](t);
if (Object[y(n) + y(r) + y(o) + y(i)]) {
var w = Object[y(a) + y(c) + y(o) + y(u)](t);
e && (w = w[y(s)]((function(e) {
var n = y;
return Object[n(p) + n(h) + n(v) + n(d)](t, e)[n(g) + n(m)];
}))),
b[y(f)][y(l)](b, w);
}
return b;
}
The stringArray I mentioned before is the variable I that is assigned to y and n in this sample code. I want to get the callExpressions y() and n().
I am struggling with how to ensure any replacements are in scope because the varaibleDeclarations use the same names. Finally I want to concatenate all strings that have the + sign.
I’ve tried to read up on shift-parser, shift-template and shift-scope but I can’t quite put it all together.
Please help me with this example so I can know how to handle it.