Skip to content

Commit 0bc4737

Browse files
authored
Merge pull request #14 from 0x1Avram/dev
add transpilation message for esprima incompatible input; stringarray…
2 parents 8c89edb + 64d6f4c commit 0bc4737

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

Stages/stage_03_stringarray.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -1267,7 +1267,8 @@ class StringArrayCallsReplacer{
12671267
}
12681268
firstNode = false;
12691269

1270-
if((node.type == 'Identifier') && (node.name == wrapperName) && (parent.type == 'VariableDeclarator')){
1270+
if((node.type == 'Identifier') && (node.name == wrapperName)
1271+
&& (parent.type == 'VariableDeclarator') && (parent.id.name == wrapperName)){
12711272
foundRedefined = true;
12721273
this.break();
12731274
}
@@ -1328,7 +1329,12 @@ class StringArrayCallsReplacer{
13281329
node = parent;
13291330
}while(parent.type != 'Program');
13301331

1331-
return false;
1332+
if(parent == wrapperLexicalScope){
1333+
return true;
1334+
}
1335+
else{
1336+
return false;
1337+
}
13321338
}
13331339

13341340
_removeVariableDeclaratorWrappers(wrappers){

deobfuscator.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,16 @@ class SourceCodeDeobfuscator{
2727
}
2828

2929
deobfuscate(){
30-
this._generateASTFromObfuscatedSourceCode();
30+
try{
31+
this._generateASTFromObfuscatedSourceCode();
32+
}
33+
catch(e){
34+
this.logger.error(`[deobfuscator.js] Error when transforming the input source code to AST.`
35+
+ ` This is an 'esprima' parser limitation and the code needs to be`
36+
+ ` transpiled to an esprima compatible version before passing it to`
37+
+ ` the deobfuscator. error = ${e}. Stack = ${e.stack}`);
38+
return '';
39+
}
3140
this._deobfuscateAST();
3241
this._generateSourceCodeFromDeobfuscatedAST();
3342
return this.deobfuscatedSourceCode;

0 commit comments

Comments
 (0)