add examples
This commit is contained in:
parent
22571a39fc
commit
28f47eaba4
4 changed files with 65 additions and 1 deletions
|
|
@ -33,3 +33,8 @@ python = ["pyo3", "pyo3-log"] # Currently not supported
|
||||||
external-zip-reader = ["zip"]
|
external-zip-reader = ["zip"]
|
||||||
platform-list = ["androscalpel_platform_api_list"]
|
platform-list = ["androscalpel_platform_api_list"]
|
||||||
code-analysis = []
|
code-analysis = []
|
||||||
|
|
||||||
|
[[example]]
|
||||||
|
name = "list-method"
|
||||||
|
[[example]]
|
||||||
|
name = "count_ins_and_genapk"
|
||||||
|
|
|
||||||
39
androscalpel/examples/count_ins_and_genapk.rs
Normal file
39
androscalpel/examples/count_ins_and_genapk.rs
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
use androscalpel::{Apk, Instruction, Result, VisitableMut, VisitorMut};
|
||||||
|
use std::env;
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
|
struct InsCounter {
|
||||||
|
pub n: u64,
|
||||||
|
}
|
||||||
|
impl VisitorMut for InsCounter {
|
||||||
|
fn visit_instruction(&mut self, ins: Instruction) -> Result<Instruction> {
|
||||||
|
if !ins.is_pseudo_ins() {
|
||||||
|
self.n += 1;
|
||||||
|
}
|
||||||
|
ins.default_visit_mut(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let args: Vec<_> = env::args().collect();
|
||||||
|
assert!(args.len() > 1, "Need one argument");
|
||||||
|
|
||||||
|
let mut cnt = InsCounter::default();
|
||||||
|
let apk = cnt
|
||||||
|
.visit_apk(Apk::load_apk_path((&args[1]).into(), false, false).unwrap())
|
||||||
|
.unwrap();
|
||||||
|
println!("Nb INS: {}", cnt.n);
|
||||||
|
|
||||||
|
let mut files = apk.gen_raw_dex().unwrap();
|
||||||
|
|
||||||
|
/*apk_frauder::replace_dex(
|
||||||
|
(&args[1]).into(),
|
||||||
|
(&args[1] + ".pathed").into(),
|
||||||
|
&mut dex_files,
|
||||||
|
cli.keystore,
|
||||||
|
cli.zipalign,
|
||||||
|
cli.apksigner,
|
||||||
|
cli.keypassword.as_deref(),
|
||||||
|
None::<HashMap<_, Option<Cursor<&[u8]>>>>,
|
||||||
|
)*/
|
||||||
|
}
|
||||||
20
androscalpel/examples/list-method.rs
Normal file
20
androscalpel/examples/list-method.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
use androscalpel::{Apk, Method, Result, SmaliName, Visitable, Visitor};
|
||||||
|
use std::env;
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
|
struct MethodPrinter {}
|
||||||
|
impl Visitor for MethodPrinter {
|
||||||
|
fn visit_method(&mut self, method: &Method) -> Result<()> {
|
||||||
|
println!("Method: {}", method.descriptor.try_to_smali()?);
|
||||||
|
method.default_visit(self)?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let args: Vec<_> = env::args().collect();
|
||||||
|
assert!(args.len() > 1, "Need one argument");
|
||||||
|
|
||||||
|
let apk = Apk::load_apk_path((&args[1]).into(), false, false).unwrap();
|
||||||
|
MethodPrinter::default().visit_apk(&apk).unwrap();
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use anyhow::Result;
|
pub use anyhow::Result;
|
||||||
|
|
||||||
#[cfg(feature = "python")]
|
#[cfg(feature = "python")]
|
||||||
use pyo3::prelude::*;
|
use pyo3::prelude::*;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue