4
4
using PowerCrypt . Obfuscator . Methods . GeneralControlFlowPostOBF ;
5
5
using PowerCrypt . Settings ;
6
6
using Spectre . Console ;
7
+ using System . Diagnostics ;
7
8
using System . Management . Automation . Language ;
8
9
9
10
namespace PowerCrypt . Obfuscator . Passes
@@ -20,23 +21,48 @@ private static List<ReplacementMapUniversal> CollectReplacements(ScriptBlockAst
20
21
. Where ( stmt => ! stmt . FindAll ( inner => ( inner is IfStatementAst || inner is ForStatementAst || inner is ForEachStatementAst ) && inner != stmt , searchNestedScriptBlocks : true ) . Any ( ) &&
21
22
! stmt . FindAll ( inner => inner is ReturnStatementAst , searchNestedScriptBlocks : true ) . Any ( ) ) ;
22
23
23
- foreach ( var node in nodes )
24
+ foreach ( var function in Globals . FunctionNamesToSkip )
24
25
{
25
- if ( isFunction && ( ( FunctionDefinitionAst ) node ) . Name . Equals ( Globals . CompressFunctionName ) )
26
+ foreach ( var node in nodes )
26
27
{
27
- continue ;
28
- }
28
+ bool shouldSkip = false ;
29
29
30
- string obfuscatedText = WrapOBF . ObfuscateWithWrap ( node . Extent . Text ) ;
31
- allReplacements . Add ( new ReplacementMapUniversal
32
- {
33
- StartOffset = node . Extent . StartOffset ,
34
- Length = node . Extent . Text . Length ,
35
- OriginalName = node . Extent . Text ,
36
- Text = obfuscatedText ,
37
- Type = node . GetType ( ) . Name ,
38
- RequiresKeyword = false
39
- } ) ;
30
+ if ( isFunction && ( ( FunctionDefinitionAst ) node ) . Name . Equals ( Globals . CompressFunctionName ) )
31
+ {
32
+ continue ;
33
+ }
34
+
35
+ foreach ( var function2 in Globals . FunctionNamesToSkip )
36
+ {
37
+ if ( isFunction && ( ( FunctionDefinitionAst ) node ) . Name . Equals ( function2 ) )
38
+ {
39
+ Console . WriteLine ( ( ( FunctionDefinitionAst ) node ) . Name ) ;
40
+ shouldSkip = true ;
41
+ break ;
42
+ }
43
+ }
44
+
45
+ if ( shouldSkip )
46
+ {
47
+ continue ;
48
+ }
49
+
50
+ if ( isFunction )
51
+ {
52
+ Console . WriteLine ( ( ( FunctionDefinitionAst ) node ) . Name ) ;
53
+ }
54
+
55
+ string obfuscatedText = WrapOBF . ObfuscateWithWrap ( node . Extent . Text ) ;
56
+ allReplacements . Add ( new ReplacementMapUniversal
57
+ {
58
+ StartOffset = node . Extent . StartOffset ,
59
+ Length = node . Extent . Text . Length ,
60
+ OriginalName = node . Extent . Text ,
61
+ Text = obfuscatedText ,
62
+ Type = node . GetType ( ) . Name ,
63
+ RequiresKeyword = false
64
+ } ) ;
65
+ }
40
66
}
41
67
42
68
return allReplacements ;
@@ -84,4 +110,4 @@ public static string ProcessScript(string scriptContent)
84
110
return scriptContent ;
85
111
}
86
112
}
87
- }
113
+ }
0 commit comments