-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHexManifest.java
More file actions
32 lines (29 loc) · 1.45 KB
/
Copy pathHexManifest.java
File metadata and controls
32 lines (29 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import java.io.*;
import java.nio.file.*;
public class HexManifest {
public static void main(String[] args) throws Exception {
byte[] b = Files.readAllBytes(Paths.get("D:/Ideas/Antigravity/Notes/apks_extracted/base.apk"));
// This is not efficient, but let's find AndroidManifest.xml in the zip
// I already extracted it to AndroidManifest.bin earlier
byte[] m = Files.readAllBytes(Paths.get("D:/Ideas/Antigravity/Notes/AndroidManifest.bin"));
// Find split attributes
// "requiredSplitTypes" is a string in the string pool.
// We can just corrupt the string name to something else.
patch(m, "requiredSplitTypes", "disabledSplits___");
patch(m, "splitTypes", "dummyTypes");
patch(m, "isSplitRequired", "notRequiredAtAll");
Files.write(Paths.get("D:/Ideas/Antigravity/Notes/AndroidManifest_Patched.bin"), m);
}
private static void patch(byte[] m, String target, String replacement) throws Exception {
byte[] t = target.getBytes("UTF-16LE");
byte[] r = replacement.getBytes("UTF-16LE");
for (int i = 0; i < m.length - t.length; i++) {
boolean match = true;
for (int j = 0; j < t.length; j++) if (m[i+j] != t[j]) { match = false; break; }
if (match) {
System.arraycopy(r, 0, m, i, r.length);
System.out.println("Patched string: " + target);
}
}
}
}