Skip to content

Commit 3396417

Browse files
committed
removing duplicate definitions of isDecodeCall
1 parent 322e44d commit 3396417

3 files changed

Lines changed: 30 additions & 25 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package jadx.plugins.stringdecoder;
2+
3+
import java.util.Locale;
4+
5+
import jadx.core.dex.info.MethodInfo;
6+
import jadx.core.dex.instructions.InvokeNode;
7+
import jadx.core.dex.nodes.InsnNode;
8+
9+
/**
10+
* Recognises calls to {@code Base64.decode}-like methods: any invoke whose declaring class name
11+
* contains "base64" and whose method name contains "decode" (case-insensitive). A direct string
12+
* argument to such a call is strong evidence of intent, so callers decode it without heuristics.
13+
*/
14+
final class B64DecodeCalls {
15+
16+
private B64DecodeCalls() {
17+
}
18+
19+
/** True if {@code insn} is an invoke of a Base64.decode-like method. */
20+
static boolean isDecodeCall(InsnNode insn) {
21+
if (!(insn instanceof InvokeNode)) {
22+
return false;
23+
}
24+
MethodInfo mth = ((InvokeNode) insn).getCallMth();
25+
return mth.getDeclClass().getFullName().toLowerCase(Locale.ROOT).contains("base64")
26+
&& mth.getName().toLowerCase(Locale.ROOT).contains("decode");
27+
}
28+
}

src/main/java/jadx/plugins/stringdecoder/B64DeobfuscatePass.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import java.util.HashSet;
66
import java.util.LinkedHashMap;
77
import java.util.List;
8-
import java.util.Locale;
98
import java.util.Map;
109
import java.util.Set;
1110
import java.util.TreeMap;
@@ -22,7 +21,6 @@
2221
import jadx.core.codegen.utils.CodeComment;
2322
import jadx.core.dex.attributes.AFlag;
2423
import jadx.core.dex.attributes.AType;
25-
import jadx.core.dex.info.MethodInfo;
2624
import jadx.core.dex.instructions.ConstStringNode;
2725
import jadx.core.dex.instructions.FilledNewArrayNode;
2826
import jadx.core.dex.instructions.InvokeNode;
@@ -287,16 +285,7 @@ private static boolean isUsedAsBase64DecodeArg(ConstStringNode csn) {
287285
if (v == null) {
288286
return false;
289287
}
290-
return v.getUseList().stream().anyMatch(use -> isBase64DecodeCall(use.getParentInsn()));
291-
}
292-
293-
private static boolean isBase64DecodeCall(InsnNode insn) {
294-
if (!(insn instanceof InvokeNode)) {
295-
return false;
296-
}
297-
MethodInfo mth = ((InvokeNode) insn).getCallMth();
298-
return mth.getDeclClass().getFullName().toLowerCase(Locale.ROOT).contains("base64")
299-
&& mth.getName().toLowerCase(Locale.ROOT).contains("decode");
288+
return v.getUseList().stream().anyMatch(use -> B64DecodeCalls.isDecodeCall(use.getParentInsn()));
300289
}
301290

302291
private static Set<String> collectConstantValueFieldStrings(ClassNode cls) {

src/main/java/jadx/plugins/stringdecoder/B64FieldInitPass.java

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package jadx.plugins.stringdecoder;
22

3-
import java.util.Locale;
43
import java.util.TreeMap;
54

65
import jadx.api.plugins.input.data.annotations.EncodedType;
@@ -12,12 +11,10 @@
1211
import jadx.core.dex.attributes.AType;
1312
import jadx.core.dex.attributes.FieldInitInsnAttr;
1413
import jadx.core.dex.info.FieldInfo;
15-
import jadx.core.dex.info.MethodInfo;
1614
import jadx.core.dex.instructions.ConstStringNode;
1715
import jadx.core.dex.instructions.FilledNewArrayNode;
1816
import jadx.core.dex.instructions.IndexInsnNode;
1917
import jadx.core.dex.instructions.InsnType;
20-
import jadx.core.dex.instructions.InvokeNode;
2118
import jadx.core.dex.instructions.args.InsnArg;
2219
import jadx.core.dex.instructions.args.InsnWrapArg;
2320
import jadx.core.dex.instructions.args.RegisterArg;
@@ -142,7 +139,7 @@ private boolean findAndAnnotateInArgTree(FieldNode field, InsnNode insn, int dep
142139
if (insn == null || depth > MAX_ARG_TREE_DEPTH) {
143140
return false;
144141
}
145-
boolean isBase64Call = isBase64DecodeCall(insn);
142+
boolean isBase64Call = B64DecodeCalls.isDecodeCall(insn);
146143
for (int i = 0; i < insn.getArgsCount(); i++) {
147144
InsnNode argInsn = resolveArgInsn(insn.getArg(i));
148145
if (argInsn == null) {
@@ -225,13 +222,4 @@ private boolean annotateField(FieldNode field, String str, boolean forced) {
225222
field.addCodeComment(result.commentText());
226223
return true;
227224
}
228-
229-
private static boolean isBase64DecodeCall(InsnNode insn) {
230-
if (!(insn instanceof InvokeNode)) {
231-
return false;
232-
}
233-
MethodInfo mth = ((InvokeNode) insn).getCallMth();
234-
return mth.getDeclClass().getFullName().toLowerCase(Locale.ROOT).contains("base64")
235-
&& mth.getName().toLowerCase(Locale.ROOT).contains("decode");
236-
}
237225
}

0 commit comments

Comments
 (0)