Skip to content
This repository was archived by the owner on May 30, 2024. It is now read-only.

Commit 054dd9f

Browse files
committed
fix
1 parent 176aaa2 commit 054dd9f

File tree

5 files changed

+13
-9
lines changed

5 files changed

+13
-9
lines changed

index.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ try {
1515
console.log(result);
1616
} catch (e) {
1717
console.error(e);
18+
console.error(e.stack);
1819
}

src/control-flow.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,13 @@ export class FunctionControlFlow extends ProtectionBase {
214214
|| Utils.isFunctionDeclaration(node))
215215
&& Utils.isBlockStatement(node.body) && node.body.body.length > 0)
216216
{
217-
const firstStmt = node.body.body[0];
218-
if (Utils.isVariableDeclaration(firstStmt)) {
219-
const id = firstStmt.declarations[0].id;
220-
const obj = firstStmt.declarations[0].init;
217+
for (let i = 0; i < node.body.body.length; ++i) {
218+
const stmt = node.body.body[i];
219+
if (!Utils.isVariableDeclaration(stmt)) {
220+
break;
221+
}
222+
const id = stmt.declarations[0].id;
223+
const obj = stmt.declarations[0].init;
221224
if (Utils.isIdentifier(id) && obj
222225
&& Utils.isObjectExpression(obj)
223226
&& obj.properties.length > 0
@@ -227,7 +230,7 @@ export class FunctionControlFlow extends ProtectionBase {
227230
const result = this.processProperties(obj.properties);
228231
if (Object.keys(result).length > 0) {
229232
this.data[id.name] = result;
230-
this.decl[id.name] = firstStmt;
233+
this.decl[id.name] = stmt;
231234
}
232235
}
233236
}

src/deobfuscator.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export class Deobfuscator {
5555
if (p.detect()) {
5656
ast = p.remove();
5757
code = generate(ast);
58+
ast = EspreeFacade.parse(code, Deobfuscator.espreeParseOptions);
5859
}
5960
}
6061

src/string-array.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export class StringArrayProtection extends ProtectionBase {
2626
constructor(code: string, ast: estree.Program) {
2727
super(code, ast);
2828
}
29-
29+
3030
detect(): boolean {
3131
this.active = false;
3232
if (this.ast.body && this.ast.body.length > 0 && Utils.isVariableDeclaration(this.ast.body[0])) {
@@ -40,7 +40,7 @@ export class StringArrayProtection extends ProtectionBase {
4040
assert(Utils.isLiteral(e));
4141
assert(typeof (<estree.Literal> e).value === 'string');
4242
return (<estree.Literal> e).value as string;
43-
});
43+
});
4444
this.active = true;
4545
this.detectRotation();
4646
this.detectEncoding();
@@ -80,7 +80,7 @@ export class StringArrayProtection extends ProtectionBase {
8080
if (decDecl.init.params.length === 2) {
8181
const decFuncCode = Utils.cutCode(this.code, decDecl.init);
8282
this.encoding = /\batob\b/.test(decFuncCode)
83-
? (/%(?:0x100|256)\D/.test(decFuncCode) ? 'rc4' : 'base64')
83+
? (/%\s*(?:0x100|256)\D/.test(decFuncCode) ? 'rc4' : 'base64')
8484
: 'none';
8585
this.astDecoder = this.ast.body[index] as estree.Statement;
8686
this.decFuncName = decDecl.id.name;

0 commit comments

Comments
 (0)