Issue #1244 Remove unknown actions when deobfuscation is enabled

This commit is contained in:
honfika@gmail.com
2016-05-29 07:23:16 +02:00
parent aa117d7c75
commit d000457330
4 changed files with 22 additions and 15 deletions

View File

@@ -22,7 +22,6 @@ import com.jpexs.decompiler.flash.action.deobfuscation.ActionDeobfuscator;
import com.jpexs.decompiler.flash.action.model.ConstantPool;
import com.jpexs.decompiler.flash.action.special.ActionDeobfuscateJump;
import com.jpexs.decompiler.flash.action.special.ActionEnd;
import com.jpexs.decompiler.flash.action.special.ActionNop;
import com.jpexs.decompiler.flash.action.special.ActionStore;
import com.jpexs.decompiler.flash.action.special.ActionUnknown;
import com.jpexs.decompiler.flash.action.swf4.ActionIf;
@@ -821,17 +820,6 @@ public class ActionListReader {
int actionLengthWithHeader = a.getTotalActionLength();
// unknown action, replace with jump
if (a instanceof ActionNop) {
ActionJump aJump = new ActionDeobfuscateJump(0);
int jumpLength = aJump.getTotalActionLength();
aJump.setAddress(a.getAddress());
//FIXME! This offset can be larger than SI16 value!
aJump.setJumpOffset(actionLengthWithHeader - jumpLength);
a = aJump;
actionLengthWithHeader = a.getTotalActionLength();
}
Action existingAction = actionMap.get(ip);
if (existingAction != null) {
break;

View File

@@ -101,6 +101,7 @@ public class ActionDeobfuscator extends SWFDecompilerAdapter {
@Override
public void actionListParsed(ActionList actions, SWF swf) throws InterruptedException {
FastActionList fastActions = new FastActionList(actions);
fastActions.removeUnknownActions();
fastActions.expandPushes();
Map<String, Object> fakeFunctions = getFakeFunctionResults(fastActions);
boolean changed = true;
@@ -466,9 +467,9 @@ public class ActionDeobfuscator extends SWFDecompilerAdapter {
Action action = item.action;
/*System.out.print(action.getASMSource(actions, new ArrayList<Long>(), ScriptExportMode.PCODE));
for (int j = 0; j < stack.size(); j++) {
for (int j = 0; j < stack.size(); j++) {
System.out.print(" '" + stack.get(j).getResult() + "'");
}
}
System.out.println();*/
if (action instanceof ActionConstantPool) {
lastConstantPool = (ActionConstantPool) action;

View File

@@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.fastactionlist;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.ActionList;
import com.jpexs.decompiler.flash.action.special.ActionStore;
import com.jpexs.decompiler.flash.action.special.ActionUnknown;
import com.jpexs.decompiler.flash.action.swf4.ActionIf;
import com.jpexs.decompiler.flash.action.swf4.ActionJump;
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
@@ -402,6 +403,23 @@ public class FastActionList implements Collection<ActionItem> {
} while (item != firstItem);
}
public void removeUnknownActions() {
ActionItem item = firstItem;
if (item == null) {
return;
}
do {
Action action = item.action;
if (action instanceof ActionUnknown) {
item = removeItem(item);
continue;
}
item = item.next;
} while (item != firstItem);
}
public void removeZeroJumps() {
ActionItem item = firstItem;
if (item == null) {