MacOS client works!

modified:   frida_client/src/client.rs
	modified:   frida_core/src/mac_tun.rs
This commit is contained in:
Michael Wain 2025-02-11 05:50:15 +03:00
parent 9474cb8652
commit 39e64a4944
2 changed files with 10 additions and 5 deletions

View File

@ -68,8 +68,10 @@ pub mod general {
loop {
match dev_reader.read(&mut buf).await {
Ok(n) => {
//info!("Read from tun.");
#[cfg(not(target_os = "macos"))]
dx.send(buf[..n].to_vec()).unwrap();
#[cfg(target_os = "macos")]
dx.send(buf[4..n].to_vec()).unwrap();
},
Err(_e) => { /*error!("Read failed {}", e);*/ }
}
@ -87,6 +89,8 @@ pub mod general {
rr = rx.recv() => {
if let Some(bytes) = rr {
//info!("Write to tun. len={:?}", bytes.len());
#[cfg(target_os = "macos")]
let bytes = [vec![0, 0, 0, 2], bytes].concat();
if let Err(e) = dev_writer.write(&bytes).await {
//error!("Writing error: {:?}", e);
@ -340,7 +344,7 @@ pub mod desktop {
cmd("route", &["add", "-host", endpoint_ip, &gateway.unwrap()]);
cmd("route", &["change", "default", "-interface", "utun3"]); // todo: change that
cmd("route", &["change", "default", "-interface", "utun3"]); // TODO: change that
cmd("route", &["add", "-host", endpoint_ip, &gateway.unwrap()]);
}

View File

@ -1,9 +1,10 @@
use std::fs::File;
use std::io::{Read, Write};
use std::os::fd::{AsRawFd, FromRawFd};
use std::{ffi::CString, process::Command};
use std::sync::Arc;
use std::error::Error;
use log::info;
use tokio::fs::File;
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use crate::device::AbstractDevice;
@ -49,12 +50,12 @@ pub struct DeviceReader {
impl DeviceWriter {
pub async fn write(&mut self, buf: &Vec<u8>) -> Result<usize, Box<dyn Error>> {
Ok(self.writer.write(buf).await?)
Ok(self.writer.write(buf)?)
}
}
impl DeviceReader {
pub async fn read(&mut self, buf: &mut Vec<u8>) -> Result<usize, Box<dyn Error>> {
Ok(self.reader.read_buf(buf).await?)
Ok(self.reader.read(buf)?)
}
}