modified: Cargo.lock
Some checks failed
gitea/Frida-android-native/pipeline/head There was a failure building this commit
Some checks failed
gitea/Frida-android-native/pipeline/head There was a failure building this commit
modified: Cargo.toml modified: src/client.rs modified: src/main.rs
This commit is contained in:
parent
1c118b2318
commit
ad9383777f
136
Cargo.lock
generated
136
Cargo.lock
generated
@ -77,23 +77,6 @@ version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0"
|
||||
|
||||
[[package]]
|
||||
name = "android_log-sys"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5ecc8056bf6ab9892dcd53216c83d1597487d7dacac16c8df6b877d127df9937"
|
||||
|
||||
[[package]]
|
||||
name = "android_logger"
|
||||
version = "0.14.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "05b07e8e73d720a1f2e4b6014766e6039fd2e96a4fa44e2a78d0e1fa2ff49826"
|
||||
dependencies = [
|
||||
"android_log-sys",
|
||||
"env_filter",
|
||||
"log",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "android_system_properties"
|
||||
version = "0.1.5"
|
||||
@ -118,6 +101,12 @@ version = "1.0.89"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6"
|
||||
|
||||
[[package]]
|
||||
name = "arc-swap"
|
||||
version = "1.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "69f7f8c3906b62b754cd5326047894316021dcfe5a194c8ea52bdd94934a3457"
|
||||
|
||||
[[package]]
|
||||
name = "async-channel"
|
||||
version = "2.3.1"
|
||||
@ -598,22 +587,29 @@ dependencies = [
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "derivative"
|
||||
version = "2.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "destructure_traitobject"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3c877555693c14d2f84191cfd3ad8582790fc52b5e2274b40b59cf5f5cea25c7"
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0"
|
||||
|
||||
[[package]]
|
||||
name = "env_filter"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4f2c92ceda6ceec50f43169f9ee8424fe2db276791afde7b2cd8bc084cb376ab"
|
||||
dependencies = [
|
||||
"log",
|
||||
"regex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "equivalent"
|
||||
version = "1.0.1"
|
||||
@ -674,7 +670,6 @@ name = "frida_android"
|
||||
version = "0.1.2"
|
||||
dependencies = [
|
||||
"aes-gcm",
|
||||
"android_logger",
|
||||
"base64 0.22.1",
|
||||
"block-modes",
|
||||
"block-padding",
|
||||
@ -687,6 +682,7 @@ dependencies = [
|
||||
"hex",
|
||||
"jni 0.20.0",
|
||||
"log",
|
||||
"log4rs",
|
||||
"network-interface",
|
||||
"nonblock",
|
||||
"packet",
|
||||
@ -1177,6 +1173,43 @@ name = "log"
|
||||
version = "0.4.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "log-mdc"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a94d21414c1f4a51209ad204c1776a3d0765002c76c6abcb602a6f09f1e881c7"
|
||||
|
||||
[[package]]
|
||||
name = "log4rs"
|
||||
version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0816135ae15bd0391cf284eab37e6e3ee0a6ee63d2ceeb659862bd8d0a984ca6"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"arc-swap",
|
||||
"chrono",
|
||||
"derivative",
|
||||
"fnv",
|
||||
"humantime",
|
||||
"libc",
|
||||
"log",
|
||||
"log-mdc",
|
||||
"once_cell",
|
||||
"parking_lot",
|
||||
"rand",
|
||||
"serde",
|
||||
"serde-value",
|
||||
"serde_json",
|
||||
"serde_yaml",
|
||||
"thiserror",
|
||||
"thread-id",
|
||||
"typemap-ors",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "matchers"
|
||||
@ -1305,6 +1338,15 @@ version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381"
|
||||
|
||||
[[package]]
|
||||
name = "ordered-float"
|
||||
version = "2.10.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "68f19d67e5a2795c94e73e0bb1cc1a7edeb2e28efd39e2e1c9b7a40c1108b11c"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "packet"
|
||||
version = "0.1.4"
|
||||
@ -1680,6 +1722,16 @@ dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde-value"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f3a1a3341211875ef120e117ea7fd5228530ae7e7036a779fdc9117be6b3282c"
|
||||
dependencies = [
|
||||
"ordered-float",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.210"
|
||||
@ -1868,6 +1920,16 @@ dependencies = [
|
||||
"syn 2.0.77",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thread-id"
|
||||
version = "4.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cfe8f25bbdd100db7e1d34acf7fd2dc59c4bf8f7483f505eaa7d4f12f76cc0ea"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thread_local"
|
||||
version = "1.1.8"
|
||||
@ -2068,6 +2130,15 @@ dependencies = [
|
||||
"wintun-bindings",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typemap-ors"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a68c24b707f02dd18f1e4ccceb9d49f2058c2fb86384ef9972592904d7a28867"
|
||||
dependencies = [
|
||||
"unsafe-any-ors",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typenum"
|
||||
version = "1.17.0"
|
||||
@ -2096,6 +2167,15 @@ dependencies = [
|
||||
"subtle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unsafe-any-ors"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e0a303d30665362d9680d7d91d78b23f5f899504d4f08b3c4cf08d055d87c0ad"
|
||||
dependencies = [
|
||||
"destructure_traitobject",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unsafe-libyaml"
|
||||
version = "0.2.11"
|
||||
|
@ -36,9 +36,9 @@ base64 = "0.22.1"
|
||||
chrono = "0.4.38"
|
||||
console-subscriber = "0.4.0"
|
||||
network-interface = "2.0.0"
|
||||
log4rs = "1.3.0"
|
||||
|
||||
[target.'cfg(target_os="android")'.dependencies]
|
||||
jni = "^0.20"
|
||||
robusta_jni = "0.2.2"
|
||||
android_logger = "0.14.1"
|
||||
nonblock = "0.2.0"
|
@ -26,6 +26,7 @@ use crate::jni::FridaLib;
|
||||
|
||||
pub async fn client_mode(client_config: ClientConfiguration, fd: i32, /*env: &JNIEnv<'_>,*/ close_token: CancellationToken) {
|
||||
let (ltx, mut lrx) = mpsc::unbounded_channel::<Vec<u8>>();
|
||||
info!("Starting client log..");
|
||||
ltx.send("Starting client...".as_bytes().to_vec());
|
||||
|
||||
let sock = UdpSocket::bind("0.0.0.0:25565").await.unwrap();
|
||||
@ -138,7 +139,7 @@ pub async fn client_mode(client_config: ClientConfiguration, fd: i32, /*env: &JN
|
||||
}
|
||||
rr1 = lrx.recv() => {
|
||||
if let Some(bytes) = rr1 {
|
||||
crate::log2java(String::from_utf8_lossy(&bytes).to_string());
|
||||
//crate::log2java(String::from_utf8_lossy(&bytes).to_string());
|
||||
//FridaLib::traceFromNative(&env, );
|
||||
}
|
||||
}
|
||||
|
58
src/main.rs
58
src/main.rs
@ -1,18 +1,5 @@
|
||||
#![cfg(target_os = "android")]
|
||||
|
||||
/*use jni::{
|
||||
objects::{JClass, JString},
|
||||
sys::{jboolean, jchar, jint, jstring},
|
||||
JNIEnv,
|
||||
};
|
||||
use std::{error::Error, fs, net::Ipv4Addr, str};
|
||||
use clap::{App, Arg, ArgMatches};
|
||||
use env_logger::Builder;
|
||||
use log::{error, LevelFilter};
|
||||
use crate::config::{ ServerConfiguration, ClientConfiguration, ObfsProtocol, ServerPeer };
|
||||
use fast32::base32::RFC4648;
|
||||
use crossbeam_channel::unbounded;*/
|
||||
|
||||
use ::jni::objects::GlobalRef;
|
||||
use ::jni::JavaVM;
|
||||
use robusta_jni::bridge;
|
||||
@ -27,22 +14,9 @@ mod udp;
|
||||
mod mobile;
|
||||
|
||||
static TUN_QUIT: std::sync::Mutex<Option<tokio_util::sync::CancellationToken>> = std::sync::Mutex::new(None);
|
||||
static LOG_FILE: std::sync::Mutex<Option<File>> = std::sync::Mutex::new(None);
|
||||
|
||||
pub fn log2java(text: String) {
|
||||
if let Ok(mut l) = LOG_FILE.lock() {
|
||||
if let Some(mut ff) = l.take() {
|
||||
ff.write(text.as_bytes());
|
||||
ff.write(b"\n");
|
||||
//ff.flush();
|
||||
//jni::FridaLib::traceFromNative(l.unwrap(), text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[bridge]
|
||||
mod jni {
|
||||
use android_logger::Config;
|
||||
use jni::objects::{GlobalRef, JObject, JValue, JString};
|
||||
use jni::sys::{jboolean, jchar, jint, jstring};
|
||||
use log::{info, trace};
|
||||
@ -67,6 +41,20 @@ mod jni {
|
||||
close_fd_on_drop: bool,
|
||||
temp_file: String) -> JniResult<i32> {
|
||||
|
||||
let logfile = FileAppender::builder()
|
||||
.encoder(Box::new(PatternEncoder::new("{l} - {m}\n")))
|
||||
.build(&temp_file).await.unwrap();
|
||||
|
||||
let config = Config::builder()
|
||||
.appender(Appender::builder().build("logfile", Box::new(logfile)))
|
||||
.build(Root::builder()
|
||||
.appender("logfile")
|
||||
.build(LevelFilter::Info)).await.unwrap();
|
||||
|
||||
log4rs::init_config(config).await;
|
||||
|
||||
info!("Hello, world!");
|
||||
|
||||
let close_token = tokio_util::sync::CancellationToken::new();
|
||||
if let Ok(mut l) = TUN_QUIT.lock() {
|
||||
if l.is_some() {
|
||||
@ -77,21 +65,7 @@ mod jni {
|
||||
return Ok(-2);
|
||||
}
|
||||
|
||||
if let Ok(mut l) = LOG_FILE.lock() {
|
||||
if !l.is_some() {
|
||||
*l = Some(File::options()
|
||||
.read(false)
|
||||
.write(true)
|
||||
.open(&temp_file).unwrap());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
let main_loop = async move {
|
||||
/*if let Err(err) = {
|
||||
FridaLib::traceFromNative(env, format!("main loop error: {}", err));
|
||||
return Err(err);
|
||||
}*/
|
||||
mobile::mobile_run(config_b32, close_fd_on_drop, tun_fd, /*env,*/ close_token).await;
|
||||
};
|
||||
|
||||
@ -101,10 +75,6 @@ mod jni {
|
||||
};
|
||||
|
||||
Ok(exit_code)
|
||||
|
||||
//FridaLib::traceFromNative(env, "Hello world".to_string());
|
||||
|
||||
//Ok(mobile::mobile_run(config_b32, close_fd_on_drop, tun_fd, env))
|
||||
}
|
||||
|
||||
pub extern "jni" fn stop(self, env: &JNIEnv) -> JniResult<i32> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user