Skip to content

Commit 167b223

Browse files
committed
remove minInputLength option in favour of minDecodedLength
1 parent 3ec7c95 commit 167b223

5 files changed

Lines changed: 6 additions & 27 deletions

File tree

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

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ public class B64DeobfuscateOptions extends BasePluginOptionsBuilder {
77
private boolean enable;
88
private boolean enableByteArrayStringPass;
99
private int byteArrayMinPrintablePercent;
10-
private int minInputLength;
1110
private int minDecodedLength;
1211
private int maxCommentLength;
1312
private int minPrintablePercent;
@@ -23,19 +22,14 @@ public void registerOptions() {
2322
.defaultValue(100)
2423
.setter(v -> maxCommentLength = v);
2524
intOption(JadxStringDecoderPlugin.PLUGIN_ID + ".minDecodedLength")
26-
.description("Minimum decoded string length to add a comment (0 = disabled); rejects very short decoded outputs")
25+
.description("Minimum decoded string length to add a comment (0 = disabled); helps reject short garbage decodes")
2726
.defaultValue(0)
2827
.setter(v -> minDecodedLength = v);
29-
3028
// B64DeobfuscatePass options
3129
boolOption(JadxStringDecoderPlugin.PLUGIN_ID + ".enableB64DecodePass")
3230
.description("Enable Base64 string detection and decoding")
3331
.defaultValue(true)
3432
.setter(v -> enable = v);
35-
intOption(JadxStringDecoderPlugin.PLUGIN_ID + ".minInputLength")
36-
.description("Minimum length of an encoded string to be considered for decoding")
37-
.defaultValue(8)
38-
.setter(v -> minInputLength = v);
3933
intOption(JadxStringDecoderPlugin.PLUGIN_ID + ".minPrintablePercent")
4034
.description("Minimum percentage of printable ASCII chars in decoded string (0-100); higher values reduce false positives")
4135
.defaultValue(90)
@@ -76,10 +70,6 @@ public double getByteArrayMinPrintableRatio() {
7670
return byteArrayMinPrintablePercent / 100.0;
7771
}
7872

79-
public int getMinInputLength() {
80-
return minInputLength;
81-
}
82-
8373
public int getMaxCommentLength() {
8474
return maxCommentLength;
8575
}

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ public static B64Result detect(String str, B64DeobfuscateOptions options) {
3131
if (B64FalsePositives.contains(str)) {
3232
return null;
3333
}
34-
if (str.length() < options.getMinInputLength()) {
35-
return null;
36-
}
3734
if (options.isRequireValidLength() && str.length() % 4 != 0) {
3835
return null;
3936
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ private void processField(FieldNode field) {
6363
return;
6464
}
6565
byte[] bytes = extractLiteralBytes(filledArr);
66-
if (bytes == null || bytes.length < Math.max(1, options.getMinInputLength())) {
66+
if (bytes == null || bytes.length == 0) {
6767
return;
6868
}
6969
String decoded = tryDecodeAsString(bytes);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public String getTitle() {
8888
@Override
8989
public JComponent buildComponent() {
9090
if (panel == null) {
91-
Set<String> generalSuffixes = Set.of("minInputLength", "maxCommentLength", "minDecodedLength");
91+
Set<String> generalSuffixes = Set.of("maxCommentLength", "minDecodedLength");
9292
List<OptionDescription> allOpts = options.getOptionsDescriptions();
9393
List<OptionDescription> generalOpts = allOpts.stream()
9494
.filter(o -> generalSuffixes.stream().anyMatch(s -> o.name().endsWith("." + s)))

src/test/java/jadx/plugins/stringdecoder/JadxStringDecoderPluginTest.java

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -154,22 +154,14 @@ public void requireValidLengthAllowsDivisibleByFourTest() throws Exception {
154154
assertThat(code).contains("b64: hello");
155155
}
156156

157-
@Test
158-
public void minInputLengthOptionTest() throws Exception {
159-
// Raising minInputLength to 24 should suppress the 8-char "aGVsbG8=" string
160-
String code = decompileSmali("b64/b64_decodable.smali",
161-
Map.of(opt("minInputLength"), "24"));
162-
System.out.println(code);
163-
assertThat(code).doesNotContain("b64:");
164-
}
165-
166157
@Test
167158
public void minAlphanumericPercentOptionTest() throws Exception {
168159
// "fillItem" decodes to ~40% alphanumeric; setting minAlphanumericPercent=50 must suppress it
169-
// (set printable threshold low enough to isolate the alnum check)
160+
// (lower printable threshold and disable skipCamelCase to isolate the alnum check)
170161
String code = decompileSmali("b64/identifier_like_b64.smali",
171162
Map.of(opt("minPrintablePercent"), "75",
172-
opt("minAlphanumericPercent"), "50"));
163+
opt("minAlphanumericPercent"), "50",
164+
opt("skipCamelCase"), "false"));
173165
System.out.println(code);
174166
assertThat(code).doesNotContain("b64:");
175167
}

0 commit comments

Comments
 (0)