Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Contra
committed
Feb 14, 2011
1 parent
3bf463d
commit 7721103
Showing
43 changed files
with
1,136 additions
and
120 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Empty file.
Binary file modified
BIN
+0 Bytes
(100%)
out/production/JMOT/net/contra/obfuscator/Application$1.class
Binary file not shown.
Binary file modified
BIN
+129 Bytes
(100%)
out/production/JMOT/net/contra/obfuscator/Application.class
Binary file not shown.
Binary file modified
BIN
+10 Bytes
(100%)
out/production/JMOT/net/contra/obfuscator/ITransformer.class
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+86 Bytes
(100%)
out/production/JMOT/net/contra/obfuscator/trans/AttributeObfuscator.class
Binary file not shown.
Binary file modified
BIN
+91 Bytes
(100%)
out/production/JMOT/net/contra/obfuscator/trans/ClassNameObfuscator.class
Binary file not shown.
Binary file modified
BIN
+111 Bytes
(100%)
out/production/JMOT/net/contra/obfuscator/trans/FieldNameObfuscator.class
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+50 Bytes
(100%)
out/production/JMOT/net/contra/obfuscator/trans/IntegerComplicator.class
Binary file not shown.
Binary file modified
BIN
+111 Bytes
(100%)
out/production/JMOT/net/contra/obfuscator/trans/MethodNameObfuscator.class
Binary file not shown.
Binary file modified
BIN
+45 Bytes
(100%)
out/production/JMOT/net/contra/obfuscator/trans/StringObfuscator.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+4.65 KB
out/production/JMOT/net/contra/obfuscator/util/bcel/BCELMethods.class
Binary file not shown.
Binary file renamed
BIN
+4.26 KB
...et/contra/obfuscator/util/JarLoader.class → ...ntra/obfuscator/util/bcel/JarLoader.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file renamed
BIN
+906 Bytes
...T/net/contra/obfuscator/util/Misc$1.class → .../contra/obfuscator/util/misc/Misc$1.class
Binary file not shown.
Binary file renamed
BIN
+1.98 KB
...MOT/net/contra/obfuscator/util/Misc.class → ...et/contra/obfuscator/util/misc/Misc.class
Binary file not shown.
Binary file renamed
BIN
+786 Bytes
.../contra/obfuscator/util/RenamedPair.class → ...ra/obfuscator/util/misc/RenamedPair.class
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Manifest-Version: 1.0 | ||
Main-Class: net.contra.obfuscator.Application | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
package net.contra.obfuscator.trans; | ||
|
||
import com.sun.org.apache.bcel.internal.Constants; | ||
import com.sun.org.apache.bcel.internal.classfile.Method; | ||
import com.sun.org.apache.bcel.internal.generic.*; | ||
import net.contra.obfuscator.ITransformer; | ||
import net.contra.obfuscator.ObfuscationType; | ||
import net.contra.obfuscator.Settings; | ||
import net.contra.obfuscator.util.bcel.BCELMethods; | ||
import net.contra.obfuscator.util.bcel.JarLoader; | ||
import net.contra.obfuscator.util.misc.LogHandler; | ||
|
||
|
||
public class IntegerBoxer implements ITransformer { | ||
private final LogHandler Logger = new LogHandler("AttributeObfuscator"); | ||
private String Location = ""; | ||
private JarLoader LoadedJar; | ||
|
||
public IntegerBoxer(String loc) { | ||
Location = loc; | ||
} | ||
|
||
public void Load() { | ||
LoadedJar = new JarLoader(Location); | ||
} | ||
|
||
public void Transform() { | ||
for (ClassGen cg : LoadedJar.ClassEntries.values()) { | ||
MethodGen boxer = getBoxer(cg); | ||
INVOKESTATIC inv = new INVOKESTATIC(cg.getConstantPool().addMethodref(boxer)); | ||
for (Method method : cg.getMethods()) { | ||
MethodGen mg = new MethodGen(method, cg.getClassName(), cg.getConstantPool()); | ||
InstructionList list = mg.getInstructionList(); | ||
if (list == null) continue; | ||
Logger.Log("Boxing Constant Integers -> Class: " + cg.getClassName() + " Method: " + method.getName()); | ||
InstructionHandle[] handles = list.getInstructionHandles(); | ||
for (InstructionHandle handle : handles) { | ||
if (handle.getInstruction() instanceof ICONST | ||
|| handle.getInstruction() instanceof BIPUSH | ||
|| handle.getInstruction() instanceof SIPUSH | ||
|| handle.getInstruction() instanceof ILOAD | ||
|| (handle.getInstruction() instanceof LDC && handle.getNext().getInstruction() instanceof IASTORE)) { | ||
int curValue = BCELMethods.getIntegerValue(handle.getInstruction()); | ||
InstructionHandle nh; | ||
//If it is an even int, it gets replaced with half it's value and appends | ||
//an int of the key | ||
if (curValue != -9001 && (curValue % 2 == 0) | ||
&& Settings.ObfuscationLevel.getLevel() > ObfuscationType.Normal.getLevel()) { //check if it's even. | ||
int tempkey = curValue / 2; | ||
Logger.Debug("Value: " + curValue + " Key: " + tempkey); | ||
Instruction newIns = BCELMethods.getIntegerLoad(handle.getInstruction(), tempkey); | ||
handle.setInstruction(newIns); | ||
if (tempkey <= 5 && tempkey >= -1) { | ||
nh = list.append(handle, new ICONST(tempkey)); | ||
} else { | ||
nh = list.append(handle, newIns); | ||
} | ||
} else { | ||
//Otherwise just append a 0 key and keep the number the same | ||
nh = list.append(handle, new ICONST(0)); | ||
} | ||
list.append(nh, inv); | ||
} | ||
} | ||
list.setPositions(); | ||
mg.setInstructionList(list); | ||
mg.setMaxLocals(); | ||
mg.setMaxStack(); | ||
cg.replaceMethod(method, mg.getMethod()); | ||
} | ||
if (cg.containsMethod(boxer.getName(), boxer.getSignature()) == null) { | ||
Logger.Log("Injecting Boxer Method -> Class: " + cg.getClassName()); | ||
cg.addMethod(boxer.getMethod()); | ||
} else { | ||
Logger.Error("Boxer Method Already Exists! -> Class: " + cg.getClassName()); | ||
} | ||
} | ||
} | ||
|
||
MethodGen getBoxer(ClassGen cg) { | ||
InstructionList il = new InstructionList(); | ||
MethodGen method = new MethodGen(Constants.ACC_PUBLIC | Constants.ACC_STATIC, Type.INT, new Type[]{Type.INT, Type.INT}, | ||
new String[]{Settings.BoxerArg, Settings.BoxerArg + "i"}, Settings.BoxerName, cg.getClassName(), il, cg.getConstantPool()); | ||
il.append(InstructionFactory.createLoad(Type.INT, 0)); | ||
il.append(InstructionFactory.createLoad(Type.INT, 1)); | ||
il.append(new IADD()); | ||
il.append(InstructionFactory.createReturn(Type.INT)); | ||
method.setMaxStack(); | ||
method.setMaxLocals(); | ||
return method; | ||
} | ||
|
||
public void Dump() { | ||
LoadedJar.Save(Location.replace(".jar", Settings.FileTag + ".jar")); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...net/contra/obfuscator/util/JarLoader.java → ...ontra/obfuscator/util/bcel/JarLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/net/contra/obfuscator/util/IO.java → src/net/contra/obfuscator/util/misc/IO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...et/contra/obfuscator/util/LogHandler.java → ...ntra/obfuscator/util/misc/LogHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/net/contra/obfuscator/util/Misc.java → ...net/contra/obfuscator/util/misc/Misc.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...t/contra/obfuscator/util/RenamedPair.java → ...tra/obfuscator/util/misc/RenamedPair.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package net.contra.obfuscator.util; | ||
package net.contra.obfuscator.util.misc; | ||
|
||
/** | ||
* Created by IntelliJ IDEA. | ||
|