diff --git a/Cargo.lock b/Cargo.lock index d1e4d18..e9c41c7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1760,12 +1760,15 @@ dependencies = [ ] [[package]] +<<<<<<< HEAD name = "static_assertions" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] +======= +>>>>>>> 35594dea3ce13c2fe98f3a7bdd28e9b3c8351732 name = "strsim" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" diff --git a/Cargo.toml b/Cargo.toml index 244bf08..5ad3aaf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,10 +38,14 @@ x25519-dalek = { version = "2.0.1", features = ["getrandom", "static_secrets"] } base64 = "0.22.1" chrono = "0.4.38" console-subscriber = "0.4.0" +<<<<<<< HEAD network-interface = "2.0.0" [target.'cfg(target_os="android")'.dependencies] jni = "^0.20" robusta_jni = "0.2.2" nonblock = "0.2.0" -log4rs = "1.3.0" \ No newline at end of file +log4rs = "1.3.0" +======= +network-interface = "2.0.0" +>>>>>>> 35594dea3ce13c2fe98f3a7bdd28e9b3c8351732 diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..77acf86 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,10 @@ +pipeline { + agent any + stages { + stage('Build Project') { + steps { + build "Frida" + } + } + } +} \ No newline at end of file diff --git a/src/client_socks.rs b/src/client_socks.rs index 64673ef..90cabef 100644 --- a/src/client_socks.rs +++ b/src/client_socks.rs @@ -1,56 +1,63 @@ use crossbeam_channel::unbounded; use socket2::SockAddr; use tokio::{net::UdpSocket, sync::Mutex}; -use std::{io::{Read, Write}, net::SocketAddr}; +use std::{io::{Read, Write}, net::{SocketAddr, Ipv4Addr, IpAddr}}; use base64::prelude::*; use log::{error, info, warn}; use std::sync::Arc; -use std::net::Ipv4Addr; use x25519_dalek::{PublicKey, StaticSecret}; use std::process::Command; +use std::collections::HashMap; use aes_gcm::{ aead::{Aead, AeadCore, KeyInit, OsRng}, Aes256Gcm, Nonce}; use crate::config::ClientConfiguration; use crate::udp::{UDPVpnPacket, UDPVpnHandshake, UDPSerializable}; +use network_interface::NetworkInterface; +use network_interface::NetworkInterfaceConfig; -pub async fn client_mode(client_config: ClientConfiguration) { +pub async fn client_mode(client_config: ClientConfiguration, s_interface: Option<&str>) { info!("Starting client..."); + info!("s_interface: {:?}", s_interface); + + let proxy_sock = UdpSocket::bind("127.0.0.1:9997").await.unwrap(); + let proxy_sock_rec = Arc::new(proxy_sock); + let proxy_sock_snd = proxy_sock_rec.clone(); let sock = UdpSocket::bind("0.0.0.0:25565").await.unwrap(); sock.connect(&client_config.server.endpoint).await.unwrap(); - // socks5 - - let (mut dev_reader, mut dev_writer) = dev.split(); - let sock_rec = Arc::new(sock); let sock_snd = sock_rec.clone(); let (tx, rx) = unbounded::>(); let (dx, mx) = unbounded::>(); + let addresses = Arc::new(Mutex::new(SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8080))); + let cipher_shared = Arc::new(Mutex::new(None)); + let addresses_snd = addresses.clone(); tokio::spawn(async move { while let Ok(bytes) = rx.recv() { //info!("Write to tun {:?}", hex::encode(&bytes)); - dev_writer.write_all(&bytes).unwrap(); + let al = addresses_snd.lock().await; + proxy_sock_snd.send_to(&bytes, al.clone()).await; + drop(al); } }); + let addresses_rec = addresses.clone(); tokio::spawn(async move { let mut buf = vec![0; 8192]; - while let Ok(n) = dev_reader.read(&mut buf) { - dx.send(buf[..n].to_vec()).unwrap(); + while let Ok((len, addr)) = proxy_sock_rec.recv_from(&mut buf).await { + let mut al = addresses_rec.lock().await; + *al = addr; + dx.send(buf[..len].to_vec()).unwrap(); } }); - let s_a: SocketAddr = client_config.server.endpoint.parse().unwrap(); - #[cfg(target_os = "linux")] - configure_routes(&s_a.ip().to_string(), s_interface); - let priv_key = BASE64_STANDARD.decode(client_config.client.private_key).unwrap(); let cipher_shared_clone = cipher_shared.clone(); diff --git a/src/main.rs b/src/main.rs index f3980ed..e5e3615 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,7 +11,7 @@ mod server; mod client; mod udp; mod config; -//mod client_socks; +mod client_socks; fn generate_server_config(matches: &ArgMatches, config_path: &str) { let bind_address = matches.value_of("bind-address").expect("No bind address specified");