Skip to content

Commit e3ec48b

Browse files
committed
claude simpliy run
1 parent 6b46663 commit e3ec48b

2 files changed

Lines changed: 9 additions & 33 deletions

File tree

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,15 @@ public static B64Result detect(String str, B64DeobfuscateOptions options) {
6060
}
6161

6262
private static B64Result tryDecode(String str, B64DeobfuscateOptions options) {
63-
for (int i = 0; i < STANDARD_AND_URL.length; i++) {
64-
B64Result result = attemptDecode(STANDARD_AND_URL[i], str, options, STANDARD_AND_URL_TAGS[i]);
63+
boolean hasLineBreaks = str.indexOf('\n') >= 0 || str.indexOf('\r') >= 0;
64+
Base64.Decoder[] decoders = hasLineBreaks ? ALL_DECODERS : STANDARD_AND_URL;
65+
String[] tags = hasLineBreaks ? ALL_DECODER_TAGS : STANDARD_AND_URL_TAGS;
66+
for (int i = 0; i < decoders.length; i++) {
67+
B64Result result = attemptDecode(decoders[i], str, options, tags[i]);
6568
if (result != null) {
6669
return result;
6770
}
6871
}
69-
// MIME decoder ignores embedded whitespace (PEM line-wrapped Base64)
70-
if (str.indexOf('\n') >= 0 || str.indexOf('\r') >= 0) {
71-
return attemptDecode(Base64.getMimeDecoder(), str, options, "mime");
72-
}
7372
return null;
7473
}
7574

@@ -101,7 +100,7 @@ private static B64Result attemptDecode(Base64.Decoder decoder, String str, B64De
101100

102101
// Counts printable ASCII (32-126) plus common whitespace (\t, \n, \r) as printable.
103102
// Non-ASCII Unicode chars (e.g. Hebrew letters from garbage decodes) do not count.
104-
private static boolean isPrintable(String str, double minRatio) {
103+
static boolean isPrintable(String str, double minRatio) {
105104
if (str.isEmpty()) {
106105
return false;
107106
}

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

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,10 @@ private void processField(FieldNode field) {
6060
}
6161
FilledNewArrayNode filledArr = (FilledNewArrayNode) insn;
6262
ArgType elemType = filledArr.getElemType();
63-
byte[] bytes;
64-
if (ArgType.BYTE.equals(elemType)) {
65-
bytes = extractLiteralBytes(filledArr);
66-
} else if (ArgType.INT.equals(elemType)) {
67-
bytes = extractIntAsAsciiBytes(filledArr);
68-
} else {
63+
if (!ArgType.BYTE.equals(elemType) && !ArgType.INT.equals(elemType)) {
6964
return;
7065
}
66+
byte[] bytes = extractLiteralBytes(filledArr);
7167
if (bytes == null || bytes.length == 0) {
7268
return;
7369
}
@@ -78,19 +74,6 @@ private void processField(FieldNode field) {
7874
}
7975

8076
private static byte[] extractLiteralBytes(FilledNewArrayNode insn) {
81-
int count = insn.getArgsCount();
82-
byte[] bytes = new byte[count];
83-
for (int i = 0; i < count; i++) {
84-
InsnArg arg = insn.getArg(i);
85-
if (!(arg instanceof LiteralArg)) {
86-
return null;
87-
}
88-
bytes[i] = (byte) ((LiteralArg) arg).getLiteral();
89-
}
90-
return bytes;
91-
}
92-
93-
private static byte[] extractIntAsAsciiBytes(FilledNewArrayNode insn) {
9477
int count = insn.getArgsCount();
9578
byte[] bytes = new byte[count];
9679
for (int i = 0; i < count; i++) {
@@ -113,13 +96,7 @@ private String tryDecodeAsString(byte[] bytes) {
11396
.onMalformedInput(CodingErrorAction.REPORT)
11497
.onUnmappableCharacter(CodingErrorAction.REPORT);
11598
String decoded = utf8.decode(ByteBuffer.wrap(bytes)).toString();
116-
if (decoded.isEmpty()) {
117-
return null;
118-
}
119-
long printableCount = decoded.chars()
120-
.filter(c -> (c >= 32 && c <= 126) || c == '\t' || c == '\n' || c == '\r')
121-
.count();
122-
if ((double) printableCount / decoded.length() < options.getByteArrayMinPrintableRatio()) {
99+
if (!B64Detector.isPrintable(decoded, options.getByteArrayMinPrintableRatio())) {
123100
return null;
124101
}
125102
int minDecoded = options.getMinDecodedLength();

0 commit comments

Comments
 (0)