mirror of
https://github.com/EFForg/rayhunter.git
synced 2026-06-08 06:01:53 -07:00
Add WiFi client support and S01iptables to T-Mobile and Wingtech installers
Both installers now deploy wpa_supplicant, wpa_cli, udhcpc-hook.sh, and the S01iptables boot-time firewall script. Config generation uses the shared install_config/install_wifi_creds helpers instead of manual string replacement.
This commit is contained in:
+62
-11
@@ -12,6 +12,7 @@ use anyhow::Result;
|
||||
use tokio::time::sleep;
|
||||
|
||||
use crate::TmobileArgs as Args;
|
||||
use crate::connection::{TelnetConnection, install_config, install_wifi_creds};
|
||||
use crate::output::{print, println};
|
||||
use crate::util::{http_ok_every, telnet_send_command, telnet_send_file};
|
||||
use crate::wingtech::start_telnet;
|
||||
@@ -20,12 +21,25 @@ pub async fn install(
|
||||
Args {
|
||||
admin_ip,
|
||||
admin_password,
|
||||
wifi_ssid,
|
||||
wifi_password,
|
||||
}: Args,
|
||||
) -> Result<()> {
|
||||
run_install(admin_ip, admin_password).await
|
||||
run_install(
|
||||
admin_ip,
|
||||
admin_password,
|
||||
wifi_ssid.as_deref(),
|
||||
wifi_password.as_deref(),
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn run_install(admin_ip: String, admin_password: String) -> Result<()> {
|
||||
async fn run_install(
|
||||
admin_ip: String,
|
||||
admin_password: String,
|
||||
wifi_ssid: Option<&str>,
|
||||
wifi_password: Option<&str>,
|
||||
) -> Result<()> {
|
||||
print!("Starting telnet ... ");
|
||||
start_telnet(&admin_ip, &admin_password).await?;
|
||||
sleep(Duration::from_millis(200)).await;
|
||||
@@ -38,15 +52,10 @@ async fn run_install(admin_ip: String, admin_password: String) -> Result<()> {
|
||||
|
||||
telnet_send_command(addr, "mount -o remount,rw /", "exit code 0", true).await?;
|
||||
|
||||
telnet_send_file(
|
||||
addr,
|
||||
"/data/rayhunter/config.toml",
|
||||
crate::CONFIG_TOML
|
||||
.replace("#device = \"orbic\"", "device = \"tmobile\"")
|
||||
.as_bytes(),
|
||||
true,
|
||||
)
|
||||
.await?;
|
||||
let mut conn = TelnetConnection::new(addr, true);
|
||||
let wifi_enabled = wifi_ssid.is_some() && wifi_password.is_some();
|
||||
install_config(&mut conn, "tmobile", false, wifi_enabled).await?;
|
||||
install_wifi_creds(&mut conn, wifi_ssid, wifi_password).await?;
|
||||
|
||||
let rayhunter_daemon_bin = include_bytes!(env!("FILE_RAYHUNTER_DAEMON"));
|
||||
telnet_send_file(
|
||||
@@ -63,6 +72,34 @@ async fn run_install(admin_ip: String, admin_password: String) -> Result<()> {
|
||||
true,
|
||||
)
|
||||
.await?;
|
||||
#[cfg(feature = "wifi-client")]
|
||||
{
|
||||
telnet_send_command(addr, "mkdir -p /data/rayhunter/bin", "exit code 0", true).await?;
|
||||
let wpa_supplicant_bin = include_bytes!(env!("FILE_WPA_SUPPLICANT"));
|
||||
let wpa_cli_bin = include_bytes!(env!("FILE_WPA_CLI"));
|
||||
telnet_send_file(
|
||||
addr,
|
||||
"/data/rayhunter/bin/wpa_supplicant",
|
||||
wpa_supplicant_bin,
|
||||
true,
|
||||
)
|
||||
.await?;
|
||||
telnet_send_file(addr, "/data/rayhunter/bin/wpa_cli", wpa_cli_bin, true).await?;
|
||||
telnet_send_file(
|
||||
addr,
|
||||
"/data/rayhunter/udhcpc-hook.sh",
|
||||
include_bytes!("../../dist/scripts/udhcpc-hook.sh"),
|
||||
true,
|
||||
)
|
||||
.await?;
|
||||
telnet_send_command(
|
||||
addr,
|
||||
"chmod +x /data/rayhunter/bin/wpa_supplicant /data/rayhunter/bin/wpa_cli /data/rayhunter/udhcpc-hook.sh",
|
||||
"exit code 0",
|
||||
true,
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
telnet_send_file(
|
||||
addr,
|
||||
"/etc/init.d/misc-daemon",
|
||||
@@ -91,6 +128,20 @@ async fn run_install(admin_ip: String, admin_password: String) -> Result<()> {
|
||||
true,
|
||||
)
|
||||
.await?;
|
||||
telnet_send_file(
|
||||
addr,
|
||||
"/etc/init.d/S01iptables",
|
||||
include_bytes!("../../dist/scripts/S01iptables"),
|
||||
true,
|
||||
)
|
||||
.await?;
|
||||
telnet_send_command(
|
||||
addr,
|
||||
"chmod 755 /etc/init.d/S01iptables",
|
||||
"exit code 0",
|
||||
true,
|
||||
)
|
||||
.await?;
|
||||
|
||||
println!("Rebooting device and waiting 30 seconds for it to start up.");
|
||||
telnet_send_command(addr, "reboot", "exit code 0", true).await?;
|
||||
|
||||
+62
-11
@@ -18,6 +18,7 @@ use serde::Deserialize;
|
||||
use tokio::time::sleep;
|
||||
|
||||
use crate::WingtechArgs as Args;
|
||||
use crate::connection::{TelnetConnection, install_config, install_wifi_creds};
|
||||
use crate::output::{print, println};
|
||||
use crate::util::{http_ok_every, telnet_send_command, telnet_send_file};
|
||||
|
||||
@@ -30,9 +31,17 @@ pub async fn install(
|
||||
Args {
|
||||
admin_ip,
|
||||
admin_password,
|
||||
wifi_ssid,
|
||||
wifi_password,
|
||||
}: Args,
|
||||
) -> Result<()> {
|
||||
wingtech_run_install(admin_ip, admin_password).await
|
||||
wingtech_run_install(
|
||||
admin_ip,
|
||||
admin_password,
|
||||
wifi_ssid.as_deref(),
|
||||
wifi_password.as_deref(),
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
const KEY: &[u8] = b"abcdefghijklmn12";
|
||||
@@ -88,7 +97,12 @@ pub async fn run_command(admin_ip: &str, admin_password: &str, cmd: &str) -> Res
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn wingtech_run_install(admin_ip: String, admin_password: String) -> Result<()> {
|
||||
async fn wingtech_run_install(
|
||||
admin_ip: String,
|
||||
admin_password: String,
|
||||
wifi_ssid: Option<&str>,
|
||||
wifi_password: Option<&str>,
|
||||
) -> Result<()> {
|
||||
print!("Starting telnet ... ");
|
||||
start_telnet(&admin_ip, &admin_password).await?;
|
||||
println!("ok");
|
||||
@@ -98,15 +112,10 @@ async fn wingtech_run_install(admin_ip: String, admin_password: String) -> Resul
|
||||
telnet_send_command(addr, "mkdir -p /data/rayhunter", "exit code 0", true).await?;
|
||||
println!("ok");
|
||||
|
||||
telnet_send_file(
|
||||
addr,
|
||||
"/data/rayhunter/config.toml",
|
||||
crate::CONFIG_TOML
|
||||
.replace("#device = \"orbic\"", "device = \"wingtech\"")
|
||||
.as_bytes(),
|
||||
true,
|
||||
)
|
||||
.await?;
|
||||
let mut conn = TelnetConnection::new(addr, true);
|
||||
let wifi_enabled = wifi_ssid.is_some() && wifi_password.is_some();
|
||||
install_config(&mut conn, "wingtech", false, wifi_enabled).await?;
|
||||
install_wifi_creds(&mut conn, wifi_ssid, wifi_password).await?;
|
||||
|
||||
let rayhunter_daemon_bin = include_bytes!(env!("FILE_RAYHUNTER_DAEMON"));
|
||||
telnet_send_file(
|
||||
@@ -123,6 +132,34 @@ async fn wingtech_run_install(admin_ip: String, admin_password: String) -> Resul
|
||||
true,
|
||||
)
|
||||
.await?;
|
||||
#[cfg(feature = "wifi-client")]
|
||||
{
|
||||
telnet_send_command(addr, "mkdir -p /data/rayhunter/bin", "exit code 0", true).await?;
|
||||
let wpa_supplicant_bin = include_bytes!(env!("FILE_WPA_SUPPLICANT"));
|
||||
let wpa_cli_bin = include_bytes!(env!("FILE_WPA_CLI"));
|
||||
telnet_send_file(
|
||||
addr,
|
||||
"/data/rayhunter/bin/wpa_supplicant",
|
||||
wpa_supplicant_bin,
|
||||
true,
|
||||
)
|
||||
.await?;
|
||||
telnet_send_file(addr, "/data/rayhunter/bin/wpa_cli", wpa_cli_bin, true).await?;
|
||||
telnet_send_file(
|
||||
addr,
|
||||
"/data/rayhunter/udhcpc-hook.sh",
|
||||
include_bytes!("../../dist/scripts/udhcpc-hook.sh"),
|
||||
true,
|
||||
)
|
||||
.await?;
|
||||
telnet_send_command(
|
||||
addr,
|
||||
"chmod +x /data/rayhunter/bin/wpa_supplicant /data/rayhunter/bin/wpa_cli /data/rayhunter/udhcpc-hook.sh",
|
||||
"exit code 0",
|
||||
true,
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
telnet_send_file(
|
||||
addr,
|
||||
"/etc/init.d/rayhunter_daemon",
|
||||
@@ -144,6 +181,20 @@ async fn wingtech_run_install(admin_ip: String, admin_password: String) -> Resul
|
||||
true,
|
||||
)
|
||||
.await?;
|
||||
telnet_send_file(
|
||||
addr,
|
||||
"/etc/init.d/S01iptables",
|
||||
include_bytes!("../../dist/scripts/S01iptables"),
|
||||
true,
|
||||
)
|
||||
.await?;
|
||||
telnet_send_command(
|
||||
addr,
|
||||
"chmod 755 /etc/init.d/S01iptables",
|
||||
"exit code 0",
|
||||
true,
|
||||
)
|
||||
.await?;
|
||||
|
||||
println!("Rebooting device and waiting 30 seconds for it to start up.");
|
||||
telnet_send_command(addr, "shutdown -r -t 1 now", "exit code 0", true).await?;
|
||||
|
||||
Reference in New Issue
Block a user