#!/bin/sh # Aggressive standalone local-only hotspot # Tries to fully release Android's control of the radio IFACE="wlan1" SSID="vegeta black" PSK="supermarioinreallife" CHANNEL="6" AP_IP="192.168.43.1" NET="192.168.43.0/24" DHCP_RANGE="192.168.43.10,192.168.43.50,12h" [ "$(id -u)" -ne 0 ] && { echo "Need root"; exit 1; } echo "[*] Aggressively stopping Android Wi-Fi stack..." # Stop as many Android Wi-Fi related services as possible svc wifi disable 2>/dev/null stop wpa_supplicant 2>/dev/null stop wifi 2>/dev/null killall wpa_supplicant hostapd dnsmasq wificond 2>/dev/null sleep 2 # Extra force setprop ctl.stop wpa_supplicant 2>/dev/null setprop ctl.stop wifi 2>/dev/null sleep 1 echo "[*] Fully resetting $IFACE..." ip link set "$IFACE" down 2>/dev/null ip addr flush dev "$IFACE" 2>/dev/null ip route flush dev "$IFACE" 2>/dev/null # Delete and recreate the interface if possible iw dev "$IFACE" del 2>/dev/null sleep 1 # Try to create a clean AP interface iw phy phy0 interface add "$IFACE" type __ap 2>/dev/null || \ iw phy phy0 interface add "$IFACE" type ap 2>/dev/null sleep 1 ip link set "$IFACE" up 2>/dev/null sleep 1 # Disable reverse path filter echo 0 > /proc/sys/net/ipv4/conf/all/rp_filter echo 0 > /proc/sys/net/ipv4/conf/"$IFACE"/rp_filter 2>/dev/null # hostapd config cat > /tmp/hostapd-$IFACE.conf </dev/null ip link set "$IFACE" up sleep 2 hostapd -B /tmp/hostapd-$IFACE.conf || { echo echo "Standalone hostapd is not working reliably on this device." echo "The internal Wi-Fi firmware is still holding management frames." exit 1 } fi sleep 1 # Configure IP ip addr add $AP_IP/24 broadcast 192.168.43.255 dev $IFACE ip link set $IFACE up ip route add $NET dev $IFACE src $AP_IP 2>/dev/null # Firewall iptables -I INPUT -i $IFACE -j ACCEPT iptables -I OUTPUT -o $IFACE -j ACCEPT iptables -I FORWARD -i $IFACE -j ACCEPT iptables -I FORWARD -o $IFACE -j ACCEPT # DHCP echo "[*] Starting dnsmasq..." dnsmasq \ --interface=$IFACE \ --bind-interfaces \ --dhcp-range=$DHCP_RANGE \ --dhcp-option=3,$AP_IP \ --dhcp-option=6,$AP_IP \ --port=0 \ --no-resolv \ --pid-file=/tmp/dnsmasq-$IFACE.pid & sleep 2 echo echo "=== Standalone Hotspot ===" echo "SSID : $SSID" echo "Password : $PSK" echo "Gateway : $AP_IP" echo iw dev $IFACE info 2>/dev/null | head -12 echo ip -4 addr show $IFACE