2017-08-08 11:40:32 -06:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-12-05 15:44:54 -07:00
|
|
|
# ================================================================
|
|
|
|
# Configuration Section
|
|
|
|
# ================================================================
|
2017-08-14 03:14:23 -06:00
|
|
|
APServiceConfigDirectory=$FLUXIONWorkspacePath
|
2017-12-05 15:44:54 -07:00
|
|
|
# ================================================================
|
|
|
|
|
|
|
|
#if [ "$APServiceVersion" ]; then return 0; fi
|
|
|
|
#readonly APServiceVersion="1.0"
|
2017-08-14 03:14:23 -06:00
|
|
|
|
2018-01-18 00:14:32 -07:00
|
|
|
function ap_service_stop() {
|
|
|
|
if [ "$APServicePID" ]; then
|
|
|
|
kill $APServicePID &> $FLUXIONOutputDevice
|
2017-12-31 09:02:12 -07:00
|
|
|
fi
|
2017-12-05 15:44:54 -07:00
|
|
|
|
2017-12-31 09:02:12 -07:00
|
|
|
APServicePID=""
|
2017-08-08 11:40:32 -06:00
|
|
|
}
|
|
|
|
|
2018-01-18 00:14:32 -07:00
|
|
|
function ap_service_reset() {
|
|
|
|
ap_service_stop
|
2017-08-08 11:40:32 -06:00
|
|
|
|
2017-12-31 09:02:12 -07:00
|
|
|
# Reset MAC address to original.
|
2018-01-18 00:14:32 -07:00
|
|
|
ifconfig $APServiceInterface down
|
2017-12-31 09:02:12 -07:00
|
|
|
sleep 0.5
|
2017-12-05 15:44:54 -07:00
|
|
|
|
2018-01-18 00:14:32 -07:00
|
|
|
macchanger -p $APServiceInterface &> $FLUXIONOutputDevice
|
2017-12-31 09:02:12 -07:00
|
|
|
sleep 0.5
|
2017-08-08 11:40:32 -06:00
|
|
|
|
2018-01-18 00:14:32 -07:00
|
|
|
ifconfig $APServiceInterface up
|
2017-12-31 09:02:12 -07:00
|
|
|
sleep 0.5
|
2018-01-18 00:14:32 -07:00
|
|
|
|
|
|
|
APServiceAccessInterface=""
|
|
|
|
|
|
|
|
APServiceChannel=""
|
|
|
|
APServiceMAC=""
|
|
|
|
APServiceSSID=""
|
|
|
|
APServiceInterfaceAddress=""
|
|
|
|
APServiceInterface=""
|
|
|
|
|
2017-08-08 11:40:32 -06:00
|
|
|
}
|
|
|
|
|
2018-01-18 00:14:32 -07:00
|
|
|
function ap_service_route() {
|
|
|
|
echo "APService: No custom routes for hostapd" > $FLUXIONOutputDevice
|
2017-08-08 11:40:32 -06:00
|
|
|
}
|
|
|
|
|
2018-01-18 00:14:32 -07:00
|
|
|
function ap_service_prep() {
|
|
|
|
if [ ${#@} -lt 5 ]; then return 1; fi
|
|
|
|
|
|
|
|
APServiceInterface=$1
|
|
|
|
APServiceInterfaceAddress=$2
|
|
|
|
APServiceSSID=$3
|
|
|
|
APServiceMAC=$4
|
|
|
|
APServiceChannel=$5
|
|
|
|
|
|
|
|
ap_service_stop
|
2017-08-08 11:40:32 -06:00
|
|
|
|
2017-12-31 09:02:12 -07:00
|
|
|
# Prepare the hostapd config file.
|
|
|
|
echo "\
|
2018-01-18 00:14:32 -07:00
|
|
|
interface=$APServiceInterface
|
2017-08-08 11:40:32 -06:00
|
|
|
driver=nl80211
|
2018-01-18 00:14:32 -07:00
|
|
|
ssid=$APServiceSSID
|
|
|
|
channel=$APServiceChannel" \
|
|
|
|
> "$APServiceConfigDirectory/$APServiceMAC-hostapd.conf"
|
2017-08-08 11:40:32 -06:00
|
|
|
|
2017-12-31 09:02:12 -07:00
|
|
|
# Spoof virtual interface MAC address.
|
2018-01-18 00:14:32 -07:00
|
|
|
ifconfig $APServiceInterface down
|
2017-12-31 09:02:12 -07:00
|
|
|
sleep 0.5
|
2017-12-05 15:44:54 -07:00
|
|
|
|
2018-01-18 00:14:32 -07:00
|
|
|
macchanger --mac=$APServiceMAC $APServiceInterface &> $FLUXIONOutputDevice
|
2017-12-31 09:02:12 -07:00
|
|
|
sleep 0.5
|
2017-08-08 11:40:32 -06:00
|
|
|
|
2018-01-18 00:14:32 -07:00
|
|
|
ifconfig $APServiceInterface up
|
2017-12-31 09:02:12 -07:00
|
|
|
sleep 0.5
|
2018-01-18 00:14:32 -07:00
|
|
|
|
|
|
|
# HostAPD sets the virtual interface mode
|
|
|
|
# to master, which is supported by dhcpd.
|
|
|
|
APServiceAccessInterface=$APServiceInterface
|
2017-08-08 11:40:32 -06:00
|
|
|
}
|
|
|
|
|
2018-01-18 00:14:32 -07:00
|
|
|
function ap_service_start() {
|
|
|
|
ap_service_stop
|
2017-12-05 15:44:54 -07:00
|
|
|
|
2018-01-18 00:14:32 -07:00
|
|
|
xterm $FLUXIONHoldXterm $TOP -bg "#000000" -fg "#FFFFFF" \
|
|
|
|
-title "FLUXION AP Service [hostapd]" -e \
|
|
|
|
hostapd "$APServiceConfigDirectory/$APServiceMAC-hostapd.conf" &
|
2017-12-31 09:02:12 -07:00
|
|
|
local parentPID=$!
|
2017-08-12 21:36:36 -06:00
|
|
|
|
2017-12-31 09:02:12 -07:00
|
|
|
# Wait till hostapd has started and its virtual interface is ready.
|
|
|
|
while [ ! "$APServicePID" ]; do
|
|
|
|
sleep 1
|
|
|
|
APServicePID=$(pgrep -P $parentPID)
|
|
|
|
done
|
2017-08-12 21:36:36 -06:00
|
|
|
|
2018-01-18 00:14:32 -07:00
|
|
|
ap_service_route
|
2017-08-08 11:40:32 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
# FLUXSCRIPT END
|