This repository was archived by the owner on May 30, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +13
-9
lines changed Expand file tree Collapse file tree 5 files changed +13
-9
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 15
15
console . log ( result ) ;
16
16
} catch ( e ) {
17
17
console . error ( e ) ;
18
+ console . error ( e . stack ) ;
18
19
}
Original file line number Diff line number Diff line change @@ -214,10 +214,13 @@ export class FunctionControlFlow extends ProtectionBase {
214
214
|| Utils . isFunctionDeclaration ( node ) )
215
215
&& Utils . isBlockStatement ( node . body ) && node . body . body . length > 0 )
216
216
{
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 ;
221
224
if ( Utils . isIdentifier ( id ) && obj
222
225
&& Utils . isObjectExpression ( obj )
223
226
&& obj . properties . length > 0
@@ -227,7 +230,7 @@ export class FunctionControlFlow extends ProtectionBase {
227
230
const result = this . processProperties ( obj . properties ) ;
228
231
if ( Object . keys ( result ) . length > 0 ) {
229
232
this . data [ id . name ] = result ;
230
- this . decl [ id . name ] = firstStmt ;
233
+ this . decl [ id . name ] = stmt ;
231
234
}
232
235
}
233
236
}
Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ export class Deobfuscator {
55
55
if ( p . detect ( ) ) {
56
56
ast = p . remove ( ) ;
57
57
code = generate ( ast ) ;
58
+ ast = EspreeFacade . parse ( code , Deobfuscator . espreeParseOptions ) ;
58
59
}
59
60
}
60
61
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ export class StringArrayProtection extends ProtectionBase {
26
26
constructor ( code : string , ast : estree . Program ) {
27
27
super ( code , ast ) ;
28
28
}
29
-
29
+
30
30
detect ( ) : boolean {
31
31
this . active = false ;
32
32
if ( this . ast . body && this . ast . body . length > 0 && Utils . isVariableDeclaration ( this . ast . body [ 0 ] ) ) {
@@ -40,7 +40,7 @@ export class StringArrayProtection extends ProtectionBase {
40
40
assert ( Utils . isLiteral ( e ) ) ;
41
41
assert ( typeof ( < estree . Literal > e ) . value === 'string' ) ;
42
42
return ( < estree . Literal > e ) . value as string ;
43
- } ) ;
43
+ } ) ;
44
44
this . active = true ;
45
45
this . detectRotation ( ) ;
46
46
this . detectEncoding ( ) ;
@@ -80,7 +80,7 @@ export class StringArrayProtection extends ProtectionBase {
80
80
if ( decDecl . init . params . length === 2 ) {
81
81
const decFuncCode = Utils . cutCode ( this . code , decDecl . init ) ;
82
82
this . encoding = / \b a t o b \b / . test ( decFuncCode )
83
- ? ( / % (?: 0 x 1 0 0 | 2 5 6 ) \D / . test ( decFuncCode ) ? 'rc4' : 'base64' )
83
+ ? ( / % \s * (?: 0 x 1 0 0 | 2 5 6 ) \D / . test ( decFuncCode ) ? 'rc4' : 'base64' )
84
84
: 'none' ;
85
85
this . astDecoder = this . ast . body [ index ] as estree . Statement ;
86
86
this . decFuncName = decDecl . id . name ;
You can’t perform that action at this time.
0 commit comments