modified: src/client.rs
Some checks failed
gitea/Frida-android-native/pipeline/head There was a failure building this commit
Some checks failed
gitea/Frida-android-native/pipeline/head There was a failure building this commit
This commit is contained in:
parent
3f5c1940b7
commit
8901d3b5e5
@ -22,16 +22,17 @@ use crate::udp::{UDPVpnPacket, UDPVpnHandshake, UDPSerializable};
|
|||||||
use network_interface::NetworkInterface;
|
use network_interface::NetworkInterface;
|
||||||
use network_interface::NetworkInterfaceConfig;
|
use network_interface::NetworkInterfaceConfig;
|
||||||
use robusta_jni::jni::JNIEnv;
|
use robusta_jni::jni::JNIEnv;
|
||||||
|
use crate::FridaLib;
|
||||||
|
|
||||||
pub async fn client_mode(client_config: ClientConfiguration, fd: i32, env: &JNIEnv<'_>) {
|
pub async fn client_mode(client_config: ClientConfiguration, fd: i32, env: &JNIEnv<'_>) {
|
||||||
info!("Starting client...");
|
FridaLib::traceFromNative(env, "Starting client...".to_string());
|
||||||
|
|
||||||
let sock = UdpSocket::bind("0.0.0.0:25565").await.unwrap();
|
let sock = UdpSocket::bind("0.0.0.0:25565").await.unwrap();
|
||||||
sock.connect(&client_config.server.endpoint).await.unwrap();
|
sock.connect(&client_config.server.endpoint).await.unwrap();
|
||||||
|
|
||||||
|
|
||||||
info!("FD: {:?}", &fd);
|
FridaLib::traceFromNative(env, format!("FD: {:?}", &fd));
|
||||||
info!("So exhausting");
|
FridaLib::traceFromNative(env, "So exhausting".to_string());
|
||||||
let mut dev = unsafe { File::from_raw_fd(fd) };
|
let mut dev = unsafe { File::from_raw_fd(fd) };
|
||||||
let mut dev1 = dev.try_clone().unwrap();
|
let mut dev1 = dev.try_clone().unwrap();
|
||||||
let mut dev_reader = BufReader::new(dev);
|
let mut dev_reader = BufReader::new(dev);
|
||||||
@ -47,7 +48,7 @@ pub async fn client_mode(client_config: ClientConfiguration, fd: i32, env: &JNIE
|
|||||||
|
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
while let Ok(bytes) = rx.recv() {
|
while let Ok(bytes) = rx.recv() {
|
||||||
info!("Write to tun.");
|
FridaLib::traceFromNative(env, "Write to tun.".to_string());
|
||||||
dev_writer.write_all(&bytes).unwrap();
|
dev_writer.write_all(&bytes).unwrap();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -55,7 +56,7 @@ pub async fn client_mode(client_config: ClientConfiguration, fd: i32, env: &JNIE
|
|||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
let mut buf = vec![0; 1400]; // mtu
|
let mut buf = vec![0; 1400]; // mtu
|
||||||
while let Ok(n) = dev_reader.read(&mut buf) {
|
while let Ok(n) = dev_reader.read(&mut buf) {
|
||||||
info!("Read from tun.");
|
FridaLib::traceFromNative(env, "Read from tun.".to_string());
|
||||||
dx.send(buf[..n].to_vec()).unwrap();
|
dx.send(buf[..n].to_vec()).unwrap();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -68,7 +69,7 @@ pub async fn client_mode(client_config: ClientConfiguration, fd: i32, env: &JNIE
|
|||||||
|
|
||||||
loop {
|
loop {
|
||||||
if let Ok(l) = sock_rec.recv(&mut buf).await {
|
if let Ok(l) = sock_rec.recv(&mut buf).await {
|
||||||
info!("Read from socket");
|
FridaLib::traceFromNative(env, "Read from socket".to_string());
|
||||||
let mut s_cipher = cipher_shared_clone.lock().await;
|
let mut s_cipher = cipher_shared_clone.lock().await;
|
||||||
match buf.first() {
|
match buf.first() {
|
||||||
Some(h) => {
|
Some(h) => {
|
||||||
@ -93,17 +94,17 @@ pub async fn client_mode(client_config: ClientConfiguration, fd: i32, env: &JNIE
|
|||||||
let nonce = Nonce::clone_from_slice(&wrapped_packet.nonce);
|
let nonce = Nonce::clone_from_slice(&wrapped_packet.nonce);
|
||||||
match aes.decrypt(&nonce, &wrapped_packet.data[..]) {
|
match aes.decrypt(&nonce, &wrapped_packet.data[..]) {
|
||||||
Ok(decrypted) => { let _ = tx.send(decrypted); },
|
Ok(decrypted) => { let _ = tx.send(decrypted); },
|
||||||
Err(error) => error!("Decryption error! {:?}", error)
|
Err(error) => FridaLib::traceFromNative(env, format!("Decryption error! {:?}", error))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
warn!("There is no static_secret");
|
FridaLib::traceFromNative(env, "There is no static_secret".to_string());
|
||||||
}
|
}
|
||||||
}, // payload
|
}, // payload
|
||||||
2 => info!("Got keepalive packet"),
|
2 => FridaLib::traceFromNative(env, "Got keepalive packet".to_string()),
|
||||||
_ => error!("Unexpected header value.")
|
_ => FridaLib::traceFromNative(env, "Unexpected header value.".to_string())
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
None => error!("There is no header.")
|
None => FridaLib::traceFromNative(env, "There is no header.".to_string())
|
||||||
}
|
}
|
||||||
drop(s_cipher);
|
drop(s_cipher);
|
||||||
}
|
}
|
||||||
@ -132,13 +133,13 @@ pub async fn client_mode(client_config: ClientConfiguration, fd: i32, env: &JNIE
|
|||||||
if let Ok(ciphered_d) = ciphered_data {
|
if let Ok(ciphered_d) = ciphered_data {
|
||||||
let vpn_packet = UDPVpnPacket{ data: ciphered_d, nonce: nonce.to_vec()};
|
let vpn_packet = UDPVpnPacket{ data: ciphered_d, nonce: nonce.to_vec()};
|
||||||
let serialized_data = vpn_packet.serialize();
|
let serialized_data = vpn_packet.serialize();
|
||||||
info!("Write to socket");
|
FridaLib::traceFromNative(env, "Write to socket".to_string());
|
||||||
sock_snd.send(&serialized_data).await.unwrap();
|
sock_snd.send(&serialized_data).await.unwrap();
|
||||||
} else {
|
} else {
|
||||||
error!("Socket encryption failed.");
|
FridaLib::traceFromNative(env, "Socket encryption failed.".to_string());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
warn!("There is no shared_secret in main loop");
|
FridaLib::traceFromNative(env, "There is no shared_secret in main loop".to_string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user