mirror of
https://github.com/SuspiciousActivity/ByteEdit.git
synced 2026-08-13 17:56:17 +00:00
Fixed number deobfuscator
This commit is contained in:
1 parent
b5e4847be5
commit
ac247a89ca
2 files changed
+41
-8
No files matched your search
@@ -24,6 +24,7 @@ import org.objectweb.asm.tree.FieldNode;
|
||||
import org.objectweb.asm.tree.FrameNode;
|
||||
import org.objectweb.asm.tree.IincInsnNode;
|
||||
import org.objectweb.asm.tree.InnerClassNode;
|
||||
import org.objectweb.asm.tree.InsnList;
|
||||
import org.objectweb.asm.tree.InsnNode;
|
||||
import org.objectweb.asm.tree.IntInsnNode;
|
||||
import org.objectweb.asm.tree.InvokeDynamicInsnNode;
|
||||
@@ -419,9 +420,18 @@ public class Disassembler {
|
||||
HashMap<Label, Integer> labels = new HashMap<Label, Integer>();
|
||||
String localVarTable;
|
||||
String tryCatchTable;
|
||||
for (AbstractInsnNode n : mn.instructions.toArray()) {
|
||||
|
||||
InsnList insnList = mn.instructions;
|
||||
boolean deobfNumbers = Main.INSTANCE.mntmNumbers.isSelected();
|
||||
|
||||
ArrayList<Label> labelsReversed = deobfNumbers ? new ArrayList<>() : null;
|
||||
|
||||
for (AbstractInsnNode n = insnList.getFirst(); n != null; n = n.getNext()) {
|
||||
if (n instanceof LabelNode) {
|
||||
labels.put(((LabelNode) n).getLabel(), labels.size() + 1);
|
||||
int id = labels.size() + 1;
|
||||
if (deobfNumbers)
|
||||
labelsReversed.add(((LabelNode) n).getLabel());
|
||||
labels.put(((LabelNode) n).getLabel(), id);
|
||||
}
|
||||
}
|
||||
if (mn.localVariables != null && !mn.localVariables.isEmpty()) {
|
||||
@@ -450,14 +460,20 @@ public class Disassembler {
|
||||
} else
|
||||
tryCatchTable = "";
|
||||
|
||||
if (Main.INSTANCE.mntmNumbers.isSelected()) {
|
||||
StackBasedCalculator calc = new StackBasedCalculator(mn.instructions);
|
||||
if (deobfNumbers) {
|
||||
StackBasedCalculator calc = new StackBasedCalculator(insnList);
|
||||
calc.run();
|
||||
insnList = calc.get();
|
||||
int i = 0;
|
||||
for (AbstractInsnNode n = insnList.getFirst(); n != null; n = n.getNext()) {
|
||||
if (n instanceof LabelNode) {
|
||||
((LabelNode) n).setLabel(labelsReversed.get(i++));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AbstractInsnNode[] insns = mn.instructions.toArray();
|
||||
StringContext ctx = new StringContext(insns.length);
|
||||
for (AbstractInsnNode n : insns) {
|
||||
StringContext ctx = new StringContext(insnList.size());
|
||||
for (AbstractInsnNode n = insnList.getFirst(); n != null; n = n.getNext()) {
|
||||
ctx.next(disassembleInstruction(n, labels, hs));
|
||||
}
|
||||
return new String[] { ctx.finish(), localVarTable, tryCatchTable };
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package me.ByteEdit.edit;
|
||||
|
||||
import java.util.EmptyStackException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Stack;
|
||||
|
||||
import org.objectweb.asm.Opcodes;
|
||||
@@ -8,6 +9,7 @@ import org.objectweb.asm.tree.AbstractInsnNode;
|
||||
import org.objectweb.asm.tree.InsnList;
|
||||
import org.objectweb.asm.tree.InsnNode;
|
||||
import org.objectweb.asm.tree.IntInsnNode;
|
||||
import org.objectweb.asm.tree.LabelNode;
|
||||
import org.objectweb.asm.tree.LdcInsnNode;
|
||||
|
||||
public class StackBasedCalculator implements Opcodes, Runnable {
|
||||
@@ -19,7 +21,22 @@ public class StackBasedCalculator implements Opcodes, Runnable {
|
||||
private boolean isAtEnd = false;
|
||||
|
||||
public StackBasedCalculator(InsnList insns) {
|
||||
this.insns = insns;
|
||||
this.insns = new InsnList();
|
||||
|
||||
HashMap<LabelNode, LabelNode> labelMap = new HashMap<>();
|
||||
for (AbstractInsnNode node = insns.getFirst(); node != null; node = node.getNext()) {
|
||||
if (node.getType() == 8) {
|
||||
labelMap.put((LabelNode) node, new LabelNode());
|
||||
}
|
||||
}
|
||||
|
||||
for (AbstractInsnNode node = insns.getFirst(); node != null; node = node.getNext()) {
|
||||
this.insns.add(node.clone(labelMap));
|
||||
}
|
||||
}
|
||||
|
||||
public InsnList get() {
|
||||
return insns;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user