Issues #238,#239,#240 Fixed deobfuscation

This commit is contained in:
Jindra Petk
2013-07-16 13:04:29 +02:00
parent 79726bea22
commit 38bb6513d8
6 changed files with 18 additions and 10 deletions

View File

@@ -1552,7 +1552,7 @@ public class SWF {
if (ins instanceof ActionConstantPool) {
constantPool = new ConstantPool(((ActionConstantPool) ins).constantPool);
}
int staticOperation = (Boolean) Configuration.getConfig("autoDeobfuscate", true) ? Graph.SOP_SKIP_STATIC : Graph.SOP_USE_STATIC;
int staticOperation = Graph.SOP_USE_STATIC; //(Boolean) Configuration.getConfig("autoDeobfuscate", true) ? Graph.SOP_SKIP_STATIC : Graph.SOP_USE_STATIC;
try {
ins.translate(localData, stack, output, staticOperation, path);
@@ -1825,7 +1825,7 @@ public class SWF {
classNameParts = new String[]{className};
}
}
int staticOperation = (Boolean) Configuration.getConfig("autoDeobfuscate", true) ? Graph.SOP_SKIP_STATIC : Graph.SOP_USE_STATIC;
int staticOperation = Graph.SOP_USE_STATIC; //(Boolean) Configuration.getConfig("autoDeobfuscate", true) ? Graph.SOP_SKIP_STATIC : Graph.SOP_USE_STATIC;
List<GraphTargetItem> dec = Action.actionsToTree(dia.getActions(version), version, staticOperation, ""/*FIXME*/);
GraphTargetItem name = null;
for (GraphTargetItem it : dec) {

View File

@@ -624,7 +624,7 @@ public class SWFInputStream extends InputStream {
stack.push(new DirectValueActionItem(null, 0, new Null(), new ArrayList<String>()));
}
try {
ins.translate(localData, stack, output, Graph.SOP_SKIP_STATIC, null);
ins.translate(localData, stack, output, Graph.SOP_USE_STATIC/*Graph.SOP_SKIP_STATIC*/, null);
} catch (Exception ex) {
Logger.getLogger(SWFInputStream.class.getName()).log(Level.SEVERE, "Error during getting constantpool", ex);
}
@@ -1021,7 +1021,7 @@ public class SWFInputStream extends InputStream {
if ((a instanceof ActionStoreRegister) && stack.isEmpty()) {
stack.push(new DirectValueActionItem(null, 0, new Null(), new ArrayList<String>()));
}
a.translate(localData, stack, output, Graph.SOP_SKIP_STATIC, path);
a.translate(localData, stack, output, Graph.SOP_USE_STATIC/*Graph.SOP_SKIP_STATIC*/, path);
}
}
} catch (RuntimeException ex) {

View File

@@ -795,7 +795,7 @@ public class AVM2Code implements Serializable {
if (ins.definition instanceof IfTypeIns) {
t = new PopIns().instructionName + "\n";
if (fixBranch == 0) { //jump
t = new JumpIns().instructionName + " ofs" + Helper.formatAddress(ofs + ins.getBytes().length + ins.operands[0]);
t += new JumpIns().instructionName + " ofs" + Helper.formatAddress(ofs + ins.getBytes().length + ins.operands[0]);
} else {
//nojump, ignore
}
@@ -1483,7 +1483,7 @@ public class AVM2Code implements Serializable {
localData.add(new ArrayList<Integer>());
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, path);
ret += removeTraps(constants, body, localData, new AVM2GraphSource(this, false, -1, -1, new HashMap<Integer, GraphTargetItem>(), new Stack<GraphTargetItem>(), abc, body, new HashMap<Integer, String>(), new ArrayList<String>()), 0, path);
removeIgnored(constants, body);
removeDeadCode(constants, body);
@@ -2203,13 +2203,15 @@ public class AVM2Code implements Serializable {
return ret;
}
public static int removeTraps(List<Object> localData, AVM2GraphSource code, int addr, String path) {
public static int removeTraps(ConstantPool constants, MethodBody body, List<Object> localData, AVM2GraphSource code, int addr, String path) {
HashMap<GraphSourceItem, AVM2Code.Decision> decisions = new HashMap<>();
HashMap<Integer, List<Integer>> refs = new HashMap<>();
code.getCode().visitCode(0, code.size() - 1, refs);
removeTraps(refs, false, false, localData, new Stack<GraphTargetItem>(), new ArrayList<GraphTargetItem>(), code, code.adr2pos(addr), new HashMap<Integer, Integer>(), new HashMap<Integer, HashMap<Integer, GraphTargetItem>>(), decisions, path);
localData.set(2, new HashMap<Integer, GraphTargetItem>());
return removeTraps(refs, true, false, localData, new Stack<GraphTargetItem>(), new ArrayList<GraphTargetItem>(), code, code.adr2pos(addr), new HashMap<Integer, Integer>(), new HashMap<Integer, HashMap<Integer, GraphTargetItem>>(), decisions, path);
int cnt = removeTraps(refs, true, false, localData, new Stack<GraphTargetItem>(), new ArrayList<GraphTargetItem>(), code, code.adr2pos(addr), new HashMap<Integer, Integer>(), new HashMap<Integer, HashMap<Integer, GraphTargetItem>>(), decisions, path);
code.getCode().removeIgnored(constants, body);
return cnt;
}
/*public static int removeTraps(List<Object> localData, AVM2GraphSource code, int addr) {
AVM2Graph.translateViaGraph(localData, "", code, new ArrayList<Integer>(), Graph.SOP_REMOVE_STATIC);

View File

@@ -174,7 +174,11 @@ public class AVM2Instruction implements Serializable, GraphSourceItem {
s.append(" m[");
s.append(operands[i]);
s.append("]\"");
s.append(Helper.escapeString(constants.constant_multiname[operands[i]].toString(constants, fullyQualifiedNames)));
if (constants.constant_multiname[operands[i]] == null) {
s.append("");
} else {
s.append(Helper.escapeString(constants.constant_multiname[operands[i]].toString(constants, fullyQualifiedNames)));
}
s.append("\"");
break;
case AVM2Code.DAT_STRING_INDEX:

View File

@@ -690,7 +690,7 @@ public class Action implements GraphSourceItem {
public static String actionsToSource(List<Action> actions, int version, String path) {
try {
//List<ActionItem> tree = actionsToTree(new HashMap<Integer, String>(), actions, version);
int staticOperation = (Boolean) Configuration.getConfig("autoDeobfuscate", true) ? Graph.SOP_SKIP_STATIC : Graph.SOP_USE_STATIC;
int staticOperation = Graph.SOP_USE_STATIC; //(Boolean) Configuration.getConfig("autoDeobfuscate", true) ? Graph.SOP_SKIP_STATIC : Graph.SOP_USE_STATIC;
List<GraphTargetItem> tree = actionsToTree(new HashMap<Integer, String>(), new HashMap<String, GraphTargetItem>(), new HashMap<String, GraphTargetItem>(), actions, version, staticOperation, path);

View File

@@ -48,6 +48,7 @@ import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Locale;
import java.util.Properties;
import java.util.logging.ConsoleHandler;
import java.util.logging.FileHandler;
@@ -464,6 +465,7 @@ public class Main {
* @throws IOException
*/
public static void main(String[] args) throws IOException {
Locale.setDefault(Locale.GERMAN);
loadProperties();
View.setLookAndFeel();
Configuration.loadFromFile(getConfigFile(), getReplacementsFile());