File: test-aireplay-ng-0003.sh

package info (click to toggle)
aircrack-ng 1%3A1.6%2Bgit20210130.91820bc-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 19,056 kB
  • sloc: ansic: 67,045; cs: 5,392; sh: 3,773; python: 2,565; pascal: 1,074; asm: 570; makefile: 253; cpp: 46
file content (72 lines) | stat: -rwxr-xr-x 1,572 bytes parent folder | download | duplicates (3)
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
#!/bin/sh
# Aireplay-ng: directed deauth

if test ! -z "${CI}"; then exit 77; fi

# Load helper functions
. "${abs_builddir}/../test/int-test-common.sh"

# Check root
check_root

# Check all required tools are installed
check_airmon_ng_deps_present
is_tool_present tcpdump

# Check for interfering processes
airmon_ng_check

trap  cleanup INT QUIT SEGV PIPE ALRM TERM EXIT

# Load mac80211_hwsim
load_module 1

# Check there are two radios
check_radios_present 1

# Get interface name
get_hwsim_interface_name 1
WI_IFACE=${IFACE}

# Put interface in monitor so tcpdump captures in the correct mode
set_monitor_mode ${WI_IFACE}
[ $? -eq 1 ] && exit 1

# Start tcpdump capture in the background
TCPDUMP_IFACE=${WI_IFACE}
run_tcpdump

# Next test is directed
AP_MAC="00:11:22:33:44:55"
CLIENT_MAC="00:13:37:00:11:22"
"${abs_builddir}/../aireplay-ng${EXEEXT}" \
	-0 1 \
	-a ${AP_MAC} \
	-c ${CLIENT_MAC} \
	-D \
	${WI_IFACE} \
		2>&1 >/dev/null

# Wait a second
sleep 2

# Kill tcpdump
kill_tcpdump

# Count packets
AMOUNT_PACKETS_AP=$(tcpdump -r ${TEMP_TCPDUMP_PCAP} 2>/dev/null | ${GREP} "DeAuthentication (${AP_MAC}" | wc -l)
AMOUNT_PACKETS_CLIENT=$(tcpdump -r ${TEMP_TCPDUMP_PCAP} 2>/dev/null | ${GREP} "DeAuthentication (${CLIENT_MAC}" | wc -l)

# There should be exactly 256 deauth total
RET=0
if [ ${AMOUNT_PACKETS_CLIENT} -ne 128 ]; then
	RET=1
	echo "Expected 128 deauth frames from the client, got ${AMOUNT_PACKETS_CLIENT}"
fi

if [ ${AMOUNT_PACKETS_AP} -ne 128 ]; then
	RET=1
	echo "Expected 128 deauth frames from the AP, got ${AMOUNT_PACKETS_AP}"
fi

exit ${RET}