AS1/2 better identifiers renaming (deobfuscation)

This commit is contained in:
Jindra Petk
2013-03-24 07:42:51 +01:00
parent d549856d49
commit 67dec09957
6 changed files with 37 additions and 2 deletions

View File

@@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash;
import SevenZip.Compression.LZMA.Encoder;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.ActionGraphSource;
import com.jpexs.decompiler.flash.action.special.ActionContainer;
import com.jpexs.decompiler.flash.action.swf4.ActionEquals;
import com.jpexs.decompiler.flash.action.swf4.ActionGetVariable;
import com.jpexs.decompiler.flash.action.swf4.ActionIf;
@@ -891,9 +892,15 @@ public class SWF {
name = stack.peek();
}
if ((ins instanceof ActionDefineFunction) || (ins instanceof ActionDefineFunction2)) {
functions.add(ins);
}
if (ins instanceof ActionContainer) {
getVariables(variables, functions, new ActionGraphSource(((ActionContainer) ins).getActions(), code.version, new HashMap<Integer, String>(), new HashMap<String, GraphTargetItem>(), new HashMap<String, GraphTargetItem>()), 0);
}
if ((ins instanceof ActionSetVariable) || (ins instanceof ActionSetMember) || (ins instanceof ActionDefineLocal)) {
name = stack.get(stack.size() - 2);
}
@@ -910,7 +917,11 @@ public class SWF {
constantPool = new ConstantPool(((ActionConstantPool) ins).constantPool);
}
ins.translate(localData, stack, output);
try {
ins.translate(localData, stack, output);
} catch (Exception ex) {
//ignore
}
if (ins.isExit()) {
break;
}

View File

@@ -542,7 +542,11 @@ public class SWFInputStream extends InputStream {
if (((ins instanceof ActionEquals) || (ins instanceof ActionEquals2)) && (stack.size() == 1) && (stack.peek() instanceof DirectValueTreeItem)) {
stack.push(new DirectValueTreeItem(null, 0, new Null(), new ArrayList<String>()));
}
ins.translate(localData, stack, output);
try {
ins.translate(localData, stack, output);
} catch (Exception ex) {
//ignore
}
if (ins.isExit()) {
break;
}

View File

@@ -1,5 +1,8 @@
package com.jpexs.decompiler.flash.action.special;
import com.jpexs.decompiler.flash.action.Action;
import java.util.List;
/**
*
* @author JPEXS
@@ -7,4 +10,6 @@ package com.jpexs.decompiler.flash.action.special;
public interface ActionContainer {
public byte[] getHeaderBytes();
public List<Action> getActions();
}

View File

@@ -49,6 +49,11 @@ public class ActionDefineFunction extends Action implements ActionContainer {
private int version;
public List<String> constantPool;
@Override
public List<Action> getActions() {
return code;
}
public void setConstantPool(List<String> constantPool) {
this.constantPool = constantPool;
for (Action a : code) {

View File

@@ -35,6 +35,11 @@ public class ActionWith extends Action implements ActionContainer {
public int size;
public int version;
@Override
public List<Action> getActions() {
return actions;
}
public ActionWith(SWFInputStream sis, int version) throws IOException {
super(0x94, 2);
size = sis.readUI16();

View File

@@ -60,6 +60,11 @@ public class ActionDefineFunction2 extends Action implements ActionContainer {
private int version;
public List<String> constantPool;
@Override
public List<Action> getActions() {
return code;
}
public void setConstantPool(List<String> constantPool) {
this.constantPool = constantPool;
for (Action a : code) {