mirror of
https://github.com/EFForg/rayhunter.git
synced 2026-07-03 23:33:36 -07:00
WIFI changes to support moxee. May need to rebase as delivering refactoring under other PR.
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
#!/bin/sh
|
||||
# Pushes all client-mode files to the Orbic device via ADB.
|
||||
# Dev tool: pushes WiFi client-mode files to a device via ADB.
|
||||
# For production installs, use the installer instead: ./installer moxee --admin-password X
|
||||
#
|
||||
# Usage: ./setup-device.sh [orbic|moxee]
|
||||
# If no device specified, auto-detects via ADB uid (root=Moxee, shell=Orbic).
|
||||
# Run from the rayhunter repo root.
|
||||
set -e
|
||||
|
||||
@@ -11,14 +15,38 @@ if ! adb devices | grep -q device$; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Pushing scripts..."
|
||||
adb shell "mkdir -p /data/rayhunter/scripts /data/rayhunter/bin"
|
||||
adb push "$SCRIPT_DIR/wifi-client.sh" /data/rayhunter/scripts/wifi-client.sh
|
||||
DEVICE="$1"
|
||||
if [ -z "$DEVICE" ]; then
|
||||
ADB_UID=$(adb shell id -u | tr -d '\r')
|
||||
if [ "$ADB_UID" = "0" ]; then
|
||||
DEVICE="moxee"
|
||||
else
|
||||
DEVICE="orbic"
|
||||
fi
|
||||
echo "Auto-detected device: $DEVICE (uid=$ADB_UID)"
|
||||
fi
|
||||
|
||||
case "$DEVICE" in
|
||||
moxee)
|
||||
DEST="/cache/rayhunter"
|
||||
;;
|
||||
orbic)
|
||||
DEST="/data/rayhunter"
|
||||
;;
|
||||
*)
|
||||
echo "Unknown device: $DEVICE (expected 'orbic' or 'moxee')" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "Pushing scripts to $DEST/scripts/..."
|
||||
adb shell "mkdir -p $DEST/scripts $DEST/bin"
|
||||
adb push "$SCRIPT_DIR/wifi-client.sh" "$DEST/scripts/wifi-client.sh"
|
||||
|
||||
if [ -f "$WPA_DIR/wpa_supplicant" ]; then
|
||||
echo "Pushing wpa_supplicant binaries..."
|
||||
adb push "$WPA_DIR/wpa_supplicant" /data/rayhunter/bin/wpa_supplicant
|
||||
adb push "$WPA_DIR/wpa_cli" /data/rayhunter/bin/wpa_cli
|
||||
echo "Pushing wpa_supplicant binaries to $DEST/bin/..."
|
||||
adb push "$WPA_DIR/wpa_supplicant" "$DEST/bin/wpa_supplicant"
|
||||
adb push "$WPA_DIR/wpa_cli" "$DEST/bin/wpa_cli"
|
||||
else
|
||||
echo "wpa_supplicant binaries not found at $WPA_DIR"
|
||||
echo "Build them first: see tools/build-wpa-supplicant/Dockerfile"
|
||||
@@ -26,5 +54,5 @@ else
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Files pushed. Set WiFi credentials via the web UI or installer,"
|
||||
echo "Files pushed to $DEST. Set WiFi credentials via the web UI or installer,"
|
||||
echo "then reboot. WiFi client starts automatically on boot."
|
||||
|
||||
@@ -9,8 +9,17 @@ LOG="/tmp/wifi-client.log"
|
||||
exec > "$LOG" 2>&1
|
||||
|
||||
CRED_FILE="/data/rayhunter/wifi-creds.conf"
|
||||
WPA_BIN="/data/rayhunter/bin/wpa_supplicant"
|
||||
WPA_CONF="/tmp/wpa_sta.conf"
|
||||
|
||||
# Auto-detect wpa_supplicant location (Moxee uses /cache, Orbic uses /data)
|
||||
if [ -x "/cache/rayhunter/bin/wpa_supplicant" ]; then
|
||||
WPA_BIN="/cache/rayhunter/bin/wpa_supplicant"
|
||||
elif [ -x "/data/rayhunter/bin/wpa_supplicant" ]; then
|
||||
WPA_BIN="/data/rayhunter/bin/wpa_supplicant"
|
||||
else
|
||||
echo "wpa_supplicant not found in /cache/rayhunter/bin or /data/rayhunter/bin"
|
||||
exit 1
|
||||
fi
|
||||
WPA_PID="/tmp/wpa_sta.pid"
|
||||
DHCP_PID="/tmp/udhcpc_wlan1.pid"
|
||||
IFACE="wlan1"
|
||||
@@ -109,7 +118,7 @@ WPAEOF
|
||||
iptables -I INPUT -i "$IFACE" -j ACCEPT
|
||||
iptables -I FORWARD -i "$IFACE" -j ACCEPT
|
||||
|
||||
# Block stock Orbic daemons from phoning home (dmclient, upgrade, etc.)
|
||||
# Block stock daemons from phoning home (dmclient, upgrade, etc.)
|
||||
# Allow only: replies to incoming connections, DHCP renewal, DNS, and HTTPS
|
||||
# (needed for ntfy notifications).
|
||||
iptables -A OUTPUT -o "$IFACE" -m state --state ESTABLISHED,RELATED -j ACCEPT
|
||||
@@ -134,7 +143,7 @@ WPAEOF
|
||||
ip route show
|
||||
|
||||
echo "Internet test:"
|
||||
wget -q -O /dev/null http://detectportal.firefox.com/success.txt && echo "OK" || echo "FAILED"
|
||||
wget -q -O /dev/null https://detectportal.firefox.com/success.txt && echo "OK" || echo "FAILED"
|
||||
}
|
||||
|
||||
status() {
|
||||
|
||||
Reference in New Issue
Block a user