<commit_before>#!/usr/bin/env bash
# DTP Scan
# <NAME>
# www.commonexploits.com
# <EMAIL>
# Twitter = @commonexploits
# 13/10/2013
# Requires tshark
# Tested on Bactrack 5 and Kali with Cisco devices
# Version 1.0 - soon will be integrated into Froger version 2.


DTPSEC="90" # number of seconds to sniff for DTP. Suggest 90 as packets are sent every 30-60 seconds depending on the DTP mode.
VERSION="1.0"

clear
echo -e "\e[00;32m########################################################\e[00m"
echo "***   DTPScan - The VLAN DTP SCanner $VERSION  ***"
echo ""
echo "***   Detects DTP modes for VLAN Hopping ***"
echo -e "\e[00;32m########################################################\e[00m"

#Check for tshark
which tshark >/dev/null
if [ $? -eq 1 ]
	then
		echo -e "\e[01;31m[!]\e[00m Unable to find the required tshark program, install and try again."
		echo ""
		exit 1
fi



echo ""
echo -e "\e[01;32m[-]\e[00m The following Interfaces are available"
echo ""
ifconfig | grep -o "eth.*" |cut -d " " -f1
echo ""
echo -e "\e[1;31m----------------------------------------------------------\e[00m"
echo -e "\e[01;31m[?]\e[00m Enter the interface to scan from as the source"
echo -e "\e[1;31m----------------------------------------------------------\e[00m"
read INT
ifconfig | grep -i -w "$INT" >/dev/null

if [ $? = 1 ]
	then
		echo ""
		echo -e "\e[01;31m[!]\e[00m Sorry the interface you entered does not exist! - check and try again."
		echo ""
		exit 1
fi


echo ""
echo -e "\e[01;32m[-]\e[00m Now Sniffing DTP packets on interface $INT for "$DTPSEC" seconds."
echo ""

tshark -a duration:$DTPSEC -i $INT -R "dtp" -x -V >dtp.tmp 2>&1

cat dtp.tmp |grep "0 packets captured" >/dev/null

if [ $? = 0 ]

	then
			echo ""
			echo -e "\e[01;31m[!]\e[00m I didn't find any DTP packets. DTP is probably in 'switchport mode access' or 'switchport nonegotiate' modes."
			echo ""
			echo -e "\e[01;31m[!]\e[00m DTP VLAN attacks will not be possible."
			echo ""
			rm dtp.tmp 2>/dev/null
			exit 0
fi


DTPMODE=$(cat dtp.tmp |grep -o "Status: 0x.*" |awk '{ print $NF }' | sort --unique |head -1)
	if [ $DTPMODE = "0x03" ]
		then
			echo ""
			echo -e "\e[01;32m[+]\e[00m DTP was found enabled in it's default state of 'Auto'."
			echo ""
			echo -e "\e[01;32m[+]\e[00m VLAN hopping will be possible."
			echo ""

	elif [ $DTPMODE = "0x83" ]
		then
			echo ""
			echo -e "\e[01;32m[+]\e[00m DTP was found enabled in mode 'switchport mode dynamic desirable'."
			echo ""
			echo -e "\e[01;32m[+]\e[00m VLAN hopping should be possible."
			echo ""

	elif [ $DTPMODE = "0x04" ]
		then
			echo ""
			echo -e "\e[01;32m[+]\e[00m DTP was found enabled in mode 'switchport mode dynamic desirable'."
			echo ""
			echo -e "\e[01;32m[+]\e[00m VLAN hopping should be possible."
			echo ""

	elif [ $DTPMODE = "0x81" ]
		then
			echo ""
			echo -e "\e[01;32m[+]\e[00m DTP was found enabled in Trunk mode 'switchport mode trunk'."
			echo ""
			echo -e "\e[01;31m[!]\e[00m DTP VLAN attacks will not be possible."
			echo ""
	elif [ $DTPMODE = "0xa5" ]
		then
			echo ""
			echo -e "\e[01;32m[+]\e[00m DTP was found enabled in Trunk mode 'switchport mode trunk 802.1Q'. with 802.1Q encapsulation forced"
			echo ""
			echo -e "\e[01;31m[!]\e[00m DTP VLAN attacks will not be possible."
			echo ""

	elif [ $DTPMODE = "0x42" ]
		then
			echo ""
			echo -e "\e[01;32m[+]\e[00m DTP was found enabled in Trunk mode 'switchport mode trunk ISL'. with ISL encapsulation forced"
			echo ""
			echo -e "\e[01;31m[!]\e[00m DTP VLAN attacks will not be possible."
			echo ""

	elif [ $DTPMODE = "0x84" ]
		then
			echo ""
			echo -e "\e[01;32m[+]\e[00m DTP was found enabled in mode 'switchport mode dynamic auto'."
			echo ""
			echo -e "\e[01;32m[+]\e[00m VLAN hopping should be possible."
			echo ""

	elif [ $DTPMODE = "0x02" ]
		then
			echo ""
			echo -e "\e[01;32m[+]\e[00m DTP was found enabled in mode 'switchport mode access'."
			echo ""
			echo -e "\e[01;31m[!]\e[00m DTP VLAN attacks will not be possible."

	fi

rm dtp.tmp 2>/dev/null
exit 0<commit_msg>Version 1<commit_after>#!/usr/bin/env bash
# DTP Scan
# <NAME>
# www.commonexploits.com
# <EMAIL>
# Twitter = @commonexploits
# 13/10/2013
# Requires tshark
# Tested on Bactrack 5 and Kali with Cisco devices
# Version 1.0 - soon will be integrated into Froger version 2.


DTPSEC="90" # number of seconds to sniff for DTP. Suggest 90 as packets are sent every 30-60 seconds depending on the DTP mode.
VERSION="1.0"

clear
echo -e "\e[00;32m########################################################\e[00m"
echo "***   DTPScan - The VLAN DTP SCanner $VERSION  ***"
echo ""
echo "***   Detects DTP modes for VLAN Hopping (Passive) ***"
echo -e "\e[00;32m########################################################\e[00m"

#Check for tshark
which tshark >/dev/null
if [ $? -eq 1 ]
	then
		echo -e "\e[01;31m[!]\e[00m Unable to find the required tshark program, install and try again."
		echo ""
		exit 1
fi



echo ""
echo -e "\e[01;32m[-]\e[00m The following Interfaces are available"
echo ""
ifconfig | grep -o "eth.*" |cut -d " " -f1
echo ""
echo -e "\e[1;31m----------------------------------------------------------\e[00m"
echo -e "\e[01;31m[?]\e[00m Enter the interface to scan from as the source"
echo -e "\e[1;31m----------------------------------------------------------\e[00m"
read INT
ifconfig | grep -i -w "$INT" >/dev/null

if [ $? = 1 ]
	then
		echo ""
		echo -e "\e[01;31m[!]\e[00m Sorry the interface you entered does not exist! - check and try again."
		echo ""
		exit 1
fi


echo ""
echo -e "\e[01;32m[-]\e[00m Now Sniffing DTP packets on interface $INT for "$DTPSEC" seconds."
echo ""

tshark -a duration:$DTPSEC -i $INT -R "dtp" -x -V >dtp.tmp 2>&1

cat dtp.tmp |grep "0 packets captured" >/dev/null

if [ $? = 0 ]

	then
			echo ""
			echo -e "\e[01;31m[!]\e[00m I didn't find any DTP packets. DTP is probably in 'switchport mode access' or 'switchport nonegotiate' modes."
			echo ""
			echo -e "\e[01;31m[!]\e[00m DTP VLAN attacks will not be possible."
			echo ""
			rm dtp.tmp 2>/dev/null
			exit 0
fi


DTPMODE=$(cat dtp.tmp |grep -o "Status: 0x.*" |awk '{ print $NF }' | sort --unique |head -1)
	if [ $DTPMODE = "0x03" ]
		then
			echo ""
			echo -e "\e[01;32m[+]\e[00m DTP was found enabled in it's default state of 'Auto'."
			echo ""
			echo -e "\e[01;32m[+]\e[00m VLAN hopping will be possible."
			echo ""

	elif [ $DTPMODE = "0x83" ]
		then
			echo ""
			echo -e "\e[01;32m[+]\e[00m DTP was found enabled in mode 'switchport mode dynamic desirable'."
			echo ""
			echo -e "\e[01;32m[+]\e[00m VLAN hopping should be possible."
			echo ""

	elif [ $DTPMODE = "0x04" ]
		then
			echo ""
			echo -e "\e[01;32m[+]\e[00m DTP was found enabled in mode 'switchport mode dynamic desirable'."
			echo ""
			echo -e "\e[01;32m[+]\e[00m VLAN hopping should be possible."
			echo ""

	elif [ $DTPMODE = "0x81" ]
		then
			echo ""
			echo -e "\e[01;32m[+]\e[00m DTP was found enabled in Trunk mode 'switchport mode trunk'."
			echo ""
			echo -e "\e[01;31m[!]\e[00m DTP VLAN attacks will not be possible."
			echo ""
	elif [ $DTPMODE = "0xa5" ]
		then
			echo ""
			echo -e "\e[01;32m[+]\e[00m DTP was found enabled in Trunk mode 'switchport mode trunk 802.1Q'. with 802.1Q encapsulation forced"
			echo ""
			echo -e "\e[01;31m[!]\e[00m DTP VLAN attacks will not be possible."
			echo ""

	elif [ $DTPMODE = "0x42" ]
		then
			echo ""
			echo -e "\e[01;32m[+]\e[00m DTP was found enabled in Trunk mode 'switchport mode trunk ISL'. with ISL encapsulation forced"
			echo ""
			echo -e "\e[01;31m[!]\e[00m DTP VLAN attacks will not be possible."
			echo ""

	elif [ $DTPMODE = "0x84" ]
		then
			echo ""
			echo -e "\e[01;32m[+]\e[00m DTP was found enabled in mode 'switchport mode dynamic auto'."
			echo ""
			echo -e "\e[01;32m[+]\e[00m VLAN hopping should be possible."
			echo ""

	elif [ $DTPMODE = "0x02" ]
		then
			echo ""
			echo -e "\e[01;32m[+]\e[00m DTP was found enabled in mode 'switchport mode access'."
			echo ""
			echo -e "\e[01;31m[!]\e[00m DTP VLAN attacks will not be possible."
			echo ""
	fi

rm dtp.tmp 2>/dev/null
exit 0
{'fraction_non_alphanumeric': 0.20641975308641974, 'fraction_numerical': 0.056419753086419756, 'mean_word_length': 2.7418013856812933, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5640502', 'n_tokens_mistral': 3574, 'n_tokens_neox': 3045, 'n_words': 1012}