Issue #137 AS3 deobfuscation fix

This commit is contained in:
Jindra Petk
2013-07-19 22:33:13 +02:00
parent ef2197f8dc
commit cc1e1c2377
3 changed files with 6 additions and 5 deletions

View File

@@ -1468,7 +1468,7 @@ public class AVM2Code implements Serializable {
code.add(pos, instruction);
}
public int removeTraps(ConstantPool constants, MethodBody body, ABC abc, int scriptIndex, int classIndex, boolean isStatic, String path, HashMap<Integer, List<Integer>> refs) {
public int removeTraps(ConstantPool constants, MethodBody body, ABC abc, int scriptIndex, int classIndex, boolean isStatic, String path) {
removeDeadCode(constants, body);
List<Object> localData = new ArrayList<>();
localData.add((Boolean) isStatic); //isStatic
@@ -1487,6 +1487,7 @@ public class AVM2Code implements Serializable {
localData.add((Integer) (scriptIndex));
localData.add(new HashMap<Integer, Integer>()); //localRegAssignmentIps
localData.add(Integer.valueOf(0));
HashMap<Integer, List<Integer>> refs = visitCode(body);
localData.add(refs);
localData.add(this);
int ret = 0;
@@ -2109,7 +2110,7 @@ public class AVM2Code implements Serializable {
return true;
}
if (visited.contains(currentIp)) {
return false;
return true;
}
visited.add(currentIp);
if (refs.containsKey(currentIp)) {

View File

@@ -51,7 +51,7 @@ public abstract class SetLocalTypeIns extends InstructionDefinition implements S
int regId = getRegisterId(ins);
GraphTargetItem value = (GraphTargetItem) stack.pop();
if (localRegs.containsKey(regId)) {
localRegs.put(regId, new NotCompileTimeAVM2Item(ins, value));
localRegs.put(regId, new NotCompileTimeAVM2Item(ins, value));
} else {
localRegs.put(regId, value);
}

View File

@@ -74,7 +74,7 @@ public class MethodBody implements Cloneable, Serializable {
}
public int removeTraps(ConstantPool constants, ABC abc, int scriptIndex, int classIndex, boolean isStatic, String path) {
return code.removeTraps(constants, this, abc, scriptIndex, classIndex, isStatic, path, code.visitCode(this));
return code.removeTraps(constants, this, abc, scriptIndex, classIndex, isStatic, path);
}
public HashMap<Integer, String> getLocalRegNames(ABC abc) {
@@ -124,7 +124,7 @@ public class MethodBody implements Cloneable, Serializable {
deobfuscated.markMappedOffsets();
if ((Boolean) Configuration.getConfig("autoDeobfuscate", true)) {
try {
deobfuscated.removeTraps(constants, b, abc, scriptIndex, classIndex, isStatic, path, deobfuscated.visitCode(b));
deobfuscated.removeTraps(constants, b, abc, scriptIndex, classIndex, isStatic, path);
} catch (Exception ex) {
Logger.getLogger(MethodBody.class.getName()).log(Level.SEVERE, "Error during remove traps", ex);
}