Skip to content

Commit e59c7d4

Browse files
authored
Merge pull request #7 from Col-E/master
Adding JavaFX variant / Move to Maven compilation
2 parents 64ae0f1 + 8ad7552 commit e59c7d4

25 files changed

+2289
-848
lines changed

.classpath

Lines changed: 0 additions & 6 deletions
This file was deleted.

.gitignore

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
/bin/
2-
3-
.settings/
4-
/output/
2+
/lib/
3+
/test/
4+
/output/
5+
/target/
6+
/.metadata/
7+
.settings/
8+
9+
.classpath
10+
.project
11+
12+
*/.project

.project

Lines changed: 0 additions & 17 deletions
This file was deleted.

README.md

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
1-
[![latest release](https://img.shields.io/github/release/java-deobfuscator/deobfuscator-gui.svg?label=latest%20release)](https://github.com/java-deobfuscator/deobfuscator-gui/releases/latest)
2-
# deobfuscator-gui
3-
An awesome GUI for an awesome deobfuscator
1+
# deobfuscator-gui [![latest release](https://img.shields.io/github/release/java-deobfuscator/deobfuscator-gui.svg?label=latest%20release)](https://github.com/java-deobfuscator/deobfuscator-gui/releases/latest)
42

5-
## What is Deobfuscator-GUI?
6-
Deobfuscator-GUI is a GUI for the deobfuscator located at https://github.com/java-deobfuscator/deobfuscator.
3+
A GUI for a the popular [java-deobfuscator](https://github.com/java-deobfuscator/deobfuscator).
74

8-
It plans to make deobfuscating simple by having a UI, instead of having to deal with it from the command line.
5+
## What is Deobfuscator-GUI?
6+
Deobfuscator-GUI is a GUI for the command line deobfuscator. User interfaces are more intuitive to the average user, allowing more people to use the tool without needing to concern themselves with syntax or configuration files.
97

10-
I currently use WindowBuilder to create the GUI: https://eclipse.org/windowbuilder/
8+
There are two variants in the repository, one for *Swing* and another for *JavaFX (default)*.
119

12-
Any issues, suggestions, or pull requests are very welcome!
10+
## How to Use
11+
1. Download the deobfuscator.jar from https://github.com/java-deobfuscator/deobfuscator.
12+
2. Download or build the GUI:
13+
* Download: [releases](https://github.com/java-deobfuscator/deobfuscator-gui/releases/latest)
14+
* Build: Clone the repository then run `mvn package`
15+
3. Run the GUI for either varient:
16+
* JavaFX: Select the `input` and `output` fields, select your transformers from the list, then click `run deobfuscator`
17+
* If `detect` is selected, `output` is not required. This mode will suggest transformers given some obfuscated `input`
18+
* Swing: Follow the instructions in the UI
19+
* Execute with `java -cp deobfuscator-gui.jar io.github.thistestuser.DeobfuscatorFrame`
1320

14-
NOTE: This issue tracker is only for things related to the GUI, not the deobfuscator.
21+
## Screenshots
1522

16-
## How to Use
17-
1. Download the GUI from the releases page. (https://github.com/java-deobfuscator/deobfuscator-gui/releases/latest)
18-
2. Download the deobfuscator.jar from https://github.com/java-deobfuscator/deobfuscator.
19-
3. Follow the program instructions.
23+
![javafx](javafx.png)
2024

21-
## TODO
22-
- [x] Select deobfuscator.jar
23-
- [x] Input and output jar selection
24-
- [x] Load and select transformers from deobfuscator jar (double text panels to fix order)
25-
- [x] A list of libraries that can be loaded (manageable with add, remove)
26-
- [x] Input and output command equivalent (that can be run via command prompt)
27-
- [x] A console that can be used to check errors
25+
![swing](swing.png)

javafx.png

34.7 KB
Loading

pom.xml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<modelVersion>4.0.0</modelVersion>
3+
<groupId>com.javadeobfuscator</groupId>
4+
<artifactId>deobfuscator-gui</artifactId>
5+
<url>https://github.com/java-deobfuscator/</url>
6+
<version>1.0</version>
7+
<name>deobfuscator-gui</name>
8+
<description>UI front-end for deobfuscator</description>
9+
<dependencies>
10+
<!-- Functionality -->
11+
<!-- EMPTY -->
12+
13+
<!--- User interface -->
14+
<!-- https://mvnrepository.com/artifact/org.controlsfx/controlsfx -->
15+
<dependency>
16+
<groupId>org.controlsfx</groupId>
17+
<artifactId>controlsfx</artifactId>
18+
<version>8.40.14</version>
19+
</dependency>
20+
</dependencies>
21+
<build>
22+
<sourceDirectory>src/java</sourceDirectory>
23+
<plugins>
24+
<plugin>
25+
<artifactId>maven-compiler-plugin</artifactId>
26+
<version>3.6.1</version>
27+
<configuration>
28+
<source>1.8</source>
29+
<target>1.8</target>
30+
</configuration>
31+
</plugin>
32+
<plugin>
33+
<artifactId>maven-assembly-plugin</artifactId>
34+
<executions>
35+
<execution>
36+
<phase>package</phase>
37+
<goals>
38+
<goal>single</goal>
39+
</goals>
40+
</execution>
41+
</executions>
42+
<configuration>
43+
<archive>
44+
<manifest>
45+
<mainClass>com.javadeobfuscator.deobfuscator.ui.FxWindow</mainClass>
46+
</manifest>
47+
</archive>
48+
<descriptorRefs>
49+
<descriptorRef>jar-with-dependencies</descriptorRef>
50+
</descriptorRefs>
51+
</configuration>
52+
</plugin>
53+
</plugins>
54+
</build>
55+
</project>
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
package com.javadeobfuscator.deobfuscator.ui;
2+
3+
import java.io.PrintStream;
4+
5+
import javax.swing.JOptionPane;
6+
7+
import org.controlsfx.control.ListSelectionView;
8+
import org.controlsfx.control.Notifications;
9+
10+
import com.javadeobfuscator.deobfuscator.ui.component.ConfigProperties;
11+
import com.javadeobfuscator.deobfuscator.ui.wrap.Deobfuscator;
12+
import com.javadeobfuscator.deobfuscator.ui.wrap.Transformers;
13+
import com.javadeobfuscator.deobfuscator.ui.wrap.WrapperFactory;
14+
15+
import javafx.application.Application;
16+
import javafx.application.Platform;
17+
import javafx.event.ActionEvent;
18+
import javafx.event.EventHandler;
19+
import javafx.scene.Scene;
20+
import javafx.scene.control.*;
21+
import javafx.scene.layout.*;
22+
import javafx.stage.*;
23+
import javafx.util.Duration;
24+
25+
public class FxWindow extends Application {
26+
public static void main(String[] args) {
27+
launch(args);
28+
}
29+
30+
private Deobfuscator deob;
31+
private Transformers trans;
32+
33+
@Override
34+
public void start(Stage stage) {
35+
loadWrappers();
36+
stage.setTitle("Deobfuscator GUI");
37+
VBox root = new VBox();
38+
ConfigProperties props = new ConfigProperties(deob.getConfig().get());
39+
TitledPane wrapper1 = new TitledPane("Configuration options", props);
40+
// listview to display selected transformers
41+
ListSelectionView<Class<?>> selectedTransformers = new ListSelectionView<>();
42+
selectedTransformers.setCellFactory(p -> new ListCell<Class<?>>() {
43+
@Override
44+
protected void updateItem(Class<?> item, boolean empty) {
45+
super.updateItem(item, empty);
46+
if (empty || item == null) {
47+
setText(null);
48+
} else {
49+
String name = item.getName();
50+
int index = "com.javadeobfuscator.deobfuscator.transformers.".length();
51+
setText(name.substring(index));
52+
}
53+
}
54+
});
55+
selectedTransformers.getSourceItems().addAll(trans.getTransformers());
56+
TitledPane wrapper2 = new TitledPane("Transformers", selectedTransformers);
57+
// log
58+
ListView<String> logging = new ListView<>();
59+
TitledPane wrapper3 = new TitledPane("Logging", logging);
60+
int size = 140;
61+
// wrapper3.setMaxHeight(size);
62+
logging.setPrefHeight(size);
63+
logging.setCellFactory(p -> new ListCell<String>() {
64+
@Override
65+
protected void updateItem(String item, boolean empty) {
66+
super.updateItem(item, empty);
67+
if (empty || item == null) {
68+
setText(null);
69+
} else {
70+
setText(item);
71+
}
72+
}
73+
});
74+
// It cant fill to the bottom by itself...
75+
// This is "good enough"
76+
stage.heightProperty().addListener(i -> {
77+
double y = logging.getLayoutY();
78+
double end = stage.getHeight();
79+
double diff = (end - y) / 3.4;
80+
logging.setPrefHeight(diff);
81+
wrapper3.setPrefHeight(diff);
82+
});
83+
PrintStream ps = new PrintStream(System.out, true) {
84+
@Override
85+
public void println(String line) {
86+
if (line.contains(" - ")) {
87+
line = line.substring(line.indexOf(" - ") + 3);
88+
}
89+
String newValue = line;
90+
// ensure updates are done on the JavaFX thread
91+
Platform.runLater(() -> {
92+
logging.getItems().add(newValue);
93+
int size = logging.getItems().size();
94+
logging.scrollTo(size - 1);
95+
if (size > 100) {
96+
logging.getItems().remove(0);
97+
}
98+
});
99+
super.println(line);
100+
}
101+
};
102+
deob.hookLogging(ps);
103+
// button to run the deobfuscator
104+
HBox hbox = new HBox();
105+
Button btnRun = new Button("Run deobfuscator");
106+
btnRun.setOnAction(new EventHandler<ActionEvent>() {
107+
@Override
108+
public void handle(ActionEvent event) {
109+
logging.getItems().clear();
110+
new Thread() {
111+
@Override
112+
public void run() {
113+
try {
114+
deob.getConfig().setTransformers(trans, selectedTransformers.getTargetItems());
115+
deob.run();
116+
} catch (Exception e) {
117+
e.printStackTrace();
118+
fatalFX("Failed execution", e.toString());
119+
}
120+
}
121+
}.start();
122+
}
123+
});
124+
hbox.getChildren().add(btnRun);
125+
btnRun.setMaxWidth(Double.MAX_VALUE);
126+
btnRun.getStyleClass().add("click");
127+
HBox.setHgrow(btnRun, Priority.ALWAYS);
128+
root.getChildren().add(wrapper1);
129+
root.getChildren().add(wrapper2);
130+
root.getChildren().add(hbox);
131+
root.getChildren().add(wrapper3);
132+
Scene scene = new Scene(root, 700, 820);
133+
scene.getStylesheets().add("style.css");
134+
stage.setScene(scene);
135+
stage.show();
136+
}
137+
138+
/**
139+
* Load wrappers
140+
*/
141+
private void loadWrappers() {
142+
WrapperFactory.setupJarLoader(false);
143+
deob = WrapperFactory.getDeobfuscator();
144+
trans = WrapperFactory.getTransformers();
145+
if (deob == null || trans == null) {
146+
fatalSwing("Failed to locate Deobfuscator jar",
147+
"Please ensure that JavaDeobfuscator is located adjacent to this program.");
148+
}
149+
}
150+
151+
/**
152+
* Display error message notification.
153+
*
154+
* @param title
155+
* @param text
156+
*/
157+
public static void fatalSwing(String title, String text) {
158+
text += "\nEnsure that you have JavaDeobfuscator in the same directory as this tool.";
159+
// Reverting back to Swing since JavaFX isn't up and running when this is called.
160+
JOptionPane.showMessageDialog(null, text, title, JOptionPane.ERROR_MESSAGE);
161+
System.exit(0);
162+
}
163+
164+
/**
165+
* Display error message notification.
166+
*
167+
* @param title
168+
* @param text
169+
*/
170+
public static void fatalFX(String title, String text) {
171+
//@formatter:off
172+
Duration time = Duration.seconds(5);
173+
Notifications.create()
174+
.title("Error: " + title)
175+
.text(text)
176+
.hideAfter(time).showError();
177+
//@formatter:on
178+
}
179+
}

0 commit comments

Comments
 (0)