Skip to content

Commit

Permalink
jar checking, crasher & updated version
Browse files Browse the repository at this point in the history
added file type checking
removed procyon crasher added by @ElijahBare as it wasn't what causes procyon to fail to decompile methods, still don't know what causes the issue but procyon can't decompile methods added by the string encryption transformer

updated readme
updated version (1.4.1)
  • Loading branch information
iiiiiiiris committed Apr 5, 2023
1 parent 6eab7f8 commit b932746
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 80 deletions.
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
| Miscellaneous ZIP stuff ||
| GUI | 🚫 |

###### As of 1.3.0-beta release
###### As of 1.4.0-beta release

###### Unimplemented features will be added at some point

Expand All @@ -20,13 +20,14 @@ Download the latest jar [here](https://github.com/iiiiiiiris/Ambien/releases/lat

Run the jar using the `--create-config` argument to create a base config

###### Ambien MUST be ran with Java 8+

Then run the Ambien jar using the `-config` argument (including the path to your config)

###### Note: Ambien should not be used with other obfuscators.

###### To see all the arguments Ambien offers, you can use the '-help' argument


**Note to developers: to see debug output, add `-Dorg.slf4j.simpleLogger.defaultLogLevel=DEBUG` to vm options**

# Example obfuscation
Expand All @@ -36,15 +37,15 @@ Example obfuscation of Ambien v1.4.0
## Original

``` java
public static void main(String[] args) {
AnotherClass.yellow();
boolean plaaaaaaaay = false;
public static void main(String[] args) {
AnotherClass.yellow();
boolean plaaaaaaaay = false;

for (int i = 0; i < 15; ++i) {
System.out.printf("%b: %d\n", plaaaaaaaay, i);
plaaaaaaaay = !plaaaaaaaay;
}
for (int i = 0; i < 15; ++i) {
System.out.printf("%b: %d\n", plaaaaaaaay, i);
plaaaaaaaay = !plaaaaaaaay;
}
}
```


Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group 'me.iris'
version '1.4.0'
version '1.4.1'

repositories {
mavenCentral()
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/me/iris/ambien/obfuscator/Ambien.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class Ambien {
public static final Ambien get = new Ambien();

public static final Logger LOGGER = LoggerFactory.getLogger("Ambien");
public static final String VERSION = "1.4.0", CLASSIFIER = "dev";
public static final String VERSION = "1.4.1", CLASSIFIER = "beta";

public TransformerManager transformerManager;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,58 +1,26 @@
package me.iris.ambien.obfuscator.asm;

import me.iris.ambien.obfuscator.Ambien;
import org.objectweb.asm.ClassWriter;

public class CompetentClassWriter extends ClassWriter {
private static final String OBJECT = "java/lang/Object";

public CompetentClassWriter(int flags) {
public CompetentClassWriter(final int flags) {
super(flags);
}

@Override
protected String getCommonSuperClass(final String type1, final String type2) {
// Debugging
Ambien.LOGGER.debug("{}-{}", type1, type2);





// uhhhh
// First try to get the common super class via class loader
return super.getCommonSuperClass(type1, type2);
}

/*ClassLoader classLoader = getClassLoader();
Class<?> class1;
try {
class1 = Class.forName(type1.replace('/', '.'), false, classLoader);
} catch (ClassNotFoundException e) {
throw new TypeNotPresentException(type1, e);
}
Class<?> class2;
try {
class2 = Class.forName(type2.replace('/', '.'), false, classLoader);
} catch (ClassNotFoundException e) {
throw new TypeNotPresentException(type2, e);
/*private ClassNode getNodeFromName(final String path) {
for (ClassWrapper wrapper : classes) {
if (wrapper.getName().equals(path))
return wrapper.getNode();
}
if (class1.isAssignableFrom(class2))
return type1;
if (class2.isAssignableFrom(class1))
return type2;
if (class1.isInterface() || class2.isInterface()) {
return "java/lang/Object";
} else {
do {
class1 = class1.getSuperclass();
} while (!class1.isAssignableFrom(class2));
return class1.getName().replace('.', '/');
}*/
}

private String getCommonSuperName(final String type1, final String type2) {
return "";
}
return null;
}*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.objectweb.asm.tree.*;

import java.util.ArrayList;
import java.util.List;

/**
* Crashes & confuses various decompilers & other reverse engineering tools
Expand Down Expand Up @@ -43,10 +44,6 @@ public class Crasher extends Transformer {
* Adds a class that inherits itself, causing some tools to get stuck in an infinite loop of decompiling the class
*/
public final BooleanSetting selfInheritance = new BooleanSetting("self-inheritance", true);
/**
* Crashes proycon by finding a random local variable in a method and changing its name in the method's instructions.
*/
public final BooleanSetting procyonCrasher = new BooleanSetting("procyon-crasher", true);

@Override
public void transform(JarWrapper wrapper) {
Expand All @@ -65,9 +62,6 @@ public void transform(JarWrapper wrapper) {
addBadAnnotations(classWrapper);
if (junkSignatures.isEnabled())
addJunkSignatures(classWrapper);
if (procyonCrasher.isEnabled()) {
addProyconCrasher(classWrapper);
}
});
}

Expand Down Expand Up @@ -111,22 +105,6 @@ private void addBadAnnotations(final ClassWrapper wrapper) {
});
}

private void addProyconCrasher(final ClassWrapper wrapper) {
wrapper.getMethods().forEach(methodWrapper -> {
final MethodNode methodNode = methodWrapper.getNode();
if (methodNode.localVariables == null || methodNode.localVariables.isEmpty()) {
return;
}

final LocalVariableNode variableNode = methodNode.localVariables.get(MathUtil.randomInt(0, methodNode.localVariables.size()));
final String newName = StringUtil.randomString(15);

variableNode.name = newName;
});
}



private void addJunkSignatures(final ClassWrapper wrapper) {
// Add junk signature to class
wrapper.getNode().signature = StringUtil.randomString(15);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.util.jar.JarOutputStream;
import java.util.zip.Deflater;

@SuppressWarnings("resource")
public class JarWrapper {
@Getter
private final List<String> directories;
Expand All @@ -41,6 +42,9 @@ public JarWrapper from(final File file) throws IOException {
if (!file.exists())
throw new RuntimeException("Input jar file doesn't exist.");

if (!file.getName().endsWith(".jar"))
throw new RuntimeException("Input jar isn't a jar file.");

// Convert file to jar file
final JarFile jarFile = new JarFile(file);
Ambien.LOGGER.info("Loading jar: " + jarFile.getName());
Expand Down Expand Up @@ -82,6 +86,9 @@ public JarWrapper importLibrary(final String path) throws IOException {
if (!file.exists())
throw new RuntimeException(String.format("Library jar \"%s\" file doesn't exist.", path));

if (!file.getName().endsWith(".jar"))
throw new RuntimeException(String.format("Library jar \"%s\" isn't a jar file.", path));

// Convert file to jar file
final JarFile jarFile = new JarFile(path);
Ambien.LOGGER.info("Loading library: " + jarFile.getName());
Expand Down
13 changes: 9 additions & 4 deletions src/test/java/me/iris/testjar/Entry.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package me.iris.testjar;

import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.lang.invoke.MutableCallSite;

public class Entry {
public static boolean uhhhh = true;

Expand All @@ -11,16 +16,16 @@ public static void main(String[] args) throws Throwable {
plaaaaaaaay = !plaaaaaaaay;
}

//makeCallSite(Entry.class, "anotherMethod", "()V"/*, MethodType.methodType(void.class)*/).dynamicInvoker().invoke();
makeCallSite(Entry.class, "anotherMethod", "(Ljava/lang/String;)V"/*, MethodType.methodType(void.class)*/).dynamicInvoker().invoke("hahaha");
}

/*private static void anotherMethod() {
System.out.println("yellow");
private static void anotherMethod(String erm) {
System.out.println(erm);
}

private static MutableCallSite makeCallSite(final Class<?> target, final String name, final String desc) throws NoSuchMethodException, IllegalAccessException {
final MethodHandles.Lookup lookup = MethodHandles.lookup();
final MethodHandle handle = lookup.findStatic(target, name, MethodType.fromMethodDescriptorString(desc, target.getClassLoader()));
return new MutableCallSite(handle);
}*/
}
}
2 changes: 1 addition & 1 deletion web/version.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": "1.3.1",
"version": "1.4.1",
"classifier": "beta"
}

0 comments on commit b932746

Please sign in to comment.