1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
/*******************************************************************************
* Copyright (c) 2015 Jeff Martin.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser General Public
* License v3.0 which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl.html
*
* Contributors:
* Jeff Martin - initial API and implementation
******************************************************************************/
package cuchaz.enigma;
import cuchaz.enigma.analysis.ClassCache;
import cuchaz.enigma.analysis.index.JarIndex;
import cuchaz.enigma.network.EnigmaServer;
import cuchaz.enigma.source.Decompiler;
import cuchaz.enigma.source.Decompilers;
import cuchaz.enigma.source.SourceSettings;
import org.junit.BeforeClass;
import org.junit.Test;
import java.nio.file.Paths;
import static cuchaz.enigma.TestEntryFactory.newClass;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsInAnyOrder;
public class TestDeobfed {
private static Enigma enigma;
private static ClassCache classCache;
private static JarIndex index;
@BeforeClass
public static void beforeClass() throws Exception {
enigma = Enigma.create();
classCache = ClassCache.of(Paths.get("build/test-deobf/translation.jar"));
index = classCache.index(ProgressListener.none());
}
@Test
public void obfEntries() {
assertThat(index.getEntryIndex().getClasses(), containsInAnyOrder(
newClass("cuchaz/enigma/inputs/Keep"),
newClass("a"),
newClass("b"),
newClass("c"),
newClass("d"),
newClass("d$1"),
newClass("e"),
newClass("f"),
newClass("g"),
newClass("g$a"),
newClass("g$a$a"),
newClass("g$b"),
newClass("g$b$a"),
newClass("h"),
newClass("h$a"),
newClass("h$a$a"),
newClass("h$b"),
newClass("h$b$a"),
newClass("h$b$a$a"),
newClass("h$b$a$b"),
newClass("i"),
newClass("i$a"),
newClass("i$b")
));
}
@Test
public void decompile() {
EnigmaProject project = new EnigmaProject(enigma, classCache, index, new byte[EnigmaServer.CHECKSUM_SIZE]);
Decompiler decompiler = Decompilers.PROCYON.create(project.getClassCache(), new SourceSettings(false, false));
decompiler.getSource("a");
decompiler.getSource("b");
decompiler.getSource("c");
decompiler.getSource("d");
decompiler.getSource("d$1");
decompiler.getSource("e");
decompiler.getSource("f");
decompiler.getSource("g");
decompiler.getSource("g$a");
decompiler.getSource("g$a$a");
decompiler.getSource("g$b");
decompiler.getSource("g$b$a");
decompiler.getSource("h");
decompiler.getSource("h$a");
decompiler.getSource("h$a$a");
decompiler.getSource("h$b");
decompiler.getSource("h$b$a");
decompiler.getSource("h$b$a$a");
decompiler.getSource("h$b$a$b");
decompiler.getSource("i");
decompiler.getSource("i$a");
decompiler.getSource("i$b");
}
}
|