fix bugs
This commit is contained in:
parent
7f46d6c12f
commit
a999338cd0
7 changed files with 139 additions and 1115 deletions
1182
patcher/Cargo.lock
generated
1182
patcher/Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -6,14 +6,13 @@ edition = "2024"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
androscalpel = { git = "ssh://git@gitlab.inria.fr/androidoftheseus/androscalpel.git", rev = "615f7a8", features = ["code-analysis"] }
|
||||
apk_frauder = { git = "ssh://git@gitlab.inria.fr/androidoftheseus/androscalpel.git", rev = "615f7a8"}
|
||||
androscalpel = { git = "ssh://git@gitlab.inria.fr/androidoftheseus/androscalpel.git", rev = "3cc02a3", features = ["code-analysis"] }
|
||||
apk_frauder = { git = "ssh://git@gitlab.inria.fr/androidoftheseus/androscalpel.git", rev = "3cc02a3"}
|
||||
#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"
|
||||
reqwest = { version = "0.12.12", default-features = false, features = ["blocking", "rustls-tls"] }
|
||||
serde = "1.0.217"
|
||||
serde_json = "1.0.138"
|
||||
log = "0.4.25"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
use anyhow::Context;
|
||||
use std::collections::HashMap;
|
||||
use std::fs::File;
|
||||
use std::io::{Cursor, Read};
|
||||
|
|
@ -5,6 +6,7 @@ use std::path::PathBuf;
|
|||
|
||||
use androscalpel::{Apk, Class, IdType};
|
||||
|
||||
use androscalpel::SmaliName;
|
||||
use patcher::{
|
||||
code_loading_patcher::{insert_code, CodePatchingStrategy},
|
||||
labeling,
|
||||
|
|
@ -58,7 +60,21 @@ fn main() {
|
|||
if let Some(class) = apk.get_class_mut(&method.class_) {
|
||||
//println!("{:#?}", class.direct_methods.keys());
|
||||
//println!("{:#?}", class.virtual_methods.keys());
|
||||
let method = class.virtual_methods.get_mut(method).unwrap();
|
||||
let method = if let Some(method) = class.virtual_methods.get_mut(method) {
|
||||
method
|
||||
} else {
|
||||
class
|
||||
.direct_methods
|
||||
.get_mut(method)
|
||||
.with_context(|| {
|
||||
format!(
|
||||
"method {} not found in {}",
|
||||
method.try_to_smali().unwrap(),
|
||||
class.descriptor.try_to_smali().unwrap()
|
||||
)
|
||||
})
|
||||
.unwrap()
|
||||
};
|
||||
transform_method(method, &rt_data, test_class.clone(), &mut test_methods).unwrap();
|
||||
}
|
||||
}
|
||||
|
|
@ -95,5 +111,6 @@ fn main() {
|
|||
cli.apksigner,
|
||||
cli.keypassword.as_deref(),
|
||||
None::<HashMap<_, Option<Cursor<&[u8]>>>>,
|
||||
);
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,9 +30,15 @@ pub fn insert_code(
|
|||
/// For now, we ignore class collision.
|
||||
fn insert_code_naive(apk: &mut Apk, data: &RuntimeData) -> Result<()> {
|
||||
for dyn_data in &data.dyn_code_load {
|
||||
for file in &dyn_data.files {
|
||||
let file = File::open(file)?;
|
||||
apk.add_code(file, crate::labeling, false)?;
|
||||
for file_name in &dyn_data.files {
|
||||
let file = File::open(file_name)?;
|
||||
apk.add_code(file, crate::labeling, false)
|
||||
.with_context(|| {
|
||||
format!(
|
||||
"Could not add code from {}",
|
||||
file_name.to_str().unwrap_or("<failed to parse file name>")
|
||||
)
|
||||
})?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
|
@ -60,9 +66,15 @@ fn insert_code_model_class_loaders(apk: &mut Apk, runtime_data: &mut RuntimeData
|
|||
for dyn_data in &runtime_data.dyn_code_load {
|
||||
let mut apk = Apk::new();
|
||||
let class = dyn_data.classloader_class.clone();
|
||||
for file in &dyn_data.files {
|
||||
let file = File::open(file)?;
|
||||
apk.add_code(file, crate::labeling, false)?;
|
||||
for file_name in &dyn_data.files {
|
||||
let file = File::open(file_name)?;
|
||||
apk.add_code(file, crate::labeling, false)
|
||||
.with_context(|| {
|
||||
format!(
|
||||
"Could not add code from {}",
|
||||
file_name.to_str().unwrap_or("<failed to parse file name>")
|
||||
)
|
||||
})?;
|
||||
}
|
||||
|
||||
assert!(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue