as2 deobfuscator fix when calculated value is out of supported range (SI32 or string contains 0 character)

This commit is contained in:
honfika@gmail.com
2015-06-14 08:39:04 +02:00
parent e05d50c89d
commit 4976184cc3
2 changed files with 26 additions and 1 deletions

View File

@@ -150,7 +150,15 @@ public class ActionDeobfuscator extends ActionDeobfuscatorSimple {
}
newIstructionCount += 2 * result.variables.size();
if (newIstructionCount * 2 < result.instructionsProcessed) {
boolean allValueValid = true;
for (Object value : result.variables.values()) {
if (!ActionPush.isValidValue(value)) {
allValueValid = false;
break;
}
}
if (allValueValid && newIstructionCount * 2 < result.instructionsProcessed) {
Action target = actions.get(result.idx);
Action prevAction = actions.get(i);

View File

@@ -186,6 +186,23 @@ public class ActionPush extends Action {
return surroundWithAction(baos.toByteArray(), version);
}
public static boolean isValidValue(Object value) {
if (value instanceof String) {
for (char ch : ((String) value).toCharArray()) {
if (ch == 0) {
return false;
}
}
}
if (value instanceof Long) {
long l = (Long) value;
if (l < 0x8000000 || l > 0x7ffffff) {
return false;
}
}
return true;
}
public ActionPush(Object value) {
super(0x96, 0);
this.values = new ArrayList<>();