Re-Added Szperak's Allatori String Decrypter
This commit is contained in:
parent
563bc6b79e
commit
b7deff48da
1 changed files with 45 additions and 59 deletions
|
@ -103,12 +103,9 @@ public class AllatoriStringDecrypter extends Plugin
|
||||||
public void scanClassNode(ClassNode classNode) throws Exception
|
public void scanClassNode(ClassNode classNode) throws Exception
|
||||||
{
|
{
|
||||||
for (MethodNode method : classNode.methods)
|
for (MethodNode method : classNode.methods)
|
||||||
{
|
|
||||||
scanMethodNode(classNode, method);
|
scanMethodNode(classNode, method);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public int readUnsignedShort(byte[] b, final int index)
|
public int readUnsignedShort(byte[] b, final int index)
|
||||||
{
|
{
|
||||||
return ((b[index] & 0xFF) << 8) | (b[index + 1] & 0xFF);
|
return ((b[index] & 0xFF) << 8) | (b[index + 1] & 0xFF);
|
||||||
|
@ -131,34 +128,30 @@ public class AllatoriStringDecrypter extends Plugin
|
||||||
{
|
{
|
||||||
if (i instanceof LdcInsnNode)
|
if (i instanceof LdcInsnNode)
|
||||||
{
|
{
|
||||||
LdcInsnNode ldci = (LdcInsnNode) i;
|
LdcInsnNode ldcI = (LdcInsnNode) i;
|
||||||
if (ldci.cst instanceof String)
|
if (ldcI.cst instanceof String)
|
||||||
{
|
laststringldconstack = ldcI;
|
||||||
laststringldconstack = ldci;
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (i instanceof MethodInsnNode)
|
else if (i instanceof MethodInsnNode)
|
||||||
{
|
{
|
||||||
MethodInsnNode methodi = (MethodInsnNode) i;
|
MethodInsnNode methodI = (MethodInsnNode) i;
|
||||||
|
|
||||||
|
// Decryption is always a static call - 0xb8 - invokestatic
|
||||||
|
if (laststringldconstack != null && methodI.getOpcode() == 0xb8)
|
||||||
|
{
|
||||||
|
String decrypterClassName = methodI.owner;
|
||||||
|
String decrypterMethodName = methodI.name;
|
||||||
|
|
||||||
if (laststringldconstack != null && methodi.getOpcode() == 0xb8)
|
// Decrypter is always a static method of other class's inner class
|
||||||
{ // Decryption is always a static call - 0xb8 - invokestatic
|
if (decrypterClassName.contains("$"))
|
||||||
String decrypterclassname = methodi.owner;
|
{
|
||||||
String decrypterMethodName = methodi.name;
|
byte[] decrypterFileContents = BytecodeViewer.getFileContents(decrypterClassName + ".class");
|
||||||
|
|
||||||
if (decrypterclassname.contains("$"))
|
|
||||||
{ // Decrypter is always a static method of other class's inner class
|
|
||||||
byte[] decrypterFileContents = BytecodeViewer.getFileContents(decrypterclassname + ".class");
|
|
||||||
|
|
||||||
// We have to create new node for editing
|
// We have to create new node for editing
|
||||||
// Also, one decrypter method could be used for multiple methods in code, what gives us only part of string decrypted
|
// Also, one decrypter method could be used for multiple methods in code, what gives us only part of string decrypted
|
||||||
ClassNode decrypterclassnode = ASMUtil.getClassNode(decrypterFileContents);
|
ClassNode decrypterClassNode = ASMUtil.getClassNode(decrypterFileContents);
|
||||||
|
MethodNode decryptermethodnode = ASMUtil.getMethodByName(decrypterClassNode, decrypterMethodName);
|
||||||
if (decrypterclassnode != null)
|
|
||||||
{
|
|
||||||
MethodNode decryptermethodnode = ASMUtil.getMethodByName(decrypterclassnode, decrypterMethodName);
|
|
||||||
|
|
||||||
if (decryptermethodnode != null)
|
if (decryptermethodnode != null)
|
||||||
{
|
{
|
||||||
|
@ -174,10 +167,10 @@ public class AllatoriStringDecrypter extends Plugin
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
System.out.println("Loading " + decrypterclassname);
|
System.out.println("Loading " + decrypterClassName);
|
||||||
|
|
||||||
Class<?> decrypterClassList = the.bytecode.club.bytecodeviewer.api.BytecodeViewer
|
Class<?> decrypterClassList = the.bytecode.club.bytecodeviewer.api.BytecodeViewer
|
||||||
.loadClassIntoClassLoader(decrypterclassnode);
|
.loadClassIntoClassLoader(decrypterClassNode);
|
||||||
|
|
||||||
String decrypted = invokeDecrypter(decrypterClassList, decrypterMethodName, (String) laststringldconstack.cst);
|
String decrypted = invokeDecrypter(decrypterClassList, decrypterMethodName, (String) laststringldconstack.cst);
|
||||||
|
|
||||||
|
@ -185,24 +178,19 @@ public class AllatoriStringDecrypter extends Plugin
|
||||||
{
|
{
|
||||||
log("Succesfully invoked decrypter method: " + decrypted);
|
log("Succesfully invoked decrypter method: " + decrypted);
|
||||||
laststringldconstack.cst = decrypted;
|
laststringldconstack.cst = decrypted;
|
||||||
iList.remove(methodi);
|
iList.remove(methodI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IndexOutOfBoundsException | ClassNotFoundException | IOException e)
|
catch (IndexOutOfBoundsException | ClassNotFoundException | IOException e)
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
log("Could not load decrypter class: " + decrypterclassname);
|
log("Could not load decrypter class: " + decrypterClassName);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
log("Could not find decrypter method (" + decrypterMethodName + ") of class " + decrypterclassname);
|
log("Could not find decrypter method (" + decrypterMethodName + ") of class " + decrypterClassName);
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
log("Could not find decrypter ClassNode of class " + decrypterclassname);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -220,9 +208,8 @@ public class AllatoriStringDecrypter extends Plugin
|
||||||
//iList.set(methodi, new MethodInsnNode(0xb8, methodi.bsm.getOwner(), methodi.bsm.getName(), methodi.bsm.getDesc(), false));
|
//iList.set(methodi, new MethodInsnNode(0xb8, methodi.bsm.getOwner(), methodi.bsm.getName(), methodi.bsm.getDesc(), false));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
laststringldconstack = null;
|
laststringldconstack = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -246,10 +233,9 @@ public class AllatoriStringDecrypter extends Plugin
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (insn == null)
|
if (insn == null)
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
while (insn != null)
|
while (insn != null)
|
||||||
{
|
{
|
||||||
|
@ -258,15 +244,16 @@ public class AllatoriStringDecrypter extends Plugin
|
||||||
MethodInsnNode methodi = ((MethodInsnNode) insn);
|
MethodInsnNode methodi = ((MethodInsnNode) insn);
|
||||||
|
|
||||||
if ("hashCode".equals(methodi.name)) // to this instruction
|
if ("hashCode".equals(methodi.name)) // to this instruction
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
removeInsn = insn;
|
removeInsn = insn;
|
||||||
insn = insn.getNext();
|
insn = insn.getNext();
|
||||||
iList.remove(removeInsn); // and remove it
|
iList.remove(removeInsn); // and remove it
|
||||||
}
|
}
|
||||||
if (insn == null) return false;
|
|
||||||
|
if (insn == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
iList.set(insn, new LdcInsnNode(newHashCode)); // then replace it with pre-computed key LDC
|
iList.set(insn, new LdcInsnNode(newHashCode)); // then replace it with pre-computed key LDC
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -311,7 +298,6 @@ public class AllatoriStringDecrypter extends Plugin
|
||||||
btnNewButton.setBounds(6, 56, 232, 23);
|
btnNewButton.setBounds(6, 56, 232, 23);
|
||||||
getContentPane().add(btnNewButton);
|
getContentPane().add(btnNewButton);
|
||||||
|
|
||||||
|
|
||||||
JLabel lblNewLabel = new JLabel("Class:");
|
JLabel lblNewLabel = new JLabel("Class:");
|
||||||
lblNewLabel.setBounds(6, 20, 67, 14);
|
lblNewLabel.setBounds(6, 20, 67, 14);
|
||||||
getContentPane().add(lblNewLabel);
|
getContentPane().add(lblNewLabel);
|
||||||
|
|
Loading…
Reference in a new issue