This commit is contained in:
Jean-Marie Mineau 2025-04-07 15:40:51 +02:00
parent 190a8a8690
commit e6aafccf33
Signed by: histausse
GPG key ID: B66AEEDA9B645AD2
13 changed files with 47 additions and 181 deletions

8
patcher/Cargo.lock generated
View file

@ -35,7 +35,7 @@ dependencies = [
[[package]]
name = "androscalpel"
version = "0.1.0"
source = "git+ssh://git@git.mineau.eu/histausse/androscalpel.git?rev=c0152e7#c0152e76089b7a51ce28e19c1828cdbdd435271a"
source = "git+ssh://git@git.mineau.eu/histausse/androscalpel.git?rev=615f7a8#615f7a8f526e04e5c6d15dac00205a9c18879cfd"
dependencies = [
"adler",
"androscalpel_serializer",
@ -51,7 +51,7 @@ dependencies = [
[[package]]
name = "androscalpel_serializer"
version = "0.1.0"
source = "git+ssh://git@git.mineau.eu/histausse/androscalpel.git?rev=c0152e7#c0152e76089b7a51ce28e19c1828cdbdd435271a"
source = "git+ssh://git@git.mineau.eu/histausse/androscalpel.git?rev=615f7a8#615f7a8f526e04e5c6d15dac00205a9c18879cfd"
dependencies = [
"androscalpel_serializer_derive",
"log",
@ -60,7 +60,7 @@ dependencies = [
[[package]]
name = "androscalpel_serializer_derive"
version = "0.1.0"
source = "git+ssh://git@git.mineau.eu/histausse/androscalpel.git?rev=c0152e7#c0152e76089b7a51ce28e19c1828cdbdd435271a"
source = "git+ssh://git@git.mineau.eu/histausse/androscalpel.git?rev=615f7a8#615f7a8f526e04e5c6d15dac00205a9c18879cfd"
dependencies = [
"proc-macro2",
"quote",
@ -129,7 +129,7 @@ dependencies = [
[[package]]
name = "apk_frauder"
version = "0.1.0"
source = "git+ssh://git@git.mineau.eu/histausse/androscalpel.git?rev=c0152e7#c0152e76089b7a51ce28e19c1828cdbdd435271a"
source = "git+ssh://git@git.mineau.eu/histausse/androscalpel.git?rev=615f7a8#615f7a8f526e04e5c6d15dac00205a9c18879cfd"
dependencies = [
"androscalpel_serializer",
"flate2",

View file

@ -6,8 +6,10 @@ edition = "2024"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
androscalpel = { git = "ssh://git@git.mineau.eu/histausse/androscalpel.git", rev = "c0152e7", features = ["code-analysis"] }
apk_frauder = { git = "ssh://git@git.mineau.eu/histausse/androscalpel.git", rev = "c0152e7"}
androscalpel = { git = "ssh://git@git.mineau.eu/histausse/androscalpel.git", rev = "615f7a8", features = ["code-analysis"] }
apk_frauder = { git = "ssh://git@git.mineau.eu/histausse/androscalpel.git", rev = "615f7a8"}
#androscalpel = { path = "../../androscalpel/androscalpel", features = ["code-analysis"] }
#apk_frauder = { path = "../../androscalpel/apk_frauder"}
anyhow = { version = "1.0.95", features = ["backtrace"] }
clap = { version = "4.5.27", features = ["derive"] }
env_logger = "0.11.6"
@ -15,3 +17,9 @@ reqwest = { version = "0.12.12", default-features = false, features = ["blocking
serde = "1.0.217"
serde_json = "1.0.138"
log = "0.4.25"
[profile.minsizerelease]
inherits = "release"
strip = true # Automatically strip symbols from the binary.
opt-level = "z" # Optimize for size
lto = true

View file

@ -21,6 +21,8 @@ struct Cli {
out: PathBuf,
#[arg(short, long)]
keystore: PathBuf,
#[arg(long)]
keypassword: Option<String>,
#[arg(short, long)]
zipalign: Option<PathBuf>,
#[arg(short, long)]
@ -84,6 +86,9 @@ fn main() {
i += 1;
}
// TODO: aapt would be a lot more stable?
println!("\n\n\n\n\n\n\n");
println!("### /!\\ {:?}", cli.keypassword.as_deref());
println!("\n\n\n\n\n\n\n");
apk_frauder::replace_dex(
cli.path,
cli.out,
@ -91,6 +96,7 @@ fn main() {
cli.keystore,
cli.zipalign,
cli.apksigner,
cli.keypassword.as_deref(),
None::<HashMap<_, Option<Cursor<&[u8]>>>>,
);
}

View file

@ -1 +0,0 @@
cargo run --bin patcher -- --code-loading-patch-strategy model-class-loaders --runtime-data ./tst/runtime.json --path ../test_apks/dynloading/build/test_dynloading.apk --out /tmp/patched_dynloading.apk -k ../test_apks/dynloading/ToyKey.keystore -z $(which zipalign) -a $(which apksigner)

View file

@ -1,168 +0,0 @@
{
"invoke_data": [
{
"method": "Lcom/example/theseus/dynloading/Collider;->getColliderId()Ljava/lang/String;",
"method_cl_id": "0620d2cb",
"renamed_method": null,
"caller_method": "Lcom/example/theseus/dynloading/MainActivity;->directWithParent()V",
"caller_cl_id": "0620d2cb",
"renamed_caller_method": null,
"addr": 39,
"is_static": true
},
{
"method": "Lcom/example/theseus/dynloading/AMain;->getColliderId()Ljava/lang/String;",
"method_cl_id": "012faa7a",
"renamed_method": null,
"caller_method": "Lcom/example/theseus/dynloading/MainActivity;->indirectWithoutParent()V",
"caller_cl_id": "0620d2cb",
"renamed_caller_method": null,
"addr": 33,
"is_static": true
},
{
"method": "Lcom/example/theseus/dynloading/AMain;->getColliderId()Ljava/lang/String;",
"method_cl_id": "00a972ce",
"renamed_method": null,
"caller_method": "Lcom/example/theseus/dynloading/MainActivity;->indirectWithParent()V",
"caller_cl_id": "0620d2cb",
"renamed_caller_method": null,
"addr": 39,
"is_static": true
},
{
"method": "Lcom/example/theseus/dynloading/Collider;->getColliderId()Ljava/lang/String;",
"method_cl_id": "0354b7e2",
"renamed_method": null,
"caller_method": "Lcom/example/theseus/dynloading/MainActivity;->directWithoutParent()V",
"caller_cl_id": "0620d2cb",
"renamed_caller_method": null,
"addr": 33,
"is_static": true
}
],
"class_new_inst_data": [
{
"constructor": "Landroid/app/Application;-><init>()V",
"constructor_cl_id": "00aaeddc",
"renamed_constructor": null,
"caller_method": "Landroid/app/AppComponentFactory;->instantiateApplication(Ljava/lang/ClassLoader;Ljava/lang/String;)Landroid/app/Application;",
"caller_cl_id": "00aaeddc",
"renamed_caller_method": null,
"addr": 4
},
{
"constructor": "Lcom/example/theseus/dynloading/MainActivity;-><init>()V",
"constructor_cl_id": "0620d2cb",
"renamed_constructor": null,
"caller_method": "Landroid/app/AppComponentFactory;->instantiateActivity(Ljava/lang/ClassLoader;Ljava/lang/String;Landroid/content/Intent;)Landroid/app/Activity;",
"caller_cl_id": "00aaeddc",
"renamed_caller_method": null,
"addr": 4
}
],
"cnstr_new_inst_data": [],
"dyn_code_load": [
{
"classloader_class": "Ldalvik/system/PathClassLoader;",
"classloader": "07069310",
"files": [
"./tst/dex/PathClassLoader_07069310_09d17bb5de42d5d9.bytecode"
],
"classloader_parent": "0620d2cb"
},
{
"classloader_class": "Ldalvik/system/PathClassLoader;",
"classloader": "012faa7a",
"files": [
"./tst/dex/PathClassLoader_012faa7a_09d17bb5de42d5d9.bytecode"
],
"classloader_parent": null
},
{
"classloader_class": "Ldalvik/system/PathClassLoader;",
"classloader": "00a972ce",
"files": [
"./tst/dex/PathClassLoader_00a972ce_09d17bb5de42d5d9.bytecode"
],
"classloader_parent": "0620d2cb"
},
{
"classloader_class": "Ldalvik/system/PathClassLoader;",
"classloader": "0354b7e2",
"files": [
"./tst/dex/PathClassLoader_0354b7e2_09d17bb5de42d5d9.bytecode"
],
"classloader_parent": null
}
],
"classloaders": [
{
"id": "0096a9c1",
"parent_id": "00aaeddc",
"str": "dalvik.system.PathClassLoader[DexPathList[[directory \".\"],nativeLibraryDirectories=[/system/lib64, /system_ext/lib64, /system/lib64, /system_ext/lib64]]]",
"cname": "dalvik.system.PathClassLoader"
},
{
"id": "00aaeddc",
"parent_id": null,
"str": "java.lang.BootClassLoader@aaeddc",
"cname": "java.lang.BootClassLoader"
},
{
"id": "0035caa8",
"parent_id": null,
"str": "dalvik.system.InMemoryDexClassLoader[DexPathList[[dex file \"InMemoryDexFile[cookie=[0, 128037698188144]]\"],nativeLibraryDirectories=[/system/lib64, /system_ext/lib64]]]",
"cname": "dalvik.system.InMemoryDexClassLoader"
},
{
"id": "0096a9c1",
"parent_id": "00aaeddc",
"str": "dalvik.system.PathClassLoader[DexPathList[[directory \".\"],nativeLibraryDirectories=[/system/lib64, /system_ext/lib64, /system/lib64, /system_ext/lib64]]]",
"cname": "dalvik.system.PathClassLoader"
},
{
"id": "00aaeddc",
"parent_id": null,
"str": "java.lang.BootClassLoader@aaeddc",
"cname": "java.lang.BootClassLoader"
},
{
"id": "0035caa8",
"parent_id": null,
"str": "dalvik.system.InMemoryDexClassLoader[DexPathList[[dex file \"InMemoryDexFile[cookie=[0, 128037698188144]]\"],nativeLibraryDirectories=[/system/lib64, /system_ext/lib64]]]",
"cname": "dalvik.system.InMemoryDexClassLoader"
},
{
"id": "0620d2cb",
"parent_id": "00aaeddc",
"str": "dalvik.system.PathClassLoader[DexPathList[[zip file \"/data/app/~~G73yvcDB8EWWZQoHd7RyMQ==/com.example.theseus.dynloading-9TbLe3e6jrCqYe-MsGwAPA==/base.apk\"],nativeLibraryDirectories=[/data/app/~~G73yvcDB8EWWZQoHd7RyMQ==/com.example.theseus.dynloading-9TbLe3e6jrCqYe-MsGwAPA==/lib/x86_64, /system/lib64, /system_ext/lib64]]]",
"cname": "dalvik.system.PathClassLoader"
},
{
"id": "07069310",
"parent_id": "0620d2cb",
"str": "dalvik.system.PathClassLoader[DexPathList[[dex file \"/data/user/0/com.example.theseus.dynloading/cache/a.dex\"],nativeLibraryDirectories=[/system/lib64, /system_ext/lib64]]]",
"cname": "dalvik.system.PathClassLoader"
},
{
"id": "012faa7a",
"parent_id": null,
"str": "dalvik.system.PathClassLoader[DexPathList[[dex file \"/data/user/0/com.example.theseus.dynloading/cache/a.dex\"],nativeLibraryDirectories=[/system/lib64, /system_ext/lib64]]]",
"cname": "dalvik.system.PathClassLoader"
},
{
"id": "00a972ce",
"parent_id": "0620d2cb",
"str": "dalvik.system.PathClassLoader[DexPathList[[dex file \"/data/user/0/com.example.theseus.dynloading/cache/a.dex\"],nativeLibraryDirectories=[/system/lib64, /system_ext/lib64]]]",
"cname": "dalvik.system.PathClassLoader"
},
{
"id": "0354b7e2",
"parent_id": null,
"str": "dalvik.system.PathClassLoader[DexPathList[[dex file \"/data/user/0/com.example.theseus.dynloading/cache/a.dex\"],nativeLibraryDirectories=[/system/lib64, /system_ext/lib64]]]",
"cname": "dalvik.system.PathClassLoader"
}
],
"apk_cl_id": "0035caa8"
}