Using new deobfuscation method in GUI deobfuscation dialog too.

This commit is contained in:
Jindra Petřík
2015-07-06 10:21:20 +02:00
parent 25112542fe
commit 9fcc4fa394
2 changed files with 21 additions and 14 deletions

View File

@@ -21,6 +21,9 @@ import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.ABCInputStream;
import com.jpexs.decompiler.flash.abc.AVM2LocalData;
import com.jpexs.decompiler.flash.abc.CopyOutputStream;
import com.jpexs.decompiler.flash.abc.avm2.deobfuscation.AVM2DeobfuscatorJumps;
import com.jpexs.decompiler.flash.abc.avm2.deobfuscation.AVM2DeobfuscatorRegisters;
import com.jpexs.decompiler.flash.abc.avm2.deobfuscation.AVM2DeobfuscatorSimple;
import com.jpexs.decompiler.flash.abc.avm2.graph.AVM2Graph;
import com.jpexs.decompiler.flash.abc.avm2.graph.AVM2GraphSource;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
@@ -2189,7 +2192,7 @@ public class AVM2Code implements Cloneable {
return ret;
}
public int removeTraps(AVM2ConstantPool constants, Trait trait, MethodInfo info, MethodBody body, ABC abc, int scriptIndex, int classIndex, boolean isStatic, String path) throws InterruptedException {
private int removeTrapsOld(AVM2ConstantPool constants, Trait trait, MethodInfo info, MethodBody body, ABC abc, int scriptIndex, int classIndex, boolean isStatic, String path) throws InterruptedException {
removeDeadCode(constants, trait, info, body);
AVM2LocalData localData = new AVM2LocalData();
localData.isStatic = isStatic;
@@ -2220,6 +2223,18 @@ public class AVM2Code implements Cloneable {
return ret;
}
public int removeTraps(AVM2ConstantPool constants, Trait trait, MethodInfo info, MethodBody body, ABC abc, int scriptIndex, int classIndex, boolean isStatic, String path) throws InterruptedException {
if (Configuration.deobfuscationOldMode.get()) {
return removeTrapsOld(constants, trait, info, body, abc, scriptIndex, classIndex, isStatic, path);
} else {
new AVM2DeobfuscatorSimple().deobfuscate(path, classIndex, isStatic, scriptIndex, abc, constants, trait, info, body);
new AVM2DeobfuscatorRegisters().deobfuscate(path, classIndex, isStatic, scriptIndex, abc, constants, trait, info, body);
new AVM2DeobfuscatorJumps().deobfuscate(path, classIndex, isStatic, scriptIndex, abc, constants, trait, info, body);
body.getCode().checkValidOffsets(body); // todo: only for debugging. checkValidOffsets can be made private later
return 1;
}
}
private void handleRegister(CodeStats stats, int reg) {
if (reg + 1 > stats.maxlocal) {
stats.maxlocal = reg + 1;

View File

@@ -173,6 +173,7 @@ public final class MethodBody implements Cloneable {
}
public int removeTraps(AVM2ConstantPool constants, ABC abc, Trait trait, int scriptIndex, int classIndex, boolean isStatic, String path) throws InterruptedException {
return getCode().removeTraps(constants, trait, abc.method_info.get(method_info), this, abc, scriptIndex, classIndex, isStatic, path);
}
@@ -341,20 +342,11 @@ public final class MethodBody implements Cloneable {
body.getCode().markMappedOffsets();
if (Configuration.autoDeobfuscate.get()) {
if (Configuration.deobfuscationOldMode.get()) {
try {
body.getCode().removeTraps(constants, trait, method_info.get(this.method_info), body, abc, scriptIndex, classIndex, isStatic, path);
} catch (Throwable ex) {
logger.log(Level.SEVERE, "Error during old deobfuscation: " + path, ex);
}
} else {
new AVM2DeobfuscatorSimple().deobfuscate(path, classIndex, isStatic, scriptIndex, abc, constants, trait, method_info.get(this.method_info), body);
new AVM2DeobfuscatorRegisters().deobfuscate(path, classIndex, isStatic, scriptIndex, abc, constants, trait, method_info.get(this.method_info), body);
new AVM2DeobfuscatorJumps().deobfuscate(path, classIndex, isStatic, scriptIndex, abc, constants, trait, method_info.get(this.method_info), body);
try {
body.getCode().removeTraps(constants, trait, method_info.get(this.method_info), body, abc, scriptIndex, classIndex, isStatic, path);
} catch (Throwable ex) {
logger.log(Level.SEVERE, "Error during deobfuscation: " + path, ex);
}
// todo: only for debugging. checkValidOffsets can be made private later
body.getCode().checkValidOffsets(body);
}
return body;