Update deps and fix frida-sys issue
Some checks failed
Rust / build (macos-latest) (push) Has been cancelled
Rust / build (ubuntu-latest) (push) Has been cancelled
Rust / build (windows-latest) (push) Has been cancelled

This commit is contained in:
Dimitris Zervas 2025-01-18 21:05:06 +02:00
parent d4660c0005
commit b68121f658
No known key found for this signature in database
3 changed files with 699 additions and 440 deletions

1072
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -16,26 +16,26 @@ frida = ["dep:frida", "dep:lazy_static", "dep:serde", "dep:serde_json"]
frida-auto-download = ["frida/auto-download"]
[dependencies]
frida = { git = "https://github.com/dzervas/frida-rust", branch = "armhf-patches", optional = true }
lazy_static = { version = "1.4.0", optional = true }
frida = { version = "0.16", optional = true }
lazy_static = { version = "1.5.0", optional = true }
serde = { version = "1.0", features = ["derive"], optional = true }
serde_json = { version = "1.0", optional = true }
[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3.9", features = ["winnt", "libloaderapi"] }
windows-sys = { version = "0.52.0", features = [
windows-sys = { version = "0.59", features = [
"Win32_System_ClrHosting",
], optional = true }
[target.'cfg(unix)'.dependencies]
ctor = "0.2.8"
ctor = "0.2"
[build-dependencies]
goblin = "0.8.1"
goblin = "0.9"
build-target = "0.4"
serde = { version = "1.0", features = ["derive"] }
toml = "0.8.12"
toml = "0.8"
[dev-dependencies]
pretty_assertions = "1.4.0"
pretty_assertions = "1.4"
mylib = { path = "tests/mylib" }

View File

@ -1,8 +1,7 @@
#![cfg(feature = "frida")]
use frida::{DeviceManager, DeviceType, Frida, ScriptHandler, ScriptOption, ScriptRuntime, SpawnOptions};
use frida::{DeviceManager, DeviceType, Frida, ScriptHandler, ScriptOption, ScriptRuntime, SpawnOptions, Message, MessageLogLevel};
use lazy_static::lazy_static;
use serde::Deserialize;
lazy_static! {
pub static ref FRIDA: Frida = unsafe { Frida::obtain() };
@ -42,11 +41,11 @@ pub fn attach_with(frida_code: &str, mode: AttachMode) {
let mut script_option = ScriptOption::new()
.set_runtime(ScriptRuntime::QJS);
println!("[*] Script {}", frida_code);
let script = session
let mut script = session
.create_script(frida_code, &mut script_option)
.unwrap();
script.handle_message(&mut Handler).unwrap();
script.handle_message(Handler).unwrap();
script.load().unwrap();
println!("[*] Script loaded");
@ -60,53 +59,23 @@ pub fn attach_with(frida_code: &str, mode: AttachMode) {
};
}
#[derive(Debug, Deserialize)]
struct LogEntry {
#[serde(rename = "type")]
log_type: LogType,
level: LogLevel,
payload: String,
}
#[derive(Debug, Deserialize)]
enum LogType {
#[serde(rename = "log")]
Log,
}
#[derive(Debug, Deserialize)]
enum LogLevel {
#[serde(rename = "debug")]
Debug,
#[serde(rename = "info")]
Info,
#[serde(rename = "warning")]
Warning,
#[serde(rename = "error")]
Error,
}
struct Handler;
impl ScriptHandler for Handler {
fn on_message(&mut self, message: &str) {
if let Ok(log_entry) = serde_json::from_str::<LogEntry>(message) {
match log_entry.log_type {
LogType::Log => {
match log_entry.level {
LogLevel::Debug => eprint!("[-] "),
LogLevel::Info => eprint!("[i] "),
LogLevel::Warning => eprint!("[!] "),
LogLevel::Error => eprint!("[X] "),
}
}
fn on_message(&mut self, message: &Message, _data: Option<Vec<u8>>) {
if let Message::Log(log_entry) = message {
match log_entry.level {
MessageLogLevel::Debug => eprint!("[-] "),
MessageLogLevel::Info => eprint!("[i] "),
MessageLogLevel::Warning => eprint!("[!] "),
MessageLogLevel::Error => eprint!("[X] "),
}
eprintln!("{}", log_entry.payload);
return;
}
eprintln!("{message}");
eprintln!("{:?}", message);
}
}