mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-24 12:15:33 +00:00
Issues #78,#81,#82 Fixed deobfuscation, exceptions during printgraph,...
This commit is contained in:
@@ -72,8 +72,8 @@ public class ABC {
|
||||
|
||||
public int removeTraps() {
|
||||
int rem = 0;
|
||||
for (MethodBody body : bodies) {
|
||||
rem += body.removeTraps(constants, this);
|
||||
for (int s = 0; s < script_info.length; s++) {
|
||||
rem += script_info[s].removeTraps(s, this);
|
||||
}
|
||||
return rem;
|
||||
}
|
||||
@@ -465,6 +465,16 @@ public class ABC {
|
||||
return ret.toString();
|
||||
}
|
||||
|
||||
public boolean isStaticTraitId(int classIndex, int traitId) {
|
||||
if (traitId < class_info[classIndex].static_traits.traits.length) {
|
||||
return true;
|
||||
} else if (traitId < class_info[classIndex].static_traits.traits.length + instance_info[classIndex].instance_traits.traits.length) {
|
||||
return false;
|
||||
} else {
|
||||
return true; //Can be class or instance initializer
|
||||
}
|
||||
}
|
||||
|
||||
public Trait findTraitByTraitId(int classIndex, int traitId) {
|
||||
if (traitId < class_info[classIndex].static_traits.traits.length) {
|
||||
return class_info[classIndex].static_traits.traits[traitId];
|
||||
|
||||
@@ -1687,171 +1687,11 @@ public class AVM2Code implements Serializable {
|
||||
code.add(pos, instruction);
|
||||
}
|
||||
|
||||
public int removeTraps(ConstantPool constants, MethodBody body, ABC abc) {
|
||||
|
||||
public int removeTraps(ConstantPool constants, MethodBody body, ABC abc, int scriptIndex, int classIndex, boolean isStatic) {
|
||||
removeDeadCode(constants, body);
|
||||
/* boolean isSecure = true;
|
||||
try {
|
||||
if (code.size() > 4) {
|
||||
AVM2Instruction first = code.get(0);
|
||||
AVM2Instruction second = code.get(1);
|
||||
boolean firstValue = false;
|
||||
boolean secondValue = false;
|
||||
if (first.definition instanceof PushFalseIns) {
|
||||
firstValue = false;
|
||||
} else if (first.definition instanceof PushTrueIns) {
|
||||
firstValue = true;
|
||||
} else {
|
||||
isSecure = false;
|
||||
}
|
||||
if (isSecure) {
|
||||
if (second.definition instanceof PushFalseIns) {
|
||||
secondValue = false;
|
||||
} else if (second.definition instanceof PushTrueIns) {
|
||||
secondValue = true;
|
||||
} else {
|
||||
isSecure = false;
|
||||
}
|
||||
if (isSecure) {
|
||||
int pos = 2;
|
||||
AVM2Instruction third = code.get(pos);
|
||||
if (third.definition instanceof SwapIns) {
|
||||
pos++;
|
||||
boolean dup = firstValue;
|
||||
firstValue = secondValue;
|
||||
secondValue = dup;
|
||||
third.ignored = true;
|
||||
}
|
||||
while (third.definition instanceof JumpIns) {
|
||||
pos = adr2pos(pos2adr(pos) + third.getBytes().length + third.operands[0]);
|
||||
third = code.get(pos);
|
||||
}
|
||||
AVM2Instruction firstSet = code.get(pos);
|
||||
while (firstSet.definition instanceof JumpIns) {
|
||||
pos = adr2pos(pos2adr(pos) + firstSet.getBytes().length + firstSet.operands[0]);
|
||||
firstSet = code.get(pos);
|
||||
}
|
||||
pos++;
|
||||
AVM2Instruction secondSet = code.get(pos);
|
||||
while (secondSet.definition instanceof JumpIns) {
|
||||
pos = adr2pos(pos2adr(pos) + secondSet.getBytes().length + secondSet.operands[0]);
|
||||
secondSet = code.get(pos);
|
||||
}
|
||||
int trueIndex = -1;
|
||||
int falseIndex = -1;
|
||||
if (firstSet.definition instanceof SetLocalTypeIns) {
|
||||
if (secondValue == true) {
|
||||
trueIndex = ((SetLocalTypeIns) firstSet.definition).getRegisterId(firstSet);
|
||||
}
|
||||
if (secondValue == false) {
|
||||
falseIndex = ((SetLocalTypeIns) firstSet.definition).getRegisterId(firstSet);
|
||||
}
|
||||
} else {
|
||||
isSecure = false;
|
||||
}
|
||||
if (isSecure) {
|
||||
if (secondSet.definition instanceof SetLocalTypeIns) {
|
||||
if (firstValue == true) {
|
||||
trueIndex = ((SetLocalTypeIns) secondSet.definition).getRegisterId(secondSet);
|
||||
}
|
||||
if (firstValue == false) {
|
||||
falseIndex = ((SetLocalTypeIns) secondSet.definition).getRegisterId(secondSet);
|
||||
}
|
||||
secondSet.ignored = true;
|
||||
firstSet.ignored = true;
|
||||
first.ignored = true;
|
||||
second.ignored = true;
|
||||
boolean found;
|
||||
do {
|
||||
found = false;
|
||||
for (int ip = 0; ip < code.size(); ip++) {
|
||||
if (code.get(ip).ignored) {
|
||||
continue;
|
||||
}
|
||||
if (code.get(ip).definition instanceof GetLocalTypeIns) {
|
||||
int regIndex = ((GetLocalTypeIns) code.get(ip).definition).getRegisterId(code.get(ip));
|
||||
if ((regIndex == trueIndex) || (regIndex == falseIndex)) {
|
||||
found = true;
|
||||
Stack<Boolean> myStack = new Stack<Boolean>();
|
||||
do {
|
||||
AVM2Instruction ins = code.get(ip);
|
||||
if (ins.definition instanceof GetLocalTypeIns) {
|
||||
regIndex = ((GetLocalTypeIns) ins.definition).getRegisterId(ins);
|
||||
if (regIndex == trueIndex) {
|
||||
myStack.push(true);
|
||||
}
|
||||
if (regIndex == falseIndex) {
|
||||
myStack.push(false);
|
||||
}
|
||||
ip++;
|
||||
ins.ignored = true;
|
||||
} else if (ins.definition instanceof DupIns) {
|
||||
Boolean b = myStack.pop();
|
||||
myStack.push(b);
|
||||
myStack.push(b);
|
||||
ins.ignored = true;
|
||||
ip++;
|
||||
} else if (ins.definition instanceof PopIns) {
|
||||
myStack.pop();
|
||||
ins.ignored = true;
|
||||
ip++;
|
||||
} else if (ins.definition instanceof IfTrueIns) {
|
||||
boolean val = myStack.pop();
|
||||
if (val) {
|
||||
code.get(ip).definition = new JumpIns();
|
||||
ip = adr2pos(pos2adr(ip + 1) + code.get(ip).operands[0]);
|
||||
} else {
|
||||
code.get(ip).ignored = true;
|
||||
ip++;
|
||||
}
|
||||
} else if (ins.definition instanceof IfFalseIns) {
|
||||
boolean val = myStack.pop();
|
||||
if (!val) {
|
||||
code.get(ip).definition = new JumpIns();
|
||||
ip = adr2pos(pos2adr(ip + 1) + code.get(ip).operands[0]);
|
||||
} else {
|
||||
code.get(ip).ignored = true;
|
||||
ip++;
|
||||
}
|
||||
} else if (ins.definition instanceof JumpIns) {
|
||||
ip = adr2pos(pos2adr(ip + 1) + code.get(ip).operands[0]);
|
||||
} else {
|
||||
ip++;
|
||||
}
|
||||
|
||||
} while (myStack.size() > 0 && ip < code.size());
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} while (found);
|
||||
removeIgnored(constants, body);
|
||||
removeDeadCode(constants, body);
|
||||
} else {
|
||||
//isSecure = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (ConvertException cex) {
|
||||
}
|
||||
int ret = isSecure ? 1 : 0;
|
||||
ret += visitCodeTrap(body, new int[code.size()]);*/
|
||||
|
||||
//definition.translate((Boolean) localData.get(0), (Integer) localData.get(1),
|
||||
//(HashMap<Integer, GraphTargetItem>) localData.get(2), stack,
|
||||
//(Stack<GraphTargetItem>) localData.get(3), (ConstantPool) localData.get(4), this,
|
||||
//(MethodInfo[]) localData.get(5), output,
|
||||
//(MethodBody) localData.get(6), (ABC) localData.get(7),
|
||||
//(HashMap<Integer, String>) localData.get(8), (List<String>) localData.get(8));
|
||||
|
||||
List localData = new ArrayList();
|
||||
localData.add((Boolean) false); //isStatic
|
||||
localData.add((Integer) (-1)); //classIndex
|
||||
localData.add((Boolean) isStatic); //isStatic
|
||||
localData.add((Integer) (classIndex)); //classIndex
|
||||
localData.add(new HashMap<Integer, GraphTargetItem>());
|
||||
localData.add(new Stack<GraphTargetItem>());
|
||||
localData.add(abc.constants);
|
||||
@@ -1863,7 +1703,7 @@ public class AVM2Code implements Serializable {
|
||||
localData.add(new ArrayList<ABCException>());
|
||||
localData.add(new ArrayList<Integer>());
|
||||
localData.add(new ArrayList<Integer>());
|
||||
localData.add((Integer) (-1));
|
||||
localData.add((Integer) (scriptIndex));
|
||||
int ret = 0;
|
||||
ret += removeTraps(localData, new AVM2GraphSource(this, false, -1, -1, new HashMap<Integer, GraphTargetItem>(), new Stack<GraphTargetItem>(), abc, body, new HashMap<Integer, String>(), new ArrayList<String>()), 0);
|
||||
removeIgnored(constants, body);
|
||||
@@ -2593,6 +2433,6 @@ public class AVM2Code implements Serializable {
|
||||
HashMap<GraphSourceItem, AVM2Code.Decision> decisions = new HashMap<GraphSourceItem, AVM2Code.Decision>();
|
||||
removeTraps(false, false, localData, new Stack<GraphTargetItem>(), new ArrayList<GraphTargetItem>(), code, code.adr2pos(addr), 0, new HashMap<Integer, Integer>(), new HashMap<Integer, HashMap<Integer, GraphTargetItem>>(), decisions);
|
||||
localData.set(2, new HashMap<Integer, GraphTargetItem>());
|
||||
return removeTraps(true, true, localData, new Stack<GraphTargetItem>(), new ArrayList<GraphTargetItem>(), code, code.adr2pos(addr), 0, new HashMap<Integer, Integer>(), new HashMap<Integer, HashMap<Integer, GraphTargetItem>>(), decisions);
|
||||
return removeTraps(true, false, localData, new Stack<GraphTargetItem>(), new ArrayList<GraphTargetItem>(), code, code.adr2pos(addr), 0, new HashMap<Integer, Integer>(), new HashMap<Integer, HashMap<Integer, GraphTargetItem>>(), decisions);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,9 +244,9 @@ public class AVM2Instruction implements Serializable, GraphSourceItem {
|
||||
|
||||
@Override
|
||||
public void translate(List localData, Stack<GraphTargetItem> stack, List<GraphTargetItem> output) {
|
||||
definition.translate((Boolean) localData.get(0),
|
||||
definition.translate((Boolean) localData.get(0),
|
||||
(Integer) localData.get(13),
|
||||
(Integer) localData.get(1),
|
||||
(Integer) localData.get(1),
|
||||
(HashMap<Integer, GraphTargetItem>) localData.get(2),
|
||||
stack,
|
||||
(Stack<GraphTargetItem>) localData.get(3),
|
||||
|
||||
@@ -38,11 +38,21 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
|
||||
private List<Highlighting> classHighlights = new ArrayList<Highlighting>();
|
||||
private Highlighting currentMethodHighlight;
|
||||
private ABC abc;
|
||||
private int scriptIndex=-1;
|
||||
private int scriptIndex = -1;
|
||||
public int lastTraitIndex = 0;
|
||||
private boolean ignoreCarret = false;
|
||||
private boolean reset = false;
|
||||
private ABCPanel abcPanel;
|
||||
private int classIndex = -1;
|
||||
private boolean isStatic = false;
|
||||
|
||||
public int getScriptIndex() {
|
||||
return scriptIndex;
|
||||
}
|
||||
|
||||
public boolean getIsStatic() {
|
||||
return isStatic;
|
||||
}
|
||||
|
||||
public void setNoTrait() {
|
||||
abcPanel.detailPanel.showCard(DetailPanel.UNSUPPORTED_TRAIT_CARD, null);
|
||||
@@ -72,7 +82,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
|
||||
this.classIndex = classIndex;
|
||||
}
|
||||
|
||||
private boolean displayMethod(int pos, int methodIndex, String name, Trait trait) {
|
||||
private boolean displayMethod(int pos, int methodIndex, String name, Trait trait, boolean isStatic) {
|
||||
if (abc == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -86,6 +96,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
|
||||
abcPanel.detailPanel.methodTraitPanel.methodBodyParamsPanel.loadFromBody(abc.bodies[bi]);
|
||||
abcPanel.detailPanel.methodTraitPanel.methodInfoPanel.load(abc.bodies[bi].method_info, abc);
|
||||
abcPanel.detailPanel.setEditMode(false);
|
||||
this.isStatic = isStatic;
|
||||
}
|
||||
boolean success = false;
|
||||
for (Highlighting h : highlights) {
|
||||
@@ -103,7 +114,6 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
|
||||
abcPanel.navigator.setClassIndex(classIndex, scriptIndex);
|
||||
}
|
||||
}
|
||||
private int classIndex = -1;
|
||||
|
||||
public void resetEditing() {
|
||||
reset = true;
|
||||
@@ -147,6 +157,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
|
||||
lastTraitIndex = (int) th.offset;
|
||||
if (abc != null) {
|
||||
t = abc.findTraitByTraitId(classIndex, lastTraitIndex);
|
||||
isStatic = abc.isStaticTraitId(classIndex, lastTraitIndex);
|
||||
if (t != null) {
|
||||
name += ":" + t.getName(abc).getName(abc.constants, new ArrayList<String>());
|
||||
}
|
||||
@@ -154,7 +165,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
|
||||
}
|
||||
}
|
||||
|
||||
displayMethod(pos, (int) tm.offset, name, t);
|
||||
displayMethod(pos, (int) tm.offset, name, t, isStatic);
|
||||
currentMethodHighlight = tm;
|
||||
|
||||
|
||||
@@ -184,12 +195,13 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
|
||||
if (abc != null) {
|
||||
name = abc.instance_info[classIndex].getName(abc.constants).getNameWithNamespace(abc.constants);
|
||||
t = abc.findTraitByTraitId(classIndex, lastTraitIndex);
|
||||
isStatic = abc.isStaticTraitId(classIndex, lastTraitIndex);
|
||||
if (t != null) {
|
||||
name += ":" + t.getName(abc).getName(abc.constants, new ArrayList<String>());
|
||||
}
|
||||
}
|
||||
|
||||
displayMethod(pos, abc.findMethodIdByTraitId(classIndex, (int) th.offset), name, t);
|
||||
displayMethod(pos, abc.findMethodIdByTraitId(classIndex, (int) th.offset), name, t, isStatic);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -315,7 +327,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
|
||||
if (bufferedClasses.containsKey(scriptIndex)) {
|
||||
bufferedClasses.remove(scriptIndex);
|
||||
}
|
||||
if((scriptIndex!=-1)&&(abc!=null)){
|
||||
if ((scriptIndex != -1) && (abc != null)) {
|
||||
setScript(scriptIndex, abc, abcList);
|
||||
}
|
||||
setNoTrait();
|
||||
|
||||
@@ -31,6 +31,8 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class MethodBody implements Cloneable, Serializable {
|
||||
|
||||
@@ -70,8 +72,8 @@ public class MethodBody implements Cloneable, Serializable {
|
||||
code.restoreControlFlow(constants, this);
|
||||
}
|
||||
|
||||
public int removeTraps(ConstantPool constants, ABC abc) {
|
||||
return code.removeTraps(constants, this, abc);
|
||||
public int removeTraps(ConstantPool constants, ABC abc, int scriptIndex, int classIndex, boolean isStatic) {
|
||||
return code.removeTraps(constants, this, abc, scriptIndex, classIndex, isStatic);
|
||||
}
|
||||
|
||||
public HashMap<Integer, String> getLocalRegNames(ABC abc) {
|
||||
@@ -117,7 +119,11 @@ public class MethodBody implements Cloneable, Serializable {
|
||||
deobfuscated = b.code;
|
||||
deobfuscated.markMappedOffsets();
|
||||
if ((Boolean) Configuration.getConfig("autoDeobfuscate", true)) {
|
||||
deobfuscated.removeTraps(constants, b, abc);
|
||||
try {
|
||||
deobfuscated.removeTraps(constants, b, abc, scriptIndex, classIndex, isStatic);
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(MethodBody.class.getName()).log(Level.SEVERE, "Error during remove traps", ex);
|
||||
}
|
||||
}
|
||||
//deobfuscated.restoreControlFlow(constants, b);
|
||||
try {
|
||||
|
||||
@@ -32,6 +32,10 @@ public class ScriptInfo {
|
||||
public int init_index; //MethodInfo
|
||||
public Traits traits;
|
||||
|
||||
public int removeTraps(int scriptIndex, ABC abc) {
|
||||
return traits.removeTraps(scriptIndex, -1, true, abc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "method_index=" + init_index + "\r\n" + traits.toString();
|
||||
|
||||
@@ -138,4 +138,6 @@ public abstract class Trait implements Serializable {
|
||||
return abc.constants.constant_multiname[name_index];
|
||||
}
|
||||
}
|
||||
|
||||
public abstract int removeTraps(int scriptIndex, int classIndex, boolean isStatic, ABC abc);
|
||||
}
|
||||
|
||||
@@ -301,6 +301,7 @@ public class TraitClass extends Trait {
|
||||
|
||||
@Override
|
||||
public String convert(String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int scriptIndex, int classIndex, boolean highlight, List<String> fullyQualifiedNames) {
|
||||
|
||||
if (!highlight) {
|
||||
Highlighting.doHighlight = false;
|
||||
}
|
||||
@@ -314,7 +315,9 @@ public class TraitClass extends Trait {
|
||||
}
|
||||
|
||||
String packageName = abc.instance_info[class_info].getName(abc.constants).getNamespace(abc.constants).getName(abc.constants);
|
||||
|
||||
if (debugMode) {
|
||||
System.err.println("Decompiling " + packageName + "." + abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames));
|
||||
}
|
||||
List<String> namesInThisPackage = new ArrayList<String>();
|
||||
for (ABCContainerTag tag : abcTags) {
|
||||
for (ScriptInfo si : tag.getABC().script_info) {
|
||||
@@ -462,4 +465,20 @@ public class TraitClass extends Trait {
|
||||
public Multiname getName(ABC abc) {
|
||||
return abc.constants.constant_multiname[abc.instance_info[class_info].name_index];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int removeTraps(int scriptIndex, int classIndex, boolean isStatic, ABC abc) {
|
||||
int iInitializer = abc.findBodyIndex(abc.instance_info[class_info].iinit_index);
|
||||
int ret = 0;
|
||||
if (iInitializer != -1) {
|
||||
ret += abc.bodies[iInitializer].removeTraps(abc.constants, abc, scriptIndex, class_info, false);
|
||||
}
|
||||
int sInitializer = abc.findBodyIndex(abc.class_info[class_info].cinit_index);
|
||||
if (sInitializer != -1) {
|
||||
ret += abc.bodies[sInitializer].removeTraps(abc.constants, abc, scriptIndex, class_info, true);
|
||||
}
|
||||
ret += abc.instance_info[class_info].instance_traits.removeTraps(scriptIndex, class_info, false, abc);
|
||||
ret += abc.class_info[class_info].static_traits.removeTraps(scriptIndex, class_info, true, abc);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,4 +55,13 @@ public class TraitFunction extends Trait {
|
||||
return ABC.IDENT_STRING + ABC.IDENT_STRING + header + (abc.instance_info[classIndex].isInterface() ? ";" : " {\r\n" + bodyStr + "\r\n" + ABC.IDENT_STRING + ABC.IDENT_STRING + "}");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int removeTraps(int scriptIndex, int classIndex, boolean isStatic, ABC abc) {
|
||||
int bodyIndex = abc.findBodyIndex(method_info);
|
||||
if (bodyIndex != -1) {
|
||||
return abc.bodies[bodyIndex].removeTraps(abc.constants, abc, scriptIndex, classIndex, isStatic);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,4 +66,13 @@ public class TraitMethodGetterSetter extends Trait {
|
||||
}
|
||||
return ABC.IDENT_STRING + ABC.IDENT_STRING + header + ((classIndex != -1 && abc.instance_info[classIndex].isInterface()) ? ";" : " {\r\n" + bodyStr + "\r\n" + ABC.IDENT_STRING + ABC.IDENT_STRING + "}");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int removeTraps(int scriptIndex, int classIndex, boolean isStatic, ABC abc) {
|
||||
int bodyIndex = abc.findBodyIndex(method_info);
|
||||
if (bodyIndex != -1) {
|
||||
return abc.bodies[bodyIndex].removeTraps(abc.constants, abc, scriptIndex, classIndex, isStatic);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,4 +170,10 @@ public class TraitSlotConst extends Trait {
|
||||
public boolean isVar() {
|
||||
return kindType == TRAIT_SLOT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int removeTraps(int scriptIndex, int classIndex, boolean isStatic, ABC abc) {
|
||||
//do nothing
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,14 @@ public class Traits implements Serializable {
|
||||
|
||||
public Trait traits[] = new Trait[0];
|
||||
|
||||
public int removeTraps(int scriptIndex, int classIndex, boolean isStatic, ABC abc) {
|
||||
int ret = 0;
|
||||
for (Trait t : traits) {
|
||||
ret += t.removeTraps(scriptIndex, classIndex, isStatic, abc);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String s = "";
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.abc.avm2.treemodel.CommentTreeItem;
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.helpers.Highlighting;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EmptyStackException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
@@ -557,9 +558,20 @@ public class Graph {
|
||||
if ((ti = checkLoop(next, stopPart, loops)) != null) {
|
||||
ret.add(ti);
|
||||
} else {
|
||||
printGraph(localData, stack, allParts, parent, next, reversed ? sp1 : sp0, loops, forFinalCommands);
|
||||
GraphTargetItem second = stack.pop();
|
||||
GraphTargetItem first = stack.pop();
|
||||
GraphTargetItem second = null;
|
||||
if (first.isCompileTime() && (reversed == first.toBoolean())) {
|
||||
second = new TrueItem(null);
|
||||
} else {
|
||||
printGraph(localData, stack, allParts, parent, next, reversed ? sp1 : sp0, loops, forFinalCommands);
|
||||
try {
|
||||
second = stack.pop();
|
||||
} catch (EmptyStackException ese) {
|
||||
ese.printStackTrace();
|
||||
System.err.println(part.toString());
|
||||
System.out.println("" + first.isCompileTime() + first.toBoolean());
|
||||
}
|
||||
}
|
||||
if (!reversed) {
|
||||
AndItem a = new AndItem(null, first, second);
|
||||
stack.push(a);
|
||||
@@ -605,9 +617,16 @@ public class Graph {
|
||||
if ((ti = checkLoop(next, stopPart, loops)) != null) {
|
||||
ret.add(ti);
|
||||
} else {
|
||||
printGraph(localData, stack, allParts, parent, next, reversed ? sp1 : sp0, loops, forFinalCommands);
|
||||
GraphTargetItem second = stack.pop();
|
||||
GraphTargetItem first = stack.pop();
|
||||
GraphTargetItem second = null;
|
||||
if (first.isCompileTime() && (reversed == !first.toBoolean())) {
|
||||
second = new TrueItem(null);
|
||||
} else {
|
||||
printGraph(localData, stack, allParts, parent, next, reversed ? sp1 : sp0, loops, forFinalCommands);
|
||||
second = stack.pop();
|
||||
}
|
||||
|
||||
|
||||
if (reversed) {
|
||||
AndItem a = new AndItem(null, first, second);
|
||||
stack.push(a);
|
||||
|
||||
@@ -1161,7 +1161,7 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi
|
||||
it.setImage(data);
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, "message", ex);
|
||||
JOptionPane.showMessageDialog(null, "Invalid image.","Error",JOptionPane.ERROR_MESSAGE);
|
||||
JOptionPane.showMessageDialog(null, "Invalid image.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
reload(true);
|
||||
}
|
||||
@@ -1483,7 +1483,7 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi
|
||||
} else {
|
||||
int bi = abcPanel.detailPanel.methodTraitPanel.methodCodePanel.getBodyIndex();
|
||||
if (bi != -1) {
|
||||
cnt += abcPanel.abc.bodies[bi].removeTraps(abcPanel.abc.constants, abcPanel.abc);
|
||||
cnt += abcPanel.abc.bodies[bi].removeTraps(abcPanel.abc.constants, abcPanel.abc, abcPanel.decompiledTextArea.getScriptIndex(), abcPanel.decompiledTextArea.getClassIndex(), abcPanel.decompiledTextArea.getIsStatic());
|
||||
}
|
||||
abcPanel.detailPanel.methodTraitPanel.methodCodePanel.setBodyIndex(bi, abcPanel.abc);
|
||||
}
|
||||
@@ -1531,25 +1531,25 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi
|
||||
new SwingWorker() {
|
||||
@Override
|
||||
protected Object doInBackground() throws Exception {
|
||||
try{
|
||||
int cnt = 0;
|
||||
try {
|
||||
int cnt = 0;
|
||||
|
||||
if (abcPanel != null) {
|
||||
HashMap<String, String> namesMap = new HashMap<String, String>();
|
||||
for (ABCContainerTag tag : abcPanel.list) {
|
||||
cnt += tag.getABC().deobfuscateIdentifiers(namesMap);
|
||||
if (abcPanel != null) {
|
||||
HashMap<String, String> namesMap = new HashMap<String, String>();
|
||||
for (ABCContainerTag tag : abcPanel.list) {
|
||||
cnt += tag.getABC().deobfuscateIdentifiers(namesMap);
|
||||
}
|
||||
} else {
|
||||
cnt = swf.deobfuscateAS2Identifiers();
|
||||
}
|
||||
} else {
|
||||
cnt = swf.deobfuscateAS2Identifiers();
|
||||
}
|
||||
Main.stopWork();
|
||||
JOptionPane.showMessageDialog(null, "Identifiers renamed: " + cnt);
|
||||
if (abcPanel != null) {
|
||||
abcPanel.reload();
|
||||
}
|
||||
doFilter();
|
||||
reload(true);
|
||||
}catch(Exception ex){
|
||||
Main.stopWork();
|
||||
JOptionPane.showMessageDialog(null, "Identifiers renamed: " + cnt);
|
||||
if (abcPanel != null) {
|
||||
abcPanel.reload();
|
||||
}
|
||||
doFilter();
|
||||
reload(true);
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, "message", ex);
|
||||
}
|
||||
return true;
|
||||
@@ -1587,9 +1587,9 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi
|
||||
if (deobfuscationDialog.codeProcessingLevel.getValue() == DeobfuscationDialog.LEVEL_REMOVE_DEAD_CODE) {
|
||||
abcPanel.abc.bodies[bi].removeDeadCode(abcPanel.abc.constants);
|
||||
} else if (deobfuscationDialog.codeProcessingLevel.getValue() == DeobfuscationDialog.LEVEL_REMOVE_TRAPS) {
|
||||
abcPanel.abc.bodies[bi].removeTraps(abcPanel.abc.constants, abcPanel.abc);
|
||||
abcPanel.abc.bodies[bi].removeTraps(abcPanel.abc.constants, abcPanel.abc, abcPanel.decompiledTextArea.getScriptIndex(), abcPanel.decompiledTextArea.getClassIndex(), abcPanel.decompiledTextArea.getIsStatic());
|
||||
} else if (deobfuscationDialog.codeProcessingLevel.getValue() == DeobfuscationDialog.LEVEL_RESTORE_CONTROL_FLOW) {
|
||||
abcPanel.abc.bodies[bi].removeTraps(abcPanel.abc.constants, abcPanel.abc);
|
||||
abcPanel.abc.bodies[bi].removeTraps(abcPanel.abc.constants, abcPanel.abc, abcPanel.decompiledTextArea.getScriptIndex(), abcPanel.decompiledTextArea.getClassIndex(), abcPanel.decompiledTextArea.getIsStatic());
|
||||
abcPanel.abc.bodies[bi].restoreControlFlow(abcPanel.abc.constants);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user