staticalyze object instanciation

This commit is contained in:
Jean-Marie 'Histausse' Mineau 2025-02-04 19:01:07 +01:00
parent 6b15bbf748
commit 5fdeb25682
Signed by: histausse
GPG key ID: B66AEEDA9B645AD2
3 changed files with 518 additions and 168 deletions

View file

@ -5,7 +5,9 @@ use std::path::PathBuf;
use androscalpel::{IdMethod, IdType};
use patcher::get_apk::{get_apk, ApkLocation};
use patcher::{transform_method, ReflectionData};
use patcher::{
transform_method, ReflectionClassNewInstData, ReflectionCnstrNewInstData, ReflectionInvokeData,
};
use clap::Parser;
@ -36,25 +38,38 @@ fn main() {
.unwrap();
//println!("{:#?}", class.direct_methods.keys());
//println!("{:#?}", class.virtual_methods.keys());
let method = class
.virtual_methods
.get_mut(
&IdMethod::from_smali(
"Lcom/example/theseus/reflection/MainActivity;->callVirtualMethodReflectCall()V",
)
.unwrap(),
)
.unwrap();
transform_method(
for m in [
"Lcom/example/theseus/reflection/MainActivity;->callVirtualMethodReflectCall()V",
"Lcom/example/theseus/reflection/MainActivity;->callConstructorVirtualMethodReflectConstr()V",
"Lcom/example/theseus/reflection/MainActivity;->callVirtualMethodReflectOldConst()V",
] {
let method = class
.virtual_methods
.get_mut(&IdMethod::from_smali(m).unwrap())
.unwrap();
transform_method(
method,
&ReflectionData {
&ReflectionInvokeData {
method: IdMethod::from_smali(
"Lcom/example/theseus/reflection/Reflectee;->transfer(Ljava/lang/String;)Ljava/lang/String;",
)
.unwrap(),
},
&ReflectionClassNewInstData {
constructor: IdMethod::from_smali(
"Lcom/example/theseus/reflection/Reflectee;-><init>()V",
)
.unwrap(),
},
&ReflectionCnstrNewInstData{
constructor: IdMethod::from_smali(
"Lcom/example/theseus/reflection/Reflectee;-><init>(Ljava/lang/String;)V",
)
.unwrap(),
},
)
.unwrap();
}
let mut dex_files = vec![];
let mut files = apk.gen_raw_dex().unwrap();
let mut i = 0;