Merge origin/master

This commit is contained in:
honfika@gmail.com
2016-06-03 15:45:47 +02:00
4 changed files with 22 additions and 8 deletions

View File

@@ -155,6 +155,16 @@ public class AVM2DeobfuscatorSimpleOld extends SWFDecompilerAdapter {
return false;
}
// find jump targets
List<Integer> jumpTargets = new ArrayList<Integer>();
for (int i = 0; i < code.code.size(); i++) {
AVM2Instruction ins = code.code.get(i);
if (ins.definition instanceof JumpIns) {
long address = ins.getTargetAddress();
jumpTargets.add( code.adr2pos(address) );
}
}
AVM2LocalData localData = newLocalData(scriptIndex, abc, abc.constants, body, isStatic, classIndex);
int localReservedCount = body.getLocalReservedCount();
for (int i = 0; i < code.code.size(); i++) {
@@ -168,7 +178,7 @@ public class AVM2DeobfuscatorSimpleOld extends SWFDecompilerAdapter {
localData.localRegs.clear();
initLocalRegs(localData, localReservedCount, body.max_regs);
executeInstructions(staticRegs, body, abc, code, localData, i, code.code.size() - 1, null, inlineIns);
executeInstructions(staticRegs, body, abc, code, localData, i, code.code.size() - 1, null, inlineIns, jumpTargets);
}
return false;
@@ -218,7 +228,7 @@ public class AVM2DeobfuscatorSimpleOld extends SWFDecompilerAdapter {
}
}
private void executeInstructions(Map<Integer, GraphTargetItem> staticRegs, MethodBody body, ABC abc, AVM2Code code, AVM2LocalData localData, int idx, int endIdx, ExecutionResult result, List<AVM2Instruction> inlineIns) throws InterruptedException {
private void executeInstructions(Map<Integer, GraphTargetItem> staticRegs, MethodBody body, ABC abc, AVM2Code code, AVM2LocalData localData, int idx, int endIdx, ExecutionResult result, List<AVM2Instruction> inlineIns, List<Integer> jumpTargets) throws InterruptedException {
List<GraphTargetItem> output = new ArrayList<>();
FixItemCounterTranslateStack stack = new FixItemCounterTranslateStack("");
@@ -284,9 +294,13 @@ public class AVM2DeobfuscatorSimpleOld extends SWFDecompilerAdapter {
if (inlineIns.contains(ins)) {
if (def instanceof SetLocalTypeIns) {
int regId = ((SetLocalTypeIns) def).getRegisterId(ins);
staticRegs.put(regId, localData.localRegs.get(regId).getNotCoerced());
code.replaceInstruction(idx, new AVM2Instruction(0, DeobfuscatePopIns.getInstance(), null), body);
InstructionDefinition prevDef = code.code.get(idx-1).definition;
if ((prevDef instanceof DupIns && !jumpTargets.contains(idx-2)) || !jumpTargets.contains(idx-1))
{
int regId = ((SetLocalTypeIns) def).getRegisterId(ins);
staticRegs.put(regId, localData.localRegs.get(regId).getNotCoerced());
code.replaceInstruction(idx, new AVM2Instruction(0, DeobfuscatePopIns.getInstance(), null), body);
}
}
}
if (def instanceof GetLocalTypeIns) {

View File

@@ -39,7 +39,7 @@ public class NewFunctionIns extends InstructionDefinition {
@Override
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
int methodIndex = ins.operands[0];
NewFunctionAVM2Item function = new NewFunctionAVM2Item(ins, localData.lineStartInstruction, "", path, localData.isStatic, localData.scriptIndex, localData.classIndex, localData.abc, localData.fullyQualifiedNames, methodIndex);
NewFunctionAVM2Item function = new NewFunctionAVM2Item(ins, localData.lineStartInstruction, "", path, false, localData.scriptIndex, localData.classIndex, localData.abc, localData.fullyQualifiedNames, methodIndex);
stack.push(function);
}

View File

@@ -108,6 +108,8 @@ public abstract class AVM2Item extends GraphTargetItem {
}
if (propertyName instanceof FullMultinameAVM2Item) {
if (((FullMultinameAVM2Item) propertyName).name != null) {
if (((FullMultinameAVM2Item) propertyName).namespace != null)
writer.append(".");
return propertyName.toString(writer, localData);
} else {
writer.append(".");

View File

@@ -60,8 +60,6 @@ public class RegExpAvm2Item extends AVM2Item implements Callable {
ret.append("\\b");
} else if (c == '\f') {
ret.append("\\f");
} else if (c == '/') {
ret.append("\\/");
} else if (c < 32) {
ret.append("\\x").append(Helper.byteToHex((byte) c));
} else {