summaryrefslogtreecommitdiff
blob: e5343023aaecb4c32a0d0bba4438b5a92c0ccce4 (plain)
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
diff --git a/scripts/airmon-ng.linux b/scripts/airmon-ng.linux
index 7f488391..4d0a5e0c 100755
--- a/scripts/airmon-ng.linux
+++ b/scripts/airmon-ng.linux
@@ -106,7 +106,18 @@ else
 fi
 
 if [ -d /sys/bus/pci ] || [ -d /sys/bus/pci_express ] || [ -d /proc/bus/pci ]; then
-	if [ ! -x "$(command -v lspci 2>&1)" ]; then
+	PCI_DEVICES=0
+	if [ -d /sys/bus/pci/devices ] && [ "$(ls -1 /sys/bus/pci/devices 2>/dev/null | wc -l)" != '0' ]; then
+		PCI_DEVICES=1
+	elif [ -r /proc/bus/pci/devices ] && [ -n "$(cat /proc/bus/pci/devices 2>/dev/null)" ]; then
+		PCI_DEVICES=1
+	elif [ -d /sys/bus/pci_express/devices ] && [ -n "$(ls -1 /sys/bus/pci_express/devices 2>/dev/null | wc -l)" != '0' ]; then
+		PCI_DEVICES=1
+	fi
+
+	if [ ${PCI_DEVICES} -eq 0 ]; then
+		LSPCI=0
+	elif [ ! -x "$(command -v lspci 2>&1)" ]; then
 		printf "Please install lspci from your distro's package manager.\n"
 		exit 1
 	else
@@ -347,21 +358,21 @@ ifaceIsUp() {
 #	fi
 #}
 
-#startDeprecatedIface() {
-#	iwconfig ${1} mode monitor > /dev/null 2>&1
-#	if [ -n "${2}" ]; then
-#		if [ ${2} -lt 1000 ]; then
-#			iwconfig ${1} channel ${2} > /dev/null 2>&1
-#		else
-#			iwconfig ${1} freq ${2}000000 > /dev/null 2>&1
-#		fi
-#	else
-#		iwconfig ${1} channel ${CH} > /dev/null 2>&1
-#	fi
-#	iwconfig ${1} key off > /dev/null 2>&1
-#	setLink ${1} up
-#	printf " (monitor mode enabled)"
-#}
+startDeprecatedIface() {
+	iwconfig ${1} mode monitor > /dev/null 2>&1
+	if [ -n "${2}" ]; then
+		if [ ${2} -lt 1000 ]; then
+			iwconfig ${1} channel ${2} > /dev/null 2>&1
+		else
+			iwconfig ${1} freq ${2}000000 > /dev/null 2>&1
+		fi
+	else
+		iwconfig ${1} channel ${CH} > /dev/null 2>&1
+	fi
+	iwconfig ${1} key off > /dev/null 2>&1
+	setLink ${1} up
+	printf " (monitor mode enabled)"
+}
 
 yesorno() {
 	read input
@@ -419,7 +430,7 @@ startMac80211Iface() {
 		done
 	fi
 	#we didn't bail means we need a monitor interface
-        if [ ${#1} -gt 12 ]; then
+	if [ ${#1} -gt 12 ]; then
 		printf "Interface ${1}mon is too long for linux so it will be renamed to the old style (wlan#) name.\n"
 		findFreeInterface monitor
 	else
@@ -431,10 +442,16 @@ startMac80211Iface() {
 		fi
 		#we didn't bail means our target interface is available
 		setLink ${1} down
+		if [ "${DRIVER}" = "8812au" ] || [ "${DRIVER}" = "8814au" ]; then
+			#grumble grumble, seriously crap vendor driver
+			startDeprecatedIface ${1}
+			setChannelMac80211 ${1}
+			return
+		fi
 		IW_ERROR="$(iw phy ${PHYDEV} interface add ${1}mon type monitor 2>&1)"
 		if [ -z "${IW_ERROR}" ]; then
 			sleep 1
-			if [ "$(cat /sys/class/ieee80211/${PHYDEV}/device/net/${1}mon/type)" = "803" ]; then
+			if [ -r "/sys/class/ieee80211/${PHYDEV}/device/net/${1}mon/type" ] && [ "$(cat /sys/class/ieee80211/${PHYDEV}/device/net/${1}mon/type)" = "803" ]; then
 				setChannelMac80211 ${1}mon
 			else
 				printf "\nNewly created monitor mode interface ${1}mon is *NOT* in monitor mode.\n"
@@ -456,15 +473,12 @@ startMac80211Iface() {
 			printf "\nPlease run \"airmon-ng check kill\" and/or kill your network manager."
 		fi
 	else
-		iw ${1} del
+		isRPiWireless && iw ${1} del
 		printf "\t\t(mac80211 station mode vif disabled for [${PHYDEV}]${1})\n"
 	fi
 }
 
-NEXMON_FIRMWARE_DIR=/opt
-NEXMON_DRIVER_DIR=/opt
-
-hasRPiWireless() {
+isRPiWireless() {
 	local HW_REV=$(grep Revision /proc/cpuinfo | awk '{print $3}')
 	[ -z "${HW_REV}" ] && return 0
 	# http://www.raspberrypi-spy.co.uk/2012/09/checking-your-raspberry-pi-board-version/
@@ -475,29 +489,6 @@ hasRPiWireless() {
 	return 0
 }
 
-isNexutilPresent() {
-	type nexutil >/dev/null 2>/dev/null
-	if [ $? -eq 0 ]; then
-		return 1
-	fi
-	return 0
-}
-
-startNexmonIface() {
-	[ -z $1 ] && return
-
-	if [ -n "$(iwconfig $1 | grep 'Mode:Monitor')" ] && [ -n "$(nexutil -m | grep 'monitor: 2')" ]; then
-		printf "\n\tInterface $1 is already in monitor mode\n"
-	else
-		ifconfig $1 up 2>/dev/null
-		iwconfig $1 mode monitor 2>/dev/null
-		[ "$1" = "wlan0" ] && nexutil -m2
-		[ "$1" = "wlan0" ] || nexutil -m2 -I $1
-		iwconfig $1 channel ${CH}
-		printf "\n\t\t(monitor mode enabled for [${PHYDEV}]${1})\n"
-	fi
-}
-
 startwlIface() {
 	if [ -f "/proc/brcm_monitor0" ]; then
 		if [ -r "/proc/brcm_monitor0" ]; then
@@ -587,12 +578,12 @@ setChannelMac80211() {
 	fi
 }
 
-#stopDeprecatedIface() {
-#	setLink $1 down
-#	iwconfig $1 mode Managed > /dev/null 2>&1
-#	setLink $1 up
-#	printf " (monitor mode disabled)"
-#}
+stopDeprecatedIface() {
+	setLink $1 down
+	iwconfig $1 mode Managed > /dev/null 2>&1
+	setLink $1 up
+	printf " (monitor mode disabled)"
+}
 
 stopMac80211Iface() {
 	if [ -f /sys/class/net/${1}/type ]; then
@@ -605,6 +596,11 @@ stopMac80211Iface() {
 			printf "please report it.\n"
 			exit 1
 		else
+			if [ "${DRIVER}" = "8812au" ] || [ "${DRIVER}" = "8814au" ]; then
+				#grumble grumble, seriously crap vendor driver
+				stopDeprecatedIface ${1}
+				return
+			fi
 			if [ "${ELITE}" = "0" ]; then
 				local need_sta=1
 				if [ -d /sys/class/ieee80211/${PHYDEV}/device/net ]; then
@@ -665,18 +661,6 @@ stopMac80211Iface() {
 	fi
 }
 
-stopNexmonIface() {
-	[ -z $1 ] && return
-	ifconfig $1 down
-	# Running nexutil is not necessary, it gets reset when putting interface down
-	[ "$1" = "wlan0" ] && nexutil -m0
-	[ "$1" = "wlan0" ] || nexutil -m0 -I $1
-	ifconfig $1 down
-	ifconfig $1 up 2> /dev/null
-	iwconfig $1 mode managed 2> /dev/null
-	printf "\n\t\t(monitor mode disabled for [${PHYDEV}]${1})\n"
-}
-
 stopwlIface() {
 	if [ -f "/proc/brcm_monitor0" ]; then
 		if [ -r "/proc/brcm_monitor0" ]; then
@@ -751,6 +735,12 @@ getDriver() {
 	if [ "$DRIVER" = "rtl8187" ] && [ "$STACK" = "ieee80211" ]; then
 		DRIVER="r8187"
 	fi
+	if [ "$DRIVER" = "rtl88xxau" ]; then
+		DRIVER="88XXau"
+	fi
+	if [ "$DRIVER" = "rtl8812au" ]; then
+		DRIVER="8812au"
+	fi
 
 	#Here we will catch the broken lying drivers not caught above
 	#currently this only functions for pci devices and not usb since lsusb has no -k option
@@ -795,6 +785,8 @@ getFrom() {
 				FROM="V"
 			elif [ "$DRIVER" = "rt5390sta" ]; then
 				FROM="V"
+			elif [ "${DRIVER}" = "8812au" ] || [ "${DRIVER}" = "8814au" ]; then
+				FROM="V"
 			fi
 		elif modinfo -F filename $DRIVER 2>&1 | grep -q 'updates/drivers'
 		then
@@ -1346,8 +1338,10 @@ if [ "$DEBUG" = "1" ]; then
 	fi
 fi
 if [ "$VERBOSE" = "1" ]; then
-	lsb_release -a
-	printf "\n"
+	if [ -n "$(command -v lsb_release 2> /dev/null)" ]; then
+		lsb_release -a
+		printf "\n"
+	fi
 	uname -a
 
 	checkvm
@@ -1493,23 +1487,6 @@ for iface in $(printf "${iface_list}"); do
 		if [ "$1" = "stop" ] && [ "$2" = "$iface" ]; then
 			stopwlIface $iface
 		fi
-	elif [ "${CHIPSET}" = 'Broadcom 43430' ] || [ "${CHIPSET}" = 'Broadcom 43455' ]; then
-		hasRPiWireless
-		if [ $? -eq 0 ]; then
-			printf "\n\tNot a Raspberry Pi 3, 3B+ or Zero Wireless, cannot put in monitor mode.\n"
-		else
-			isNexutilPresent
-			if [ $? -eq 0 ]; then
-				printf "\n\tMissing nexutil, cannot switch to monitor mode.\n"
-			else
-				if [ "$1" = "start" ] && [ "$2" = "$iface" ]; then
-					startNexmonIface $iface
-				fi
-				if [ "$1" = "stop" ] && [ "$2" = "$iface" ]; then
-					stopNexmonIface $iface
-				fi
-			fi
-		fi
 	elif [ "$MAC80211" = "1" ]; then
 		if [ "$1" = "start" ] && [ "$2" = "$iface" ]; then
 			startMac80211Iface $iface