modified: Cargo.lock
Some checks failed
gitea/Frida/pipeline/head There was a failure building this commit

modified:   frida_client/src/client.rs
	modified:   frida_core/src/device.rs
	modified:   frida_core/src/linux_tun.rs
	modified:   frida_core/src/tun.rs
	modified:   frida_core/src/win_tun.rs
This commit is contained in:
Michael Wain 2024-12-09 05:05:28 +03:00
parent be7c5a7461
commit c3b886c21f
6 changed files with 38 additions and 26 deletions

10
Cargo.lock generated
View File

@ -1644,7 +1644,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b"
[[package]]
name = "frida-client"
name = "frida_cli"
version = "0.2.0"
[[package]]
name = "frida_client"
version = "0.2.0"
dependencies = [
"aes-gcm",
@ -1657,10 +1661,6 @@ dependencies = [
"x25519-dalek",
]
[[package]]
name = "frida_cli"
version = "0.2.0"
[[package]]
name = "frida_core"
version = "0.2.0"

View File

@ -192,6 +192,8 @@ pub mod android {
pub mod desktop {
use crate::client::general::{CoreVpnClient, DevReader, DevWriter, VpnClient};
use crate::config::ClientConfiguration;
use frida_core::create;
use frida_core::device::AbstractDevice;
use futures::{SinkExt, StreamExt};
use log::info;
use tokio::net::UdpSocket;
@ -267,7 +269,7 @@ pub mod desktop {
async fn start(&self) {
info!("s_interface: {:?}", &self.s_interface);
info!("client_address: {:?}", &self.client_config.client.address);
let mut config = Configuration::default();
let mut config = AbstractDevice::default();
config.address(&self.client_config.client.address)
.netmask("255.255.255.255")
.destination("10.66.66.1")
@ -279,7 +281,7 @@ pub mod desktop {
let sock = UdpSocket::bind(("0.0.0.0", 0)).await.unwrap();
sock.connect(&self.client_config.server.endpoint).await.unwrap();
let dev = create_as_async(&config).unwrap();
let dev = create(&config).unwrap();
let (mut dev_writer , mut dev_reader) = dev.into_framed().split();
let mut client = CoreVpnClient{ client_config: self.client_config.clone(), dev_reader: DevReader{ dr: dev_reader }, dev_writer: DevWriter{dr: dev_writer }, close_token: tokio_util::sync::CancellationToken::new()};

View File

@ -1,31 +1,38 @@
use std::net::IpAddr;
#[derive(Default)]
pub struct AbstractDevice {
address: String,
netmask: String,
destination: String,
mtu: u16,
tun_name: String
address: Option<IpAddr>,
netmask: Option<IpAddr>,
destination: Option<IpAddr>,
mtu: Option<u16>,
tun_name: Option<String>
}
impl AbstractDevice {
fn address(&mut self, address: String) {
self.address = address;
pub fn address(&mut self, address: IpAddr) -> &mut Self {
self.address = Some(address);
self
}
fn netmask(&mut self, netmask: String) {
self.netmask = netmask;
pub fn netmask(&mut self, netmask: IpAddr) -> &mut Self {
self.netmask = Some(netmask);
self
}
fn destination(&mut self, destination: String) {
self.destination = destination;
pub fn destination(&mut self, destination: IpAddr) -> &mut Self {
self.destination = Some(destination);
self
}
fn mtu(&mut self, mtu: u16) {
self.mtu = mtu;
pub fn mtu(&mut self, mtu: u16) -> &mut Self {
self.mtu = Some(mtu);
self
}
fn tun_name(&mut self, tun_name: String) {
self.tun_name = tun_name;
pub fn tun_name<S: AsRef<str>>(&mut self, tun_name: S) -> &mut Self {
self.tun_name = Some(tun_name.as_ref().into());
self
}
}

View File

@ -4,7 +4,7 @@ use tokio_tun::Tun;
use std::net::Ipv4Addr;
use std::os::unix::io::AsRawFd;
pub fn create() -> (DeviceReader, DeviceWriter) {
pub fn create(cfg: AbstractDevice) -> (DeviceReader, DeviceWriter) {
let tun = Arc::new(
Tun::builder()
.name("") // if name is empty, then it is set by kernel.

View File

@ -1,9 +1,10 @@
use crate::device::AbstractDevice;
#[cfg(target_os = "windows")]
use crate::win_tun::{DeviceReader, DeviceWriter, create};
#[cfg(target_os = "linux")]
use crate::linux_tun::{DeviceReader, DeviceWriter, create};
pub fn create_tun() -> (DeviceReader, DeviceWriter) {
create()
pub fn create_tun(cfg: AbstractDevice) -> (DeviceReader, DeviceWriter) {
create(cfg)
}

View File

@ -3,7 +3,9 @@ use wintun::Session;
use std::sync::Arc;
use std::error::Error;
pub fn create() -> (DeviceReader, DeviceWriter) {
use crate::device::AbstractDevice;
pub fn create(cfg: AbstractDevice) -> (DeviceReader, DeviceWriter) {
//Unsafe because we are loading an arbitrary dll file
let wintun = unsafe { wintun::load_from_path("wintun.dll") }
.expect("Failed to load wintun dll");