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
275d284705
commit
1f729e3506
@ -26,13 +26,13 @@ use crate::jni::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<'_>) {
|
||||||
let (ltx, lrx) = unbounded::<Vec<u8>>();
|
let (ltx, lrx) = unbounded::<Vec<u8>>();
|
||||||
ltx.send("Starting client...".as_bytes());
|
ltx.send("Starting client...".to_vec());
|
||||||
|
|
||||||
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();
|
||||||
|
|
||||||
ltx.send(format!("FD: {:?}", &fd).as_bytes());
|
ltx.send(format!("FD: {:?}", &fd).to_vec());
|
||||||
ltx.send("So exhausting".as_bytes());
|
ltx.send("So exhausting".to_vec());
|
||||||
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);
|
||||||
@ -54,7 +54,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() {
|
||||||
ltx.send("Write to tun.".as_bytes());
|
ltx.send("Write to tun.".to_vec());
|
||||||
dev_writer.write_all(&bytes).unwrap();
|
dev_writer.write_all(&bytes).unwrap();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -62,7 +62,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) {
|
||||||
ltx.send("Read from tun.".as_bytes());
|
ltx.send("Read from tun.".to_vec());
|
||||||
dx.send(buf[..n].to_vec()).unwrap();
|
dx.send(buf[..n].to_vec()).unwrap();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -75,7 +75,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 {
|
||||||
ltx.send("Read from socket".as_bytes());
|
ltx.send("Read from socket".to_vec());
|
||||||
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) => {
|
||||||
@ -100,17 +100,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) => { ltx.send(format!("Decryption error! {:?}", error)); }
|
Err(error) => { ltx.send(format!("Decryption error! {:?}", error).to_vec()); }
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ltx.send("There is no static_secret".as_bytes());
|
ltx.send("There is no static_secret".to_vec());
|
||||||
}
|
}
|
||||||
}, // payload
|
}, // payload
|
||||||
2 => { ltx.send("Got keepalive packet".as_bytes()); },
|
2 => { ltx.send("Got keepalive packet".to_vec()); },
|
||||||
_ => { ltx.send("Unexpected header value.".as_bytes()); }
|
_ => { ltx.send("Unexpected header value.".to_vec()); }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
None => { ltx.send("There is no header.".as_bytes()); }
|
None => { ltx.send("There is no header.".to_vec()); }
|
||||||
}
|
}
|
||||||
drop(s_cipher);
|
drop(s_cipher);
|
||||||
}
|
}
|
||||||
@ -139,13 +139,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();
|
||||||
ltx.send("Write to socket".as_bytes());
|
ltx.send("Write to socket".to_vec());
|
||||||
sock_snd.send(&serialized_data).await.unwrap();
|
sock_snd.send(&serialized_data).await.unwrap();
|
||||||
} else {
|
} else {
|
||||||
ltx.send("Socket encryption failed.".as_bytes());
|
ltx.send("Socket encryption failed.".to_vec());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ltx.send("There is no shared_secret in main loop".as_bytes());
|
ltx.send("There is no shared_secret in main loop".to_vec());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user