Skip to content

Commit 469128c

Browse files
committed
Remove unused classes + Fix mapping + Further abstract transformers
1 parent 352c7f8 commit 469128c

13 files changed

+628
-491
lines changed

README.md

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,6 +1273,19 @@ ObfuscationConfig config = new ObfuscationConfig.Builder()
12731273
- Renames methods and updates method invocations
12741274
- Skips constructors and static initializers
12751275

1276+
4. **AntiDebuggingTransformer** (Priority: 100)
1277+
- Adds anti-debugging checks and responses
1278+
- Configurable actions on debugger detection
1279+
- Adds VM checks to prevent debugging
1280+
1281+
5. **ConditionObfuscationTransformer** (Priority: 250)
1282+
- Transforms boolean constants into complex expressions
1283+
- Ensures stackmap safety
1284+
1285+
6. **StringCompressionTransformer** (Priority: 350)
1286+
- Compresses string literals using Deflate and Base64
1287+
- Decompresses strings at runtime
1288+
12761289
### Validation System
12771290

12781291
- **Input Validation** - Validates JAR files, output paths, and file permissions
@@ -1335,22 +1348,6 @@ ObfuscationConfig config = ConfigPresets.createDebugObfuscation()
13351348
.build();
13361349
```
13371350

1338-
## Contributing
1339-
1340-
### Adding New Transformers
1341-
1342-
1. Extend `AbstractTransformer`
1343-
2. Implement required methods
1344-
3. Set appropriate priority
1345-
4. Register with `ObfuscationEngine`
1346-
1347-
### Configuration Extensions
1348-
1349-
1. Add new properties to `ObfuscationConfig`
1350-
2. Update `Builder` class
1351-
3. Add validation in `ConfigValidator`
1352-
4. Create preset if needed
1353-
13541351
## License
13551352

13561353
This project is licensed under the MIT License - see the LICENSE file for details.

src/main/java/net/cvs0/config/ConfigPresets.java

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

src/main/java/net/cvs0/context/TransformerContext.java

Lines changed: 0 additions & 38 deletions
This file was deleted.
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
package net.cvs0.core;
2+
3+
import net.cvs0.context.ObfuscationContext;
4+
import net.cvs0.utils.BytecodeUtils;
5+
import org.objectweb.asm.ClassVisitor;
6+
import org.objectweb.asm.FieldVisitor;
7+
import org.objectweb.asm.MethodVisitor;
8+
import org.objectweb.asm.Opcodes;
9+
10+
public abstract class BaseClassVisitor extends ClassVisitor implements ContextProvider
11+
{
12+
protected final ObfuscationContext context;
13+
protected String currentClassName;
14+
15+
protected BaseClassVisitor(ClassVisitor classVisitor, ObfuscationContext context)
16+
{
17+
super(Opcodes.ASM9, classVisitor);
18+
this.context = context;
19+
}
20+
21+
@Override
22+
public final ObfuscationContext getContext()
23+
{
24+
return context;
25+
}
26+
27+
@Override
28+
public final String getCurrentClassName()
29+
{
30+
return currentClassName;
31+
}
32+
33+
@Override
34+
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces)
35+
{
36+
this.currentClassName = name;
37+
super.visit(version, access, name, signature, superName, interfaces);
38+
}
39+
40+
@Override
41+
public MethodVisitor visitMethod(int access, String name, String descriptor, String signature, String[] exceptions)
42+
{
43+
MethodVisitor mv = super.visitMethod(access, name, descriptor, signature, exceptions);
44+
45+
if (!shouldProcessMethod(name, access, descriptor)) {
46+
return mv;
47+
}
48+
49+
return createMethodVisitor(mv, access, name, descriptor, signature, exceptions);
50+
}
51+
52+
@Override
53+
public FieldVisitor visitField(int access, String name, String descriptor, String signature, Object value)
54+
{
55+
if (!shouldProcessField(name, access, descriptor)) {
56+
return super.visitField(access, name, descriptor, signature, value);
57+
}
58+
59+
return createFieldVisitor(super.visitField(access, name, descriptor, signature, value),
60+
access, name, descriptor, signature, value);
61+
}
62+
63+
protected boolean shouldProcessMethod(String name, int access, String descriptor)
64+
{
65+
if (BytecodeUtils.isMethodSkippable(name, access)) {
66+
return false;
67+
}
68+
69+
if (!context.getConfig().isInPackageScope(currentClassName)) {
70+
return false;
71+
}
72+
73+
return !context.getConfig().shouldKeepMethod(currentClassName, name, descriptor);
74+
}
75+
76+
protected boolean shouldProcessField(String name, int access, String descriptor)
77+
{
78+
if (BytecodeUtils.isFieldSkippable(name, access)) {
79+
return false;
80+
}
81+
82+
if (!context.getConfig().isInPackageScope(currentClassName)) {
83+
return false;
84+
}
85+
86+
return !context.getConfig().shouldKeepField(currentClassName, name);
87+
}
88+
89+
protected boolean shouldProcessClass()
90+
{
91+
return context.getConfig().isInPackageScope(currentClassName) &&
92+
!context.getConfig().shouldKeepClass(currentClassName);
93+
}
94+
95+
protected void logTransformation(String message)
96+
{
97+
if (context.getConfig().isVerbose()) {
98+
System.out.println("[" + getTransformerName() + "] " + message + " in " + currentClassName);
99+
}
100+
}
101+
102+
protected abstract String getTransformerName();
103+
104+
protected MethodVisitor createMethodVisitor(MethodVisitor mv, int access, String name,
105+
String descriptor, String signature, String[] exceptions)
106+
{
107+
return mv;
108+
}
109+
110+
protected FieldVisitor createFieldVisitor(FieldVisitor fv, int access, String name,
111+
String descriptor, String signature, Object value)
112+
{
113+
return fv;
114+
}
115+
}

0 commit comments

Comments
 (0)