-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
hostapd.sh
executable file
·98 lines (73 loc) · 2.18 KB
/
hostapd.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/bash
# ================================================================
# Configuration Section
# ================================================================
APServiceConfigDirectory=$FLUXIONWorkspacePath
# ================================================================
#if [ "$APServiceVersion" ]; then return 0; fi
#readonly APServiceVersion="1.0"
function ap_service_stop() {
if [ "$APServicePID" ]; then
kill $APServicePID &> $FLUXIONOutputDevice
fi
APServicePID=""
}
function ap_service_reset() {
ap_service_stop
# Reset MAC address to original.
ifconfig $APServiceInterface down
sleep 0.5
macchanger -p $APServiceInterface &> $FLUXIONOutputDevice
sleep 0.5
ifconfig $APServiceInterface up
sleep 0.5
APServiceAccessInterface=""
APServiceChannel=""
APServiceMAC=""
APServiceSSID=""
APServiceInterfaceAddress=""
APServiceInterface=""
}
function ap_service_route() {
echo "APService: No custom routes for hostapd" > $FLUXIONOutputDevice
}
function ap_service_prep() {
if [ ${#@} -lt 5 ]; then return 1; fi
APServiceInterface=$1
APServiceInterfaceAddress=$2
APServiceSSID=$3
APServiceMAC=$4
APServiceChannel=$5
ap_service_stop
# Prepare the hostapd config file.
echo "\
interface=$APServiceInterface
driver=nl80211
ssid=$APServiceSSID
channel=$APServiceChannel" \
> "$APServiceConfigDirectory/$APServiceMAC-hostapd.conf"
# Spoof virtual interface MAC address.
ifconfig $APServiceInterface down
sleep 0.5
macchanger --mac=$APServiceMAC $APServiceInterface &> $FLUXIONOutputDevice
sleep 0.5
ifconfig $APServiceInterface up
sleep 0.5
# HostAPD sets the virtual interface mode
# to master, which is supported by dhcpd.
APServiceAccessInterface=$APServiceInterface
}
function ap_service_start() {
ap_service_stop
xterm $FLUXIONHoldXterm $TOP -bg "#000000" -fg "#FFFFFF" \
-title "FLUXION AP Service [hostapd]" -e \
hostapd "$APServiceConfigDirectory/$APServiceMAC-hostapd.conf" &
local parentPID=$!
# Wait till hostapd has started and its virtual interface is ready.
while [ ! "$APServicePID" ]; do
sleep 1
APServicePID=$(pgrep -P $parentPID)
done
ap_service_route
}
# FLUXSCRIPT END