Trying to implement my ideas

modified:   Cargo.lock
	modified:   frida_client/Cargo.toml
	modified:   frida_client/src/client.rs
This commit is contained in:
Michael Wain 2024-12-16 22:58:04 +03:00
parent 7b327b1b30
commit f589ba2b48
3 changed files with 18 additions and 10 deletions

1
Cargo.lock generated
View File

@ -1607,6 +1607,7 @@ dependencies = [
"env_logger", "env_logger",
"frida_core", "frida_core",
"log", "log",
"rand",
"regex", "regex",
"tokio", "tokio",
"tokio-util", "tokio-util",

View File

@ -20,4 +20,5 @@ tokio = { version = "1", features = ["full", "signal", "tracing"] }
tokio-util = "0.7.12" tokio-util = "0.7.12"
env_logger = "0.9" env_logger = "0.9"
log = "0.4.20" log = "0.4.20"
regex = "1.11.1" regex = "1.11.1"
rand = { version = "0.8.5", features = ["small_rng", "getrandom", "std_rng"] }

View File

@ -1,14 +1,16 @@
pub mod general { pub mod general {
use frida_core::config::ClientConfiguration; use frida_core::config::ClientConfiguration;
use rand::Rng;
use tokio_util::{codec::Framed, sync::CancellationToken}; use tokio_util::{codec::Framed, sync::CancellationToken};
use tokio::{net::UdpSocket, sync::{Mutex, mpsc}, io::{AsyncWriteExt, AsyncReadExt}, fs::File}; use tokio::{fs::File, io::{AsyncReadExt, AsyncWriteExt}, net::UdpSocket, sync::{mpsc, Mutex}, time};
use log::{error, info, warn}; use log::{error, info, warn};
use aes_gcm::{ use aes_gcm::{
aead::{Aead, AeadCore, KeyInit, OsRng}, aead::{Aead, AeadCore, KeyInit, OsRng},
Aes256Gcm, Nonce}; Aes256Gcm, Nonce};
use base64::prelude::*; use base64::prelude::*;
use std::{io::{Read, Write}, sync::Arc}; use std::{io::{Read, Write}, sync::Arc, time::Duration};
use std::net::Ipv4Addr; use std::net::Ipv4Addr;
use rand::rngs::{OsRng as OsPRNG};
use x25519_dalek::{PublicKey, StaticSecret}; use x25519_dalek::{PublicKey, StaticSecret};
use frida_core::udp::{UDPVpnPacket, UDPVpnHandshake, UDPSerializable}; use frida_core::udp::{UDPVpnPacket, UDPVpnHandshake, UDPSerializable};
@ -32,6 +34,7 @@ pub mod general {
let sock_rec = Arc::new(sock); let sock_rec = Arc::new(sock);
let sock_snd = sock_rec.clone(); let sock_snd = sock_rec.clone();
let sock_hnd = sock_snd.clone();
let (tx, mut rx) = mpsc::unbounded_channel::<Vec<u8>>(); let (tx, mut rx) = mpsc::unbounded_channel::<Vec<u8>>();
let (dx, mut mx) = mpsc::unbounded_channel::<Vec<u8>>(); let (dx, mut mx) = mpsc::unbounded_channel::<Vec<u8>>();
@ -44,16 +47,19 @@ pub mod general {
let pkey = BASE64_STANDARD.decode(&self.client_config.client.public_key).unwrap(); let pkey = BASE64_STANDARD.decode(&self.client_config.client.public_key).unwrap();
let handshake = UDPVpnHandshake{ public_key: pkey, request_ip: self.client_config.client.address.parse::<Ipv4Addr>().unwrap() }; let handshake = UDPVpnHandshake{ public_key: pkey, request_ip: self.client_config.client.address.parse::<Ipv4Addr>().unwrap() };
let mut nz = 0; tokio::spawn(async move {
while nz < 25 { let mut interval = time::interval(Duration::from_millis(1));
sock_snd.send(&handshake.serialize()).await.unwrap(); let mut rng = OsPRNG::default();
nz += 1 loop {
} interval.tick().await;
//sock_snd.send(&handshake.serialize()).await.unwrap(); interval = time::interval(Duration::from_millis(1000 * rng.gen_range(10..=15))); // 960
sock_hnd.send(&handshake.serialize()).await.unwrap();
}
});
let s_cipher = cipher_shared.clone(); let s_cipher = cipher_shared.clone();
let _ = dev_writer.write(&handshake.serialize()).await; //let _ = dev_writer.write(&handshake.serialize()).await;
let mut buf1 = vec![0; 4096]; // should be changed to less bytes let mut buf1 = vec![0; 4096]; // should be changed to less bytes