Skip to content

Commit 19bec6d

Browse files
committed
fix: merge gui to community
1 parent 813b1e0 commit 19bec6d

File tree

22 files changed

+1955
-12
lines changed

22 files changed

+1955
-12
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
exempt=[
2+
"class{^(?!(dev\\/skidfuscator)).*$}",
3+
"class{^jghost\\/}",
4+
"class{Dump}",
5+
"class{FrameComputer}",
6+
"class{util}",
7+
"class{PredicateFactory}"
8+
]
9+
flowCondition {
10+
enabled=true
11+
}
12+
flowException {
13+
enabled=true
14+
strength=AGGRESSIVE
15+
}
16+
flowRange {
17+
enabled=true
18+
}
19+
native {
20+
enabled=false
21+
}
22+
numberEncryption {
23+
enabled=true
24+
}
25+
stringEncryption {
26+
enabled=true
27+
type=STANDARD
28+
}

dev.skidfuscator.client.standalone/src/main/java/dev/skidfuscator/obfuscator/SkidfuscatorMain.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import dev.skidfuscator.obfuscator.command.HelpCommand;
44
import dev.skidfuscator.obfuscator.command.MappingsCommand;
55
import dev.skidfuscator.obfuscator.command.ObfuscateCommand;
6+
import dev.skidfuscator.obfuscator.gui.MainFrame;
67
import dev.skidfuscator.obfuscator.util.LogoUtil;
78
import lombok.SneakyThrows;
89
import org.jline.reader.EndOfFileException;
@@ -13,13 +14,31 @@
1314
import org.jline.terminal.TerminalBuilder;
1415
import picocli.CommandLine;
1516

17+
import javax.swing.*;
1618
import java.io.File;
1719

1820
public class SkidfuscatorMain {
1921

2022
@SneakyThrows
2123
public static void main(String[] args) {
2224

25+
if (args.length == 0) {
26+
SwingUtilities.invokeLater(() -> {
27+
try {
28+
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
29+
} catch (Exception e) {
30+
e.printStackTrace();
31+
}
32+
new MainFrame().setVisible(true);
33+
});
34+
return;
35+
}
36+
37+
final String[] logo = LogoUtil.getLogo();
38+
for (String line : logo) {
39+
System.out.println(line);
40+
}
41+
2342
if (args.length == 1 && args[0].equalsIgnoreCase("cli")) {
2443
final LineReader reader = LineReaderBuilder
2544
.builder()
@@ -72,7 +91,6 @@ public static void main(String[] args) {
7291
}
7392

7493
} else {
75-
LogoUtil.printLogo();
7694
new CommandLine(new HelpCommand())
7795
.addSubcommand("obfuscate", new ObfuscateCommand())
7896
.addSubcommand("mappings", new MappingsCommand())

dev.skidfuscator.client.standalone/src/main/java/dev/skidfuscator/obfuscator/command/ObfuscateCommand.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,61 +31,61 @@ public class ObfuscateCommand implements Callable<Integer> {
3131
index = "0",
3232
description = "The file which will be obfuscated."
3333
)
34-
private File input;
34+
public File input;
3535

3636
@CommandLine.Option(
3737
names = {"-rt", "--runtime"},
3838
description = "Path to the runtime jar"
3939
)
40-
private File runtime;
40+
public File runtime;
4141

4242
@CommandLine.Option(
4343
names = {"-li", "--libs"},
4444
description = "Path to the libs folder"
4545
)
46-
private File libFolder;
46+
public File libFolder;
4747

4848
@CommandLine.Option(
4949
names = {"-ex", "--exempt"},
5050
description = "Path to the exempt file"
5151
)
52-
private File exempt;
52+
public File exempt;
5353

5454
@CommandLine.Option(
5555
names = {"-o", "--output"},
5656
description = "Path to the output jar location"
5757
)
58-
private File output;
58+
public File output;
5959

6060
@CommandLine.Option(
6161
names = {"-cfg", "--config"},
6262
description = "Path to the config file"
6363
)
64-
private File config;
64+
public File config;
6565

6666
@CommandLine.Option(
6767
names = {"-ph", "--phantom"},
6868
description = "Declare if phantom computation should be used"
6969
)
70-
private boolean phantom;
70+
public boolean phantom;
7171

7272
@CommandLine.Option(
7373
names = {"-fuckit", "--fuckit"},
7474
description = "Do not use!"
7575
)
76-
private boolean fuckit;
76+
public boolean fuckit;
7777

7878
@CommandLine.Option(
7979
names = {"-dbg", "--debug"},
8080
description = "Do not use!"
8181
)
82-
private boolean debug;
82+
public boolean debug;
8383

8484
@CommandLine.Option(
8585
names = {"-notrack", "--notrack"},
8686
description = "If you do not wish to be part of analytics!"
8787
)
88-
private boolean notrack;
88+
public boolean notrack;
8989

9090

9191
@Override
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
package dev.skidfuscator.obfuscator.config;
2+
3+
import com.typesafe.config.*;
4+
import java.util.*;
5+
import java.util.stream.Collectors;
6+
7+
/**
8+
* Configuration generator for Skidfuscator transformers.
9+
* Handles HOCON configuration generation using Lightbend Config library.
10+
*/
11+
public class SkidfuscatorConfig {
12+
private final Map<String, ConfigValue> configMap = new HashMap<>();
13+
14+
/**
15+
* Adds a transformer configuration block.
16+
* @param name Transformer name
17+
* @param enabled Enabled state
18+
* @param options Additional transformer options
19+
* @param exemptions List of exemption patterns
20+
*/
21+
public void addTransformer(String name, boolean enabled, Map<String, Object> options, List<String> exemptions) {
22+
Map<String, Object> transformerConfig = new HashMap<>();
23+
transformerConfig.put("enabled", enabled);
24+
25+
if (options != null && !options.isEmpty()) {
26+
transformerConfig.putAll(options);
27+
}
28+
29+
if (exemptions != null && !exemptions.isEmpty()) {
30+
transformerConfig.put("exempt", exemptions);
31+
}
32+
33+
configMap.put(name, ConfigValueFactory.fromMap(transformerConfig));
34+
}
35+
36+
/**
37+
* Sets global exemptions for the obfuscator.
38+
* @param exemptions List of global exemption patterns
39+
*/
40+
public void setGlobalExemptions(List<String> exemptions) {
41+
if (exemptions != null && !exemptions.isEmpty()) {
42+
configMap.put("exempt", ConfigValueFactory.fromIterable(exemptions));
43+
}
44+
}
45+
46+
/**
47+
* Sets library dependencies for the obfuscator.
48+
* @param libraries List of library paths
49+
*/
50+
public void setLibraries(List<String> libraries) {
51+
if (libraries != null && !libraries.isEmpty()) {
52+
configMap.put("libraries", ConfigValueFactory.fromIterable(libraries));
53+
}
54+
}
55+
56+
/**
57+
* Generates the final Config object.
58+
* @return Config object containing all settings
59+
*/
60+
public Config generateConfig() {
61+
return ConfigFactory.parseMap(configMap);
62+
}
63+
64+
/**
65+
* Renders the configuration as a HOCON string.
66+
* @return Formatted HOCON configuration string
67+
*/
68+
public String renderConfig() {
69+
return generateConfig().root().render(
70+
ConfigRenderOptions.defaults()
71+
.setOriginComments(false)
72+
.setComments(true)
73+
.setFormatted(true)
74+
.setJson(false)
75+
);
76+
}
77+
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
package dev.skidfuscator.obfuscator.gui;
2+
3+
import dev.skidfuscator.obfuscator.Skidfuscator;
4+
import dev.skidfuscator.obfuscator.SkidfuscatorSession;
5+
import javax.swing.*;
6+
import java.awt.*;
7+
import java.io.File;
8+
9+
public class ActionPanel extends JPanel {
10+
private final MainFrame mainFrame;
11+
private final JTextArea logArea;
12+
private final JButton startButton;
13+
14+
public ActionPanel(MainFrame mainFrame) {
15+
this.mainFrame = mainFrame;
16+
setLayout(new BorderLayout(5, 5));
17+
setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
18+
19+
// Create log area
20+
logArea = new JTextArea(10, 50);
21+
logArea.setEditable(false);
22+
JScrollPane scrollPane = new JScrollPane(logArea);
23+
add(scrollPane, BorderLayout.CENTER);
24+
25+
// Create button panel
26+
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
27+
startButton = new JButton("Start Obfuscation");
28+
startButton.addActionListener(e -> startObfuscation());
29+
buttonPanel.add(startButton);
30+
add(buttonPanel, BorderLayout.SOUTH);
31+
}
32+
33+
public void startObfuscation() {
34+
ConfigPanel config = mainFrame.getConfigPanel();
35+
TransformerPanel transformers = mainFrame.getTransformerPanel();
36+
37+
// Validate inputs
38+
if (config.getInputPath().isEmpty()) {
39+
JOptionPane.showMessageDialog(this, "Please select an input JAR file", "Error", JOptionPane.ERROR_MESSAGE);
40+
return;
41+
}
42+
43+
// Create session
44+
SkidfuscatorSession session = SkidfuscatorSession.builder()
45+
.input(new File(config.getInputPath()))
46+
.output(new File(config.getOutputPath()))
47+
.libs(config.getLibsPath().isEmpty()
48+
? new File[0]
49+
: new File(config.getLibsPath()).listFiles()
50+
)
51+
.runtime(config.getRuntimePath().isEmpty()
52+
? null
53+
: new File(config.getRuntimePath())
54+
)
55+
.phantom(false)
56+
.debug(config.isDebugEnabled())
57+
.build();
58+
59+
// Start obfuscation in background
60+
startButton.setEnabled(false);
61+
SwingWorker<Void, String> worker = new SwingWorker<>() {
62+
@Override
63+
protected Void doInBackground() {
64+
try {
65+
new Skidfuscator(session).run();
66+
} catch (Exception e) {
67+
SwingUtilities.invokeLater(() -> {
68+
logArea.append("Error: " + e.getMessage() + "\n");
69+
e.printStackTrace();
70+
});
71+
}
72+
return null;
73+
}
74+
75+
@Override
76+
protected void done() {
77+
startButton.setEnabled(true);
78+
logArea.append("Obfuscation completed!\n");
79+
}
80+
};
81+
worker.execute();
82+
}
83+
}

0 commit comments

Comments
 (0)