2
2
3
3
import java .io .*;
4
4
import java .lang .reflect .Constructor ;
5
+ import java .lang .reflect .Field ;
5
6
import java .lang .reflect .Method ;
7
+ import java .util .Map ;
8
+ import java .util .Set ;
6
9
7
10
import com .javadeobfuscator .deobfuscator .ui .util .*;
8
11
@@ -15,6 +18,10 @@ public class Deobfuscator {
15
18
* Config wrapper to use in deobfuscator.
16
19
*/
17
20
private Config config ;
21
+ /**
22
+ * The deobfuscator instance.
23
+ */
24
+ private Object instance ;
18
25
19
26
Deobfuscator (ByteLoader loader ) {
20
27
this .loader = loader ;
@@ -62,10 +69,53 @@ public void run() throws Exception {
62
69
Config conf = getConfig ();
63
70
Constructor <?> con = main .getDeclaredConstructor (conf .get ().getClass ());
64
71
Object deob = con .newInstance (conf .get ());
72
+ instance = deob ;
65
73
Method start = main .getMethod ("start" );
66
74
start .invoke (deob );
67
75
}
68
76
77
+ /**
78
+ * Clears the classes in the main deobfuscator class.
79
+ *
80
+ * @throws Exception
81
+ * Thrown for any failure in the deobfuscator.
82
+ */
83
+ public void clearClasses ()
84
+ {
85
+ try
86
+ {
87
+ if (instance != null )
88
+ {
89
+ Class <?> main = loader .findClass ("com.javadeobfuscator.deobfuscator.Deobfuscator" );
90
+ Field cp = main .getDeclaredField ("classpath" );
91
+ cp .setAccessible (true );
92
+ ((Map <?, ?>)cp .get (instance )).clear ();
93
+ Field c = main .getDeclaredField ("classes" );
94
+ c .setAccessible (true );
95
+ ((Map <?, ?>)c .get (instance )).clear ();
96
+ Field h = main .getDeclaredField ("hierachy" );
97
+ h .setAccessible (true );
98
+ ((Map <?, ?>)h .get (instance )).clear ();
99
+ Field ip = main .getDeclaredField ("inputPassthrough" );
100
+ ip .setAccessible (true );
101
+ ((Map <?, ?>)ip .get (instance )).clear ();
102
+ Field cps = main .getDeclaredField ("constantPools" );
103
+ cps .setAccessible (true );
104
+ ((Map <?, ?>)cps .get (instance )).clear ();
105
+ Field r = main .getDeclaredField ("readers" );
106
+ r .setAccessible (true );
107
+ ((Map <?, ?>)r .get (instance )).clear ();
108
+ Field lc = main .getDeclaredField ("libraryClassnodes" );
109
+ lc .setAccessible (true );
110
+ ((Set <?>)lc .get (instance )).clear ();
111
+ instance = null ;
112
+ }
113
+ }catch (Exception e )
114
+ {
115
+ e .printStackTrace ();
116
+ }
117
+ }
118
+
69
119
/**
70
120
* Intercept logging calls.
71
121
*
0 commit comments