Fixed (bug) and improved AP services.

Fixed a bug where once an AP was selected, it could not be changed.
The AP service will now explicitly wait for xterm's child (AP service PID).
Removed killing every process using the same service in the system.
This commit is contained in:
Matias Barcenas 2017-12-05 16:44:54 -06:00
parent a76f5a7a57
commit 7ab63da737
2 changed files with 46 additions and 36 deletions

View File

@ -1,27 +1,29 @@
#!/bin/bash
if [ "$APServiceVersion" ]; then return 0; fi
readonly APServiceVersion="1.0"
# ================================================================
# Configuration Section
# ================================================================
VIGW="at0"
VIAP=$WIAccessPoint
#APServiceAuthenticationMethods=("hash" "wpa_supplicant")
#APServiceAuthenticationMethodsInfo=("(handshake, recommended)" "(connection, slow)")
# airbase-ng uses a monitor-mode virtual interface
# and creates a separate interface, atX, for dhcpd.
VIAPAddress="$VIGWNetwork.2"
# APServiceConfigDirectory=$FLUXIONWorkspacePath
# ================================================================
#if [ "$APServiceVersion" ]; then return 0; fi
#readonly APServiceVersion="1.0"
function ap_stop() {
killall airbase-ng &> $FLUXIONOutputDevice
local FLUXIONAPService=$(ps a | grep -e "FLUXION AP Service" | awk '{print $1'})
if [ "$FLUXIONAPService" ]; then
kill $FLUXIONAPService &> $FLUXIONOutputDevice
if [ "$APServicePID" ]
then kill $APServicePID &> $FLUXIONOutputDevice
fi
APServicePID=""
}
function ap_reset() {
@ -41,11 +43,14 @@ function ap_prep() {
}
function ap_start() {
ap_stop
xterm $BOTTOMRIGHT -bg "#000000" -fg "#FFFFFF" -title "FLUXION AP Service [airbase-ng]" -e airbase-ng -P -e $APTargetSSID -c $APTargetChannel -a $APRogueMAC $VIAP &
local parentPID=$!
# Wait till airebase-ng has started and created the extra virtual interface.
while [ ! $(ps a | awk '$5~/^airbase-ng/ && $0~/'"$APRogueMAC"'/{print $1}') ]
do sleep 1
while [ ! "$APServicePID" ]
do sleep 1; APServicePID=$(pgrep -P $parentPID)
done
ap_route

View File

@ -1,27 +1,29 @@
#!/bin/bash
if [ "$APServiceVersion" ]; then return 0; fi
readonly APServiceVersion="1.0"
# ================================================================
# Configuration Section
# ================================================================
VIGW=$WIAccessPoint
VIAP=$WIAccessPoint
#APServiceAuthenticationMethods=("hash")
#APServiceAuthenticationMethodsInfo=("(handshake, recommended)")
# HostAPD sets the virtual interface mode
# to master, which is supported by dhcpd.
VIAPAddress=$VIGWAddress
APServiceConfigDirectory=$FLUXIONWorkspacePath
# ================================================================
#if [ "$APServiceVersion" ]; then return 0; fi
#readonly APServiceVersion="1.0"
function ap_stop() {
killall hostapd &> $FLUXIONOutputDevice
local FLUXIONAPService=$(ps a | grep -e "FLUXION AP Service" | awk '{print $1'})
if [ "$FLUXIONAPService" ]; then
kill $FLUXIONAPService &> $FLUXIONOutputDevice
if [ "$APServicePID" ]
then kill $APServicePID &> $FLUXIONOutputDevice
fi
APServicePID=""
}
function ap_reset() {
@ -29,17 +31,17 @@ function ap_reset() {
# Reset MAC address to original.
ifconfig $VIAP down
sleep 0.4
sleep 0.5
macchanger -p $VIAP &> $FLUXIONOutputDevice
sleep 0.4
sleep 0.5
ifconfig $VIAP up
sleep 0.4
sleep 0.5
}
function ap_route() {
echo "No custom routes for hostapd" > $FLUXIONOutputDevice
echo "APService: No custom routes for hostapd" > $FLUXIONOutputDevice
}
function ap_prep() {
@ -55,21 +57,24 @@ channel=$APTargetChannel\
# Spoof virtual interface MAC address.
ifconfig $VIAP down
sleep 0.4
sleep 0.5
macchanger --mac=$APRogueMAC $VIAP &> $FLUXIONOutputDevice
sleep 0.4
sleep 0.5
ifconfig $VIAP up
sleep 0.4
sleep 0.5
}
function ap_start() {
xterm $HOLD $BOTTOMRIGHT -bg "#000000" -fg "#FFFFFF" -title "FLUXION AP Service [hostapd]" -e hostapd "$APServiceConfigDirectory/$APRogueMAC-hostapd.conf" &
ap_stop
xterm $FLUXIONHoldXterm $BOTTOMRIGHT -bg "#000000" -fg "#FFFFFF" -title "FLUXION AP Service [hostapd]" -e hostapd "$APServiceConfigDirectory/$APRogueMAC-hostapd.conf" &
local parentPID=$!
# Wait till hostapd has started and its virtual interface is ready.
while [ ! $(ps a | awk '$5~/^hostapd/ && $0~/'"$APRogueMAC-hostapd.conf"'/{print $1}') ]
do sleep 1
while [ ! "$APServicePID" ]
do sleep 1; APServicePID=$(pgrep -P $parentPID)
done
ap_route