Skip to content

Commit df506a8

Browse files
committed
Full fixes
1 parent 39a1227 commit df506a8

131 files changed

Lines changed: 5765 additions & 1405 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,9 @@ hs_err_pid*
8686
*/.DS_Store
8787
*/mappings/
8888
dev.skidfuscator.obfuscator/calculations.txt
89+
90+
dev.skidfuscator.obfuscator/src/test/resources/test.jar.compressed
91+
92+
dev.skidfuscator.obfuscator/src/test/resources/test.jar.compressed.json
93+
94+
dev.skidfuscator.obfuscator/src/test/resources/test.jar.compressed.skid

dev.skidfuscator.annotations/src/main/java/dev/skidfuscator/annotations/Exclude.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88
@Target({ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.TYPE})
99
@Retention(RetentionPolicy.CLASS)
1010
public @interface Exclude {
11+
1112
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package dev.skidfuscator.annotations;
2+
3+
import java.lang.annotation.Retention;
4+
import java.lang.annotation.Target;
5+
6+
import static java.lang.annotation.ElementType.METHOD;
7+
import static java.lang.annotation.RetentionPolicy.CLASS;
8+
9+
@Retention(CLASS)
10+
@Target(METHOD)
11+
public @interface NativeObfuscation {
12+
}

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package dev.skidfuscator.obfuscator;
22

3+
import dev.skidfuscator.obfuscator.command.HelpCommand;
34
import dev.skidfuscator.obfuscator.command.ObfuscateCommand;
45
import lombok.SneakyThrows;
56
import org.jline.reader.EndOfFileException;
@@ -49,10 +50,14 @@ public static void main(String[] args) {
4950
null,
5051
null,
5152
null,
53+
null,
5254
new File(System.getProperty("java.home"), "lib/rt.jar"),
5355
false,
5456
false,
5557
false,
58+
false,
59+
false,
60+
false,
5661
false
5762
);
5863

@@ -62,7 +67,8 @@ public static void main(String[] args) {
6267
}
6368

6469
} else {
65-
new CommandLine(new ObfuscateCommand())
70+
new CommandLine(new HelpCommand())
71+
.addSubcommand("obfuscate", new ObfuscateCommand())
6672
.execute(args);
6773
}
6874
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package dev.skidfuscator.obfuscator.command;
2+
3+
import picocli.CommandLine;
4+
5+
import java.util.concurrent.Callable;
6+
7+
@CommandLine.Command(
8+
aliases = "help",
9+
mixinStandardHelpOptions = true,
10+
version = "help 1.0.0",
11+
description = "Shows all the options"
12+
)
13+
public class HelpCommand implements Callable<Integer> {
14+
@Override
15+
public Integer call() throws Exception {
16+
System.out.println("Please run 'java -jar skidfuscator.jar obfuscate <input jar> [options here]' instead!");
17+
return 0;
18+
}
19+
}

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package dev.skidfuscator.obfuscator.command;
22

3+
import dev.skidfuscator.migration.ExemptToConfigMigration;
34
import dev.skidfuscator.obfuscator.Skidfuscator;
45
import dev.skidfuscator.obfuscator.SkidfuscatorSession;
56
import dev.skidfuscator.obfuscator.util.ConsoleColors;
@@ -55,6 +56,12 @@ public class ObfuscateCommand implements Callable<Integer> {
5556
)
5657
private File output;
5758

59+
@CommandLine.Option(
60+
names = {"-cfg", "--config"},
61+
description = "Path to the config file"
62+
)
63+
private File config;
64+
5865
@CommandLine.Option(
5966
names = {"-ph", "--phantom"},
6067
description = "Declare if phantom computation should be used"
@@ -73,6 +80,12 @@ public class ObfuscateCommand implements Callable<Integer> {
7380
)
7481
private boolean notrack;
7582

83+
@CommandLine.Option(
84+
names = {"-re", "--renamer"},
85+
description = "Enables renamer for the obfuscation"
86+
)
87+
private boolean renamer;
88+
7689
@Override
7790
public Integer call() {
7891
/* Total number of processors or cores available to the JVM */
@@ -154,6 +167,28 @@ public Integer call() {
154167
);
155168
}
156169

170+
if (exempt != null) {
171+
final File converted = new File(exempt.getAbsolutePath()
172+
.substring(0, exempt.getAbsolutePath().lastIndexOf("/")) + "/config.hocon");
173+
final String warning = "\n" + ConsoleColors.YELLOW
174+
+ "██╗ ██╗ █████╗ ██████╗ ███╗ ██╗██╗███╗ ██╗ ██████╗ \n"
175+
+ "██║ ██║██╔══██╗██╔══██╗████╗ ██║██║████╗ ██║██╔════╝ \n"
176+
+ "██║ █╗ ██║███████║██████╔╝██╔██╗ ██║██║██╔██╗ ██║██║ ███╗\n"
177+
+ "██║███╗██║██╔══██║██╔══██╗██║╚██╗██║██║██║╚██╗██║██║ ██║\n"
178+
+ "╚███╔███╔╝██║ ██║██║ ██║██║ ╚████║██║██║ ╚████║╚██████╔╝\n"
179+
+ " ╚══╝╚══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═══╝╚═╝╚═╝ ╚═══╝ ╚═════╝ \n"
180+
+ "\n"
181+
+ "⚠️ Warning! Skidfuscator has deprecated the exempt file!\n"
182+
+ ConsoleColors.RESET
183+
+ "\n Launching migrator service..."
184+
+ "\n Config will be found at " + converted
185+
+ "\n";
186+
Skidfuscator.LOGGER.post(warning);
187+
new ExemptToConfigMigration().migrate(exempt, converted);
188+
189+
config = converted;
190+
}
191+
157192
final File[] libs;
158193
if (libFolder != null) {
159194
libs = libFolder.listFiles();
@@ -170,6 +205,8 @@ public Integer call() {
170205
.phantom(phantom)
171206
.jmod(MiscUtil.getJavaVersion() > 8)
172207
.fuckit(fuckit)
208+
.config(config)
209+
.renamer(renamer)
173210
.analytics(!notrack)
174211
.build();
175212

dev.skidfuscator.commons/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ repositories {
77
}
88

99
dependencies {
10+
api 'com.typesafe:config:1.4.2'
1011
compileOnly 'org.projectlombok:lombok:1.18.24'
1112

1213
api project(":annotations")
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package dev.skidfuscator.config;
2+
3+
import com.typesafe.config.Config;
4+
5+
import java.util.ArrayList;
6+
import java.util.HashMap;
7+
import java.util.List;
8+
import java.util.Map;
9+
import java.util.function.Function;
10+
import java.util.function.Supplier;
11+
12+
public class DefaultConfig {
13+
protected final String path;
14+
protected final Config config;
15+
protected final Map<String, Object> cache;
16+
17+
public DefaultConfig(Config config, String path) {
18+
this.path = path.equals("") ? path : path + ".";
19+
this.config = config;
20+
this.cache = new HashMap<>();
21+
}
22+
23+
public List<String> getExemptions() {
24+
return getStringList(path + "exempt", new ArrayList<>());
25+
}
26+
27+
public boolean getBoolean(String path, final boolean dflt) {
28+
return get(path, dflt, config::getBoolean);
29+
}
30+
31+
public List<String> getStringList(String path, final List<String> dflt) {
32+
return get(path, dflt, config::getStringList);
33+
}
34+
35+
public <T extends Enum<T>> T getEnum(String path, final Enum<T> dflt) {
36+
return (T) get(path, dflt, e -> config.getEnum(dflt.getDeclaringClass(), e));
37+
}
38+
39+
public <T> T get(String path, final T dflt, final Function<String, T> supplier) {
40+
path = this.path + path;
41+
Object var = cache.get(path);
42+
43+
if (var == null) {
44+
if (config.hasPath(path)) {
45+
var = supplier.apply(path);
46+
} else {
47+
var = dflt;
48+
}
49+
50+
cache.put(path, var);
51+
}
52+
53+
assert dflt.getClass().isAssignableFrom(var.getClass()) : "Value loaded at path is not a type assigned!";
54+
55+
return (T) var;
56+
}
57+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package dev.skidfuscator.config;
2+
3+
import com.typesafe.config.Config;
4+
5+
import java.io.File;
6+
import java.util.Collections;
7+
8+
public class DefaultSkidConfig extends DefaultConfig {
9+
public DefaultSkidConfig(Config config, String path) {
10+
super(config, path);
11+
}
12+
13+
public boolean isDriver() {
14+
return this.getBoolean("driver", true);
15+
}
16+
17+
public File[] getLibs() {
18+
return this.getStringList("libraries", Collections.emptyList())
19+
.stream()
20+
.map(File::new)
21+
.distinct()
22+
.toArray(File[]::new);
23+
}
24+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package dev.skidfuscator.config;
2+
3+
import com.typesafe.config.Config;
4+
5+
public class DefaultTransformerConfig extends DefaultConfig {
6+
public DefaultTransformerConfig(Config config, String path) {
7+
super(config, path);
8+
}
9+
10+
public boolean isEnabled() {
11+
return this.getBoolean("enabled", true);
12+
}
13+
}

0 commit comments

Comments
 (0)