mirror of
https://github.com/drwetter/testssl.sh.git
synced 2025-01-03 23:39:45 +01:00
- finalize mx records, FIX: #41
This commit is contained in:
parent
2614c093d7
commit
55e8908234
27
testssl.sh
27
testssl.sh
@ -2395,6 +2395,7 @@ $PRG <options> URI
|
|||||||
<-H|--header|--headers> check for HSTS, HPKP and server/application banner string
|
<-H|--header|--headers> check for HSTS, HPKP and server/application banner string
|
||||||
|
|
||||||
<-t|--starttls> protocol does a default run against a STARTTLS enabled service
|
<-t|--starttls> protocol does a default run against a STARTTLS enabled service
|
||||||
|
<--mx> tests MX records from high to low priority (STARTTLS, port 25)
|
||||||
|
|
||||||
|
|
||||||
partly mandatory parameters:
|
partly mandatory parameters:
|
||||||
@ -2589,7 +2590,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 ] && return 3
|
[ $? -ne 0 ] && exit 3
|
||||||
fi
|
fi
|
||||||
close_socket
|
close_socket
|
||||||
|
|
||||||
@ -2606,11 +2607,12 @@ parse_hn_port() {
|
|||||||
datebanner "Testing"
|
datebanner "Testing"
|
||||||
[[ -z "$2" ]] && runs_HTTP # for starttls we don't check the protocol as it is supplied on the cmd line
|
[[ -z "$2" ]] && runs_HTTP # for starttls we don't check the protocol as it is supplied on the cmd line
|
||||||
initialize_engine
|
initialize_engine
|
||||||
|
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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
|
||||||
@ -2694,27 +2696,26 @@ datebanner() {
|
|||||||
|
|
||||||
|
|
||||||
mx_allentries() {
|
mx_allentries() {
|
||||||
|
|
||||||
HOST=$1
|
|
||||||
if which dig &> /dev/null; then
|
if which dig &> /dev/null; then
|
||||||
MXs=$(dig +short -t MX $HOST | grep '\d ')
|
MXs=$(dig +short -t MX $1)
|
||||||
elif which host &> /dev/null; then
|
elif which host &> /dev/null; then
|
||||||
MXs=$(host -t MX $HOST | grep 'handled by' | sed -e 's/^.*by //' -e 's/\.$//')
|
MXs=$(host -t MX $1 | grep 'handled by' | sed -e 's/^.*by //' -e 's/\.$//')
|
||||||
elif which nslookup &> /dev/null; then
|
elif which nslookup &> /dev/null; then
|
||||||
MXs=$(nslookup -type=MX $HOST 2> /dev/null | grep 'mail exchanger = ' | awk '$5 ~ /[0-9]+/ {print $5 " " $NF}')
|
MXs=$(nslookup -type=MX $1 2> /dev/null | grep 'mail exchanger = ' | sed 's/^.*mail exchanger = //g')
|
||||||
else
|
else
|
||||||
pr_redln 'No dig, host or nslookup'
|
pr_magentaln 'No dig, host or nslookup'
|
||||||
exit -1
|
exit 3
|
||||||
fi
|
fi
|
||||||
|
|
||||||
MXs=$(echo "$MXs" | sort -n | sed -e 's/^.* //' -e 's/\.$//')
|
# test first higher priority servers
|
||||||
|
MXs=$(echo "$MXs" | sort -nr | sed -e 's/^.* //' -e 's/\.$//')
|
||||||
|
|
||||||
if [ -n "$MXs" ] ; then
|
if [ -n "$MXs" ] ; then
|
||||||
for MX in $MXs; do
|
for MX in $MXs; do
|
||||||
parse_hn_port "$MX:25" 'smtp' && starttls 'smtp'
|
parse_hn_port "$MX:25" 'smtp' && starttls 'smtp'
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
pr_magentaln "$HOST has no Mail Server(s)"
|
pr_boldln "$1 has no mail server(s)"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2748,7 +2749,7 @@ case "$1" in
|
|||||||
-b|--banner|-banner|-v|--version|-version)
|
-b|--banner|-banner|-v|--version|-version)
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
--mx)
|
--mx)
|
||||||
mx_allentries $2
|
mx_allentries $2
|
||||||
exit $?
|
exit $?
|
||||||
;;
|
;;
|
||||||
@ -2916,6 +2917,6 @@ case "$1" in
|
|||||||
exit $ret ;;
|
exit $ret ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# $Id: testssl.sh,v 1.196 2015/02/27 20:21:37 dirkw Exp $
|
# $Id: testssl.sh,v 1.197 2015/03/02 13:42:18 dirkw Exp $
|
||||||
# vim:ts=5:sw=5
|
# vim:ts=5:sw=5
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user