Skip to content

Commit 27eaefd

Browse files
committed
field flow
1 parent 0fa7abd commit 27eaefd

File tree

4 files changed

+46
-32
lines changed

4 files changed

+46
-32
lines changed

deobfuscator-api/src/main/java/uwu/narumi/deobfuscator/api/asm/matcher/group/SequenceMatch.java

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@
1818
public class SequenceMatch extends Match {
1919

2020
private static final Match FRAME_MATCH = Match.of(context -> context.insn() instanceof FrameNode);
21-
private static final Match LABEL_MATCH = Match.of(context -> context.insn() instanceof LabelNode);
22-
private static final Match LINE_MATCH = Match.of(context -> context.insn() instanceof LineNumberNode);
2321

2422
private final Match[] matches;
25-
private final List<Match> skipMatches = new ArrayList<>(List.of(FRAME_MATCH, LABEL_MATCH, LINE_MATCH));
23+
private final List<Match> skipMatches = new ArrayList<>(List.of(FRAME_MATCH));
2624

2725
private SequenceMatch(Match[] matches) {
2826
this.matches = matches;
@@ -45,23 +43,6 @@ public SequenceMatch doNotSkipFrames() {
4543
return this;
4644
}
4745

48-
public SequenceMatch doNotSkipLabels() {
49-
this.skipMatches.remove(LABEL_MATCH);
50-
return this;
51-
}
52-
53-
public SequenceMatch doNotSkipLineNumbers() {
54-
this.skipMatches.remove(LINE_MATCH);
55-
return this;
56-
}
57-
58-
public SequenceMatch doNotSkip() {
59-
doNotSkipLabels();
60-
doNotSkipLabels();
61-
doNotSkipFrames();
62-
return this;
63-
}
64-
6546
@Override
6647
protected boolean test(MatchContext context) {
6748
AbstractInsnNode currentInsn = context.insn();

deobfuscator-transformers/src/main/java/uwu/narumi/deobfuscator/core/other/composed/Composed_qProtectTransformer.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import uwu.narumi.deobfuscator.core.other.composed.general.ComposedPeepholeCleanTransformer;
55
import uwu.narumi.deobfuscator.core.other.impl.clean.LocalVariableNamesCleanTransformer;
66
import uwu.narumi.deobfuscator.core.other.impl.pool.InlineStaticFieldTransformer;
7+
import uwu.narumi.deobfuscator.core.other.impl.qprotect.qProtectFieldFlowTransformer;
78
import uwu.narumi.deobfuscator.core.other.impl.qprotect.qProtectStringPoolTransformer;
89
import uwu.narumi.deobfuscator.core.other.impl.qprotect.qProtectStringTransformer;
910
import uwu.narumi.deobfuscator.core.other.impl.qprotect.qProtectTryCatchTransformer;
@@ -42,7 +43,10 @@ public Composed_qProtectTransformer() {
4243
InlineStaticFieldTransformer::new,
4344

4445
// Cleanup
45-
ComposedPeepholeCleanTransformer::new
46+
ComposedPeepholeCleanTransformer::new,
47+
48+
// Remove field flow after cleaning code from garbage, so we can do pattern matching
49+
qProtectFieldFlowTransformer::new
4650
);
4751
}
4852
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package uwu.narumi.deobfuscator.core.other.impl.qprotect;
2+
3+
import org.objectweb.asm.tree.FieldInsnNode;
4+
import uwu.narumi.deobfuscator.api.asm.MethodContext;
5+
import uwu.narumi.deobfuscator.api.asm.matcher.Match;
6+
import uwu.narumi.deobfuscator.api.asm.matcher.group.SequenceMatch;
7+
import uwu.narumi.deobfuscator.api.asm.matcher.impl.NumberMatch;
8+
import uwu.narumi.deobfuscator.api.asm.matcher.impl.OpcodeMatch;
9+
import uwu.narumi.deobfuscator.api.transformer.Transformer;
10+
11+
public class qProtectFieldFlowTransformer extends Transformer {
12+
private static final Match FIELD_FLOW_PATTERN = SequenceMatch.of(
13+
// Init variable through field
14+
NumberMatch.of(),
15+
OpcodeMatch.of(ISTORE),
16+
OpcodeMatch.of(ILOAD),
17+
OpcodeMatch.of(PUTSTATIC).capture("field"),
18+
// Compare
19+
NumberMatch.of(),
20+
OpcodeMatch.of(GETSTATIC),
21+
OpcodeMatch.of(IF_ICMPGT)
22+
);
23+
24+
@Override
25+
protected void transform() throws Exception {
26+
scopedClasses().forEach(classWrapper -> {
27+
classWrapper.methods().forEach(methodNode -> {
28+
MethodContext methodContext = MethodContext.frameless(classWrapper, methodNode);
29+
FIELD_FLOW_PATTERN.findAllMatches(methodContext).forEach(match -> {
30+
FieldInsnNode fieldInsn = (FieldInsnNode) match.captures().get("field").insn();
31+
32+
// Remove field flow
33+
match.removeAll();
34+
});
35+
});
36+
});
37+
}
38+
}

testData/results/custom-classes/qprotect/sample1/XML.dec

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,6 @@ public class XML {
5757
var1.appendCodePoint(var3);
5858
}
5959
}
60-
61-
int var5 = 287930431;
62-
IIlllllIIIllllIl = var5;
63-
if (1280687910 <= IIlllllIIIllllIl) {
64-
}
6560
}
6661

6762
return var1.toString();
@@ -234,10 +229,6 @@ public class XML {
234229
if (var3.getForceList().contains(var9)) {
235230
if (var7.length() == 0) {
236231
var1.put(var9, new JSONArray());
237-
int var14 = 625409678;
238-
IIlllllIIIllllIl = var14;
239-
if (1222458921 <= IIlllllIIIllllIl) {
240-
}
241232
} else if (var7.length() == 1 && var7.opt(var3.getcDataTagName()) != null) {
242233
var1.append(var9, var7.opt(var3.getcDataTagName()));
243234
} else {
@@ -247,8 +238,8 @@ public class XML {
247238
var1.accumulate(var9, "");
248239
} else if (var7.length() == 1 && var7.opt(var3.getcDataTagName()) != null) {
249240
var1.accumulate(var9, var7.opt(var3.getcDataTagName()));
250-
int var23 = 19118812;
251-
IIlllllIIIllllIl = var23;
241+
int var14 = 19118812;
242+
IIlllllIIIllllIl = var14;
252243
if (333213067 < IIlllllIIIllllIl) {
253244
}
254245
} else {

0 commit comments

Comments
 (0)