Some checks failed
gitea/Frida-android-native/pipeline/head There was a failure building this commit
new file: src/simple_log.rs
82 lines
2.2 KiB
Rust
82 lines
2.2 KiB
Rust
#![cfg(target_os = "android")]
|
|
|
|
use jni::{
|
|
objects::{JClass, JString},
|
|
sys::{jboolean, jchar, jint},
|
|
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;
|
|
|
|
mod config;
|
|
mod client;
|
|
mod udp;
|
|
mod mobile;
|
|
mod simple_log;
|
|
|
|
#[no_mangle]
|
|
pub unsafe extern "C" fn Java_com_alterdekim_frida_FridaLib_run(
|
|
mut env: JNIEnv,
|
|
_clazz: JClass,
|
|
config_b32: JString,
|
|
tun_fd: jint,
|
|
close_fd_on_drop: jboolean,
|
|
) -> jint {
|
|
simple_log::init_logger();
|
|
let config = env.get_string(config_b32).unwrap().into();
|
|
let close_fd_on_drop = close_fd_on_drop != 0;
|
|
mobile::mobile_run(config, close_fd_on_drop, tun_fd)
|
|
}
|
|
|
|
#[no_mangle]
|
|
pub unsafe extern "C" fn Java_com_alterdekim_frida_FridaLib_fetchLogs(
|
|
mut env: JNIEnv,
|
|
_clazz: JClass
|
|
) -> JString {
|
|
String::from_utf8_lossy(simple_log::fetch_logs())
|
|
}
|
|
|
|
#[no_mangle]
|
|
pub unsafe extern "C" fn Java_com_alterdekim_frida_FridaLib_stop(_env: JNIEnv, _: JClass) -> jint {
|
|
mobile::mobile_stop()
|
|
}
|
|
|
|
|
|
/*
|
|
#[tokio::main]
|
|
async fn main() {
|
|
// Initialize the logger with 'info' as the default level
|
|
Builder::new()
|
|
.filter(None, LevelFilter::Info)
|
|
.init();
|
|
|
|
let matches = App::new("Frida")
|
|
.version("0.1.2")
|
|
.author("alterwain")
|
|
.about("VPN software (android port)")
|
|
.arg(Arg::with_name("config")
|
|
.long("config")
|
|
.required(true)
|
|
.value_name("B32_RAW")
|
|
.help("Configuration file data (base32 encoded)")
|
|
.takes_value(true))
|
|
.arg(Arg::with_name("fd")
|
|
.long("fd")
|
|
.required(true)
|
|
.value_name("INT")
|
|
.help("File descriptor int")
|
|
.takes_value(true))
|
|
.get_matches();
|
|
|
|
let cfg_raw = matches.value_of("config").unwrap();
|
|
|
|
let config: ClientConfiguration = serde_yaml::from_slice(RFC4648.decode(cfg_raw.as_bytes()).unwrap().as_slice()).expect("Bad client config file structure");
|
|
|
|
client::client_mode(config, matches.value_of("fd").unwrap().parse().unwrap()).await;
|
|
}
|
|
*/ |