-
Notifications
You must be signed in to change notification settings - Fork 3
/
20061216-133556_000-wifidetect
578 lines (529 loc) · 17.2 KB
/
20061216-133556_000-wifidetect
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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
#!/bin/sh
# Original work by Thomas d'Otreppe : airmon-ng
# Modded by Grimmlin for pentoo
# Modded by Zero_Chaos due to morbid insanity
# Zero_Chaos has added the functionality to put
# ALL wireless cards that are capable into monitor mode
# and configure kismet to use them all. If this is not
# what you want, don't use this script
# Known limitations:
# 1.) if madwifi-ng detection fails it should use madwifi-old
# before continuing. It seems my bash-fu is too weak
# 2.) if you have multiple madwifi-ng devices it may get ugly (not sure, and can't test)
# 3.) if you have madwifi-ng and you run monitor twice it
# will loop creating monitor VAPs
# VERSION=200611090053 GMT-5
IFACE=""
KISMET=/root/pentoo/kismet.conf
echo -n "Wifi detection script running in mode "
if [ "`basename $0`" = "kismetautoconf" ]
then
echo "kismet auto configuration."
echo -n "Clearing kismet.conf..."
sed -e '/^source=/d' -e '/^enablesources=/d' -i $KISMET
echo "done"
fi
if [ "`basename $0`" = "monitor" ]
then
echo "monitor."
echo "All detected devices will enter monitor mode."
fi
if [ "`basename $0`" = "unmonitor" ]
then
echo "unmonitor."
echo "All detected devices will leave monitor mode."
fi
if [ "`basename $0`" = "wifidetect" ]
then
echo "detect."
echo "Here is a list of information for detected devices:"
fi
CH=6 # default channel is 6 in USA
which iwpriv > /dev/null 2> /dev/null || # checking for wireless-tools
{ echo Wireless tools not found ; exit ; }
echo -e "Interface\tChipset\t\tDriver\n"
function startStdIface() {
ifconfig $1 down
iwconfig $1 key off 2> /dev/null >/dev/null
iwconfig $1 mode monitor 2> /dev/null >/dev/null
ifconfig $1 up # it appears most (all) interfaces don't accept channel when down!
sleep 1.5 # it also appears that is takes more than 1s to accept the channel command
iwconfig $1 channel $CH 2> /dev/null >/dev/null
echo -n " (monitor mode enabled)"
}
function stopStdIface() {
ifconfig $1 down 2> /dev/null >/dev/null
iwconfig $1 mode Managed 2> /dev/null >/dev/null
ifconfig $1 down 2> /dev/null >/dev/null
echo -n " (monitor mode disabled)"
}
for iface in `ifconfig -a 2>/dev/null | egrep HWaddr | cut -b 1-7`
do
if [ -e "/proc/sys/dev/$iface/fftxqmin" ] # tests for madwifi-ng master interface
then
echo -e "$iface\t\tAtheros\t\tmadwifi-ng (master interface)"
fi
continue
done
for iface in `iwconfig 2>/dev/null | egrep '(IEEE|ESSID)' | cut -b 1-7`
do
if [ x"`iwpriv $iface 2>/dev/null | grep inact_auth`" != "x" ] # testing for madwifi
then
if [ -e "/proc/sys/net/$iface/%parent" ] # makes sure it is really madwifi VAP
then
echo -e -n "$iface\t\tAtheros\t\tmadwifi-ng VAP (parent:`cat /proc/sys/net/$iface/%parent`)"
if [ "`cat /proc/sys/net/$iface/dev_type`" != "1" ]
then
echo -e -n "(Monitor w/ "
if [ "801" == $"`cat /proc/sys/net/$iface/dev_type`" ]
then
echo -e -n "802.11 headers)"
fi
if [ "802" == $"`cat /proc/sys/net/$iface/dev_type`" ]
then
echo -e -n "Prism headers)"
fi
if [ "803" == $"`cat /proc/sys/net/$iface/dev_type`" ]
then
echo -e -n "Radiotap headers)"
fi
if [ "803" == $"`cat /proc/sys/net/$iface/dev_type`" ]
then
echo -e -n "Atheros Descriptors)"
fi
fi
fi
if [ "`basename $0`" = "unmonitor" ]
then
if [ "1" == `cat /proc/sys/net/$iface/dev_type` ]
then
echo "(non-monitor vap left alone)"
fi
# if [ "801" == `cat /proc/sys/net/$iface/dev_type` ] || [ "802" == `cat /proc/sys/net/$iface/dev_type` ] || [ "803" == `cat /proc/sys/net/$iface/dev_type` ] || [ "804" == `cat /proc/sys/net/$iface/dev_type` ]
if [ "1" != "`cat /proc/sys/net/$iface/dev_type`" ] # is this a safe substiution for the above?
then
wlanconfig $iface destroy
echo "(monitor vap destroyed)"
fi
fi
if [ "`basename $0`" = "monitor" ] # && [ $iface = "$IFACE" ]
then
if [ "1" == `cat /proc/sys/net/$iface/dev_type` ]
then
ifconfig $iface down
echo " (non-monitor interface downed, WARNING: you should destroy it)"
else
wlanconfig $iface destroy
echo " (monitor interface $iface destroyed)"
fi
for master in `ifconfig -a 2>/dev/null | egrep HWaddr | cut -b 1-7` # pulls all interface names
do
if [ -e "/proc/sys/dev/$master/fftxqmin" ] # tests for madwifi-ng master interface
then
MONITORIFACE=`wlanconfig ath create wlandev $master wlanmode monitor`
sleep 1s
ifconfig $MONITORIFACE up
echo -e -n "$MONITORIFACE\t\tAtheros\t\tmadwifi-ng VAP (parent:`cat /proc/sys/net/$iface/%parent`)(Monitor w/ Prism Headers)"
fi
continue
echo
done
fi
if [ "`basename $0`" = "kismetautoconf" ]
then
if [ "1" = `cat /proc/sys/net/$iface/dev_type` ]
then
ifconfig $iface down
echo "(non-monitor interface downed, WARNING: you should destroy it)"
fi
for master in `ifconfig -a 2>/dev/null | egrep HWaddr | cut -b 1-7` # pulls all interface names
do
if [ -e "/proc/sys/dev/$master/fftxqmin" ] # tests for madwifi-ng master interface
then
echo "source=madwifi_g,$master,Atheros" >> $KISMET
echo -e -n "$master\t\tAtheros\t\tmadwifi-ng (added to kismet.conf)"
fi
continue
echo
done
fi
#failing madwifi-ng should default back to madwifi-old, but is the code right? no, it isn't)
#fix madwifi-old handling
# echo -e -n "$iface\t\tAtheros\t\tmadwifi"
# if [ "`basename $0`" = "monitor" ] # && [ x$2 = x$iface ]
# then
# startStdIface $iface $CH
# fi
# if [ "`basename $0`" = "unmonitor" ] # && [ x$2 = x$iface ]
# then
# stopStdIface $iface
# fi
# if [ "`basename $0`" = "kismetautoconf" ]
# then
# echo "source=madwifi_g,$iface,Atheros" >>$KISMET
# echo -e -n " (added to kismet.conf)"
# fi
# echo
continue
fi
if [ x"`iwpriv $iface 2>/dev/null | grep force_reset`" != "x" ]
then
echo -e -n "$iface\t\tHermesI\t\torinoco"
if [ "`basename $0`" = "monitor" ] # && [ x$2 = x$iface ]
then
iwconfig $iface mode Monitor channel $CH &>/dev/null
iwpriv $iface monitor 1 $CH &>/dev/null
ifconfig $iface up
echo -n " (monitor mode enabled)"
fi
if [ "`basename $0`" = "unmonitor" ] # && [ x$2 = x$iface ]
then
ifconfig $iface down
iwpriv $iface monitor 0 &>/dev/null
iwconfig $iface mode Managed &>/dev/null
echo -n " (monitor mode disabled)"
fi
if [ "`basename $0`" = "kismetautoconf" ]
then
echo "source=orinoco,$iface,HermesI" >>$KISMET
echo -n " (added to kismet.conf)"
fi
echo
continue
fi
if [ `iwpriv $iface 2>/dev/null | grep -v $iface | md5sum | awk '{print $1}'` == "2310629be8b9051238cde37520d97755" ]
then
echo -e -n "$iface\t\tCentrino b\tipw2100"
if [ "`basename $0`" = "monitor" ] # && [ x$2 = x$iface ]
then
startStdIface $iface $CH
fi
if [ "`basename $0`" = "unmonitor" ] # && [ x$2 = x$iface ]
then
stopStdIface $iface
fi
if [ "`basename $0`" = "kismetautoconf" ] # && [ x$2 = x$iface ]
then
echo "source=ipw2100,$iface,Centrino_b" >>$KISMET
echo -n " (added to kismet.conf)"
fi
echo
continue
fi
if [ x"`iwpriv $iface 2>/dev/null | grep sw_reset`" != "x" ]
then
MODINFO=`modinfo ipw2200 | awk '/^version/ {print $2}'`
# if { echo "$MODINFO" | grep -E -v '^1\.0\.[0123]|^1\.[1-9]' ; } # once we are on version 2.x this won't work
# then
# echo "Monitor mode not supported, please upgrade"
# else
echo -e -n "$iface\t\tCentrino b/g\tipw2200"
if [ "`basename $0`" = "monitor" ] # && [ x$2 = x$iface ]
then
startStdIface $iface $CH
fi
if [ "`basename $0`" = "unmonitor" ] # && [ x$2 = x$iface ]
then
stopStdIface $iface
fi
if [ "`basename $0`" = "kismetautoconf" ] # && [ x$2 = x$iface ]
then
echo "source=ipw2200,$iface,Centrino_g" >>$KISMET
echo -n " (added to kismet.conf)"
fi
# if { echo "$MODINFO" | grep -E '^1\.0\.(5|7|8|11)$|^1\.[1-9]' ; }
# then
# echo -e -n " (Warning: bad module version, you should upgrade)"
# fi
# fi
echo
continue
fi
if [ x"`iwpriv $iface 2>/dev/null | grep set_preamble`" != "x" ]
then
echo -e -n "$iface\t\tCentrino b/g\tipw3945"
if [ "`basename $0`" = "monitor" ] # && [ x$2 = x$iface ]
then
startStdIface $iface $CH
fi
if [ "`basename $0`" = "unmonitor" ] # && [ x$2 = x$iface ]
then
stopStdIface $iface
fi
if [ "`basename $0`" = "kismetautoconf" ] # && [ x$2 = x$iface ]
then
echo "source=ipw3945,$iface,Centrino_g" >>$KISMET
echo -n " (added to kismet.conf)"
fi
echo
continue
fi
if [ x"`iwpriv $iface 2>/dev/null | grep extrates`" != "x" ]
then
echo -e -n "$iface\t\tPrismGT\t\tprism54"
if [ "`basename $0`" = "monitor" ] # && [ x$2 = x$iface ]
then
ifconfig $iface up
iwconfig $iface mode Monitor channel $CH
iwpriv $iface set_prismhdr 1 &>/dev/null #check this shit out
echo -n " (monitor mode enabled)"
fi
if [ "`basename $0`" = "unmonitor" ] # && [ x$2 = x$iface ]
then
stopStdIface $iface
fi
if [ "`basename $0`" = "kismetautoconf" ] # && [ x$2 = x$iface ]
then
echo "source=prism54g,$iface,Prism54" >>$KISMET
echo -n " (added to kismet.conf)"
fi
echo
continue
fi
if [ x"`iwpriv $iface 2>/dev/null | grep antsel_rx`" != "x" ]
then
if [ x"`iwconfig $iface 2>/dev/null | grep "Rx invalid nwid:"`" != "x" ] && [ x"`iwconfig $iface 2>/dev/null | grep "Invalid misc:"`" != "x" ]
then
echo -e -n "$iface\t\tPrism2\t\tHostAP"
if [ "`basename $0`" = "monitor" ] # && [ x$2 = x$iface ]
then
iwconfig $iface mode Monitor channel $CH
iwpriv $iface monitor_type 1 &>/dev/null #Check this shit out
ifconfig $iface up
echo -n " (monitor mode enabled)"
fi
if [ "`basename $0`" = "unmonitor" ] # && [ x$2 = x$iface ]
then
stopStdIface $iface
fi
if [ "`basename $0`" = "kismetautoconf" ] # && [ x$2 = x$iface ]
then
echo "source=hostap,$iface,Prism2" >>$KISMET
echo -n " (added to kismet.conf)"
fi
else
echo -e -n "$iface\t\tPrism2\t\tHostAP (master interface)"
fi
echo
continue
fi
if [ x"`wlancfg show $iface 2>/dev/null | grep p2CnfWEPFlags`" != "x" ]
then
echo -e -n "$iface\t\tPrism2\t\twlan-ng"
if [ "`basename $0`" = "monitor" ] # && [ x$2 = x$iface ]
then
wlanctl-ng $iface lnxreq_ifstate ifstate=enable >/dev/null
wlanctl-ng $iface lnxreq_wlansniff enable=true channel=$CH \
prismheader=true wlanheader=false \
stripfcs=true keepwepflags=true >/dev/null
echo p2CnfWEPFlags=0,4,7 | wlancfg set $iface
ifconfig $iface up
echo -n " (monitor mode enabled)"
fi
if [ "`basename $0`" = "unmonitor" ] # && [ x$2 = x$iface ]
then
ifconfig $iface down
wlanctl-ng $iface lnxreq_wlansniff enable=false >/dev/null
wlanctl-ng $iface lnxreq_ifstate ifstate=disable >/dev/null
echo -n " (monitor mode disabled)"
fi
if [ "`basename $0`" = "kismetautoconf" ] # && [ x$2 = x$iface ]
then
# We will assume the driver is recent until I put in a check, note the _avs header
echo "source=wlanng_avs,$iface,Prism2" >>$KISMET
echo -n " (added to kismet.conf)"
fi
echo
continue
fi
if [ x"`iwpriv $iface 2>/dev/null | grep bbp`" != "x" ]
then
echo -e -n "$iface\t\tRalink b/g\trt2500"
if [ "`basename $1`" = "monitor" ] # && [ x$2 = x$iface ]
then
iwconfig $iface mode ad-hoc 2> /dev/null >/dev/null
startStdIface $iface $CH
fi
if [ "`basename $0`" = "unmonitor" ] # && [ x$2 = x$iface ]
then
stopStdIface $iface
fi
if [ "`basename $1`" = "kismetautoconf" ] # && [ x$2 = x$iface ]
then
echo "source=rt2500,$iface,Ralink_g" >>$KISMET
echo -n " (added to kismet.conf)"
fi
echo
continue
fi
if [ x"`iwpriv $iface 2>/dev/null | grep wpapsk`" != "x" ]
then
echo -e -n "$iface\t\tRalink USB\trt2570"
if [ "`basename $0`" = "monitor" ] # && [ x$2 = x$iface ]
then
iwconfig $iface mode ad-hoc 2> /dev/null >/dev/null
startStdIface $iface $CH
# iwpriv $iface forceprismheader 1 #check this out
fi
if [ "`basename $0`" = "unmonitor" ] # && [ x$2 = x$iface ]
then
stopStdIface $iface
fi
if [ "`basename $0`" = "kismetautoconf" ] # && [ x$2 = x$iface ]
then
echo "source=rt2500,$iface,Ralink_g" >>$KISMET
echo -n " (added to kismet.conf)"
fi
echo
continue
fi
if [ x"`iwpriv $iface 2>/dev/null | grep airo`" != "x" ]
then
echo -e -n "$iface\t\tCisco Aironet\taironet"
if [ -e /proc/driver/aironet/$iface/Config ]
then #ethX
ciscoeth=$iface
if [ "`basename $0`" = "monitor" ] # && [ x$2 = x$iface ]
then
startStdIface $iface $CH
ifconfig $iface 0.0.0.0
ifconfig $iface promisc
iwconfig $iface essid ""
echo "Mode: r" > /proc/driver/aironet/$iface/Config
echo "Mode: y" > /proc/driver/aironet/$iface/Config
echo "XmitPower: 1" > /proc/driver/aironet/$iface/Config
echo -n " (don't use)"
fi
if [ "`basename $0`" = "unmonitor" ]
then
stopStdIface $iface
echo -n " (reset your card)"
fi
else #wifiX
ciscowifix=$iface
if [ "`basename $0`" = "monitor" ]
then
ifconfig $iface up
ifconfig $iface 0.0.0.0
ifconfig $iface promisc
iwconfig $iface essid ""
echo -n " (monitor mode enabled) (sniff here)"
fi
if [ "`basename $0`" = "unmonitor" ]
then
echo -n " (monitor mode disabled) (reset your card)"
fi
fi
if [ "`basename $0`" = "kismetautoconf" ] && [ x$ciscoeth != "x" ] && [ x$ciscowifix != "x" ]
then
echo "source=cisco_wifix,$ciscoeth:$ciscowifix,cisco" >>$KISMET
echo
echo -e -n "$ciscoeth:$ciscowifix\tCisco Aironet\taironet"
echo -n " (added to kismet.conf)"
fi
echo
continue
fi
if [ x"`iwpriv $iface 2>/dev/null | grep debugtx`" != "x" ]
then
echo -e -n "$iface\t\tRTL8180\t\tr8180"
if [ "`basename $0`" = "monitor" ] # && [ x$2 = x$iface ]
then
iwconfig $iface mode Monitor channel $CH
iwpriv $iface prismhdr 1 &>/dev/null
ifconfig $iface up
echo -n " (monitor mode enabled)"
fi
if [ "`basename $0`" = "unmonitor" ] # && [ x$2 = x$iface ]
then
stopStdIface $iface
fi
if [ "`basename $0`" = "kismetautoconf" ] # && [ x$2 = x$iface ]
then
echo "source=rt8180,$iface,Realtek" >>$KISMET
echo -n " (added to kismet.conf)"
fi
echo
continue
fi
if [ x"`iwpriv $iface 2>/dev/null | grep dbg_flag`" != "x" ]
then
echo -e -n "$iface\t\tZyDAS\t\tzd1211"
if [ "`basename $0`" = "monitor" ] # && [ x$2 = x$iface ]
then
startStdIface $iface $CH
fi
if [ "`basename $0`" = "unmonitor" ] # && [ x$2 = x$iface ]
then
stopStdIface $iface
fi
if [ "`basename $0`" = "kismetautoconf" ] # && [ x$2 = x$iface ]
then
# echo "source=wlanng_legacy,$iface,ZyDAS" >>$KISMET # this isn't what kismet docs say...but what do I know?
echo "source=zd1211,$iface,ZyDAS" >>$KISMET
fi
echo
continue
fi
if [ x"`iwpriv $iface 2>/dev/null | grep GetAcx1`" != "x" ]
then
echo -e -n "$iface\t\tTI\t\tacx111"
if [ "`basename $0`" = "monitor" ] # && [ x$2 = x$iface ]
then
startStdIface $iface $CH
fi
if [ "`basename $0`" = "unmonitor" ] # && [ x$2 = x$iface ]
then
stopStdIface $iface
fi
if [ "`basename $0`" = "kismetautoconf" ] # && [ x$2 = x$iface ]
then
echo "source=acx100,$iface,TI" >>$KISMET
fi
echo
continue
fi
if [ x"`iwpriv $iface 2>/dev/null | grep write_sprom`" != "x" ]
then
echo -e -n "$iface\t\tBroadcom\tbcm43xx"
if [ "`basename $0`" = "monitor" ] # && [ x$2 = x$iface ]
then
startStdIface $iface $CH
fi
if [ "`basename $0`" = "unmonitor" ] # && [ x$2 = x$iface ]
then
stopStdIface $iface
fi
if [ "`basename $0`" = "kismetautoconf" ] # && [ x$2 = x$iface ]
then
echo "source=bcm43xx,$iface,broadcom" >>$KISMET
fi
echo
continue
fi
if [ x"`iwpriv $iface 2>/dev/null | grep ndis_reset`" != "x" ]
then
echo -e -n "$iface\t\tUnknown\t\tndiswrapper"
# if [ x$2 = x$iface ]
# then
echo -e " (MONITOR MODE NOT SUPPORTED)"
# fi
echo
continue
fi
echo -e "$iface\t\tUnknown\t\tUnknown (MONITOR MODE NOT SUPPORTED)"
done
#todo: go through kismet docs and fill in the rest of the chipsets we are missing several
#admtek
#atmel_usb
#cisco (legacy)
#ipw2915 (uses the ipw2200 driver but adds .11a support)
#ipwlivetap (detect the rtap interface for ipw2200 and ipw3945 drivers but leave disabled)
#madwifi_a (can we detect if .11a is supported? if so add entry for madwifi_a; madwifi_ag; madwifi_ab disabled)
#madwifi_b (does anyone REALLY want this? what advantage is there to not seeing g?)
#rt2400 (using 1.2.2 beta 2 or newer)
#better detection of different ralink drivers?
#wlanng_legacy (do we really need something this ancient? I doubt it)
#wlanng (even this is likely older than we need)
#wlanng_avs (can we detect the difference between this and non-avs? maybe a version check?)
echo