mirror of
				https://github.com/drwetter/testssl.sh.git
				synced 2025-11-04 07:45:27 +01:00 
			
		
		
		
	Check MX Records (#41)
This commit is contained in:
		
							
								
								
									
										33
									
								
								testssl.sh
									
									
									
									
									
								
							
							
						
						
									
										33
									
								
								testssl.sh
									
									
									
									
									
								
							@@ -2588,7 +2588,7 @@ parse_hn_port() {
 | 
				
			|||||||
	# check if we can connect to port 
 | 
						# check if we can connect to port 
 | 
				
			||||||
	if ! fd_socket; then
 | 
						if ! fd_socket; then
 | 
				
			||||||
		ignore_no_or_lame "Ignore? "
 | 
							ignore_no_or_lame "Ignore? "
 | 
				
			||||||
		[ $? -ne 0 ] && exit 3
 | 
							[ $? -ne 0 ] && return 3
 | 
				
			||||||
	fi
 | 
						fi
 | 
				
			||||||
	close_socket
 | 
						close_socket
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -2609,6 +2609,7 @@ parse_hn_port() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
get_dns_entries() {
 | 
					get_dns_entries() {
 | 
				
			||||||
 | 
						IP4=''; IP6=''
 | 
				
			||||||
	test4iponly=`printf $NODE | sed -e 's/[0-9]//g' -e 's/\.//g'`
 | 
						test4iponly=`printf $NODE | sed -e 's/[0-9]//g' -e 's/\.//g'`
 | 
				
			||||||
	if [ "x$test4iponly" == "x" ]; then  # only an IPv4 address was supplied
 | 
						if [ "x$test4iponly" == "x" ]; then  # only an IPv4 address was supplied
 | 
				
			||||||
		IP4=$NODE
 | 
							IP4=$NODE
 | 
				
			||||||
@@ -2691,6 +2692,32 @@ datebanner() {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					mx_allentries() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						HOST=$1
 | 
				
			||||||
 | 
						if which dig &> /dev/null; then
 | 
				
			||||||
 | 
							MXs=$(dig +short -t MX $HOST | grep '\d ')
 | 
				
			||||||
 | 
						elif which host &> /dev/null; then
 | 
				
			||||||
 | 
							MXs=$(host -t MX $HOST | grep 'handled by' | sed -e 's/^.*by //' -e 's/\.$//')
 | 
				
			||||||
 | 
						elif which nslookup &> /dev/null; then
 | 
				
			||||||
 | 
							MXs=$(nslookup -type=MX $HOST 2> /dev/null | grep 'mail exchanger = ' | awk '$5 ~ /[0-9]+/ {print $5 " " $NF}')
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
							pr_redln 'No dig, host or nslookup'
 | 
				
			||||||
 | 
							exit -1
 | 
				
			||||||
 | 
						fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						MXs=$(echo "$MXs" | sort -n | sed -e 's/^.* //' -e 's/\.$//')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if [ -n "$MXs" ] ; then
 | 
				
			||||||
 | 
							for MX in $MXs; do
 | 
				
			||||||
 | 
								parse_hn_port "$MX:25" 'smtp' && starttls 'smtp'
 | 
				
			||||||
 | 
							done
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
							pr_magentaln "$HOST has no Mail Server(s)"
 | 
				
			||||||
 | 
						fi
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
################# main: #################
 | 
					################# main: #################
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -2720,6 +2747,10 @@ case "$1" in
 | 
				
			|||||||
     -b|--banner|-banner|-v|--version|-version)
 | 
					     -b|--banner|-banner|-v|--version|-version)
 | 
				
			||||||
		exit 0 
 | 
							exit 0 
 | 
				
			||||||
		;;
 | 
							;;
 | 
				
			||||||
 | 
						--mx)
 | 
				
			||||||
 | 
							mx_allentries $2
 | 
				
			||||||
 | 
							exit $?
 | 
				
			||||||
 | 
							;;
 | 
				
			||||||
	-V|--local)
 | 
						-V|--local)
 | 
				
			||||||
		initialize_engine 	# GOST support
 | 
							initialize_engine 	# GOST support
 | 
				
			||||||
		prettyprint_local "$2"
 | 
							prettyprint_local "$2"
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user