Skip to content

Commit 0af73c2

Browse files
author
Kali
committed
fixed DNS via Proxy
1 parent 7670275 commit 0af73c2

1 file changed

Lines changed: 36 additions & 26 deletions

File tree

testssl.sh

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ TESTSSL_INSTALL_DIR="${TESTSSL_INSTALL_DIR:-""}" # If you run testssl.sh and it
196196
CA_BUNDLES_PATH="${CA_BUNDLES_PATH:-""}" # You can have your CA stores some place else
197197
EXPERIMENTAL=${EXPERIMENTAL:-false} # a development hook which allows us to disable code
198198
PROXY_WAIT=${PROXY_WAIT:-20} # waiting at max 20 seconds for socket reply through proxy
199-
DNS_VIA_PROXY=${DNS_VIA_PROXY:-true} # do DNS lookups via proxy. --ip=proxy reverses this
199+
DNS_VIA_PROXY=${DNS_VIA_PROXY:-false} # do DNS lookups via proxy. --ip=proxy reverses this
200200
IGN_OCSP_PROXY=${IGN_OCSP_PROXY:-false} # Also when --proxy is supplied it is ignored when testing for revocation via OCSP via --phone-out
201201
HEADER_MAXSLEEP=${HEADER_MAXSLEEP:-5} # we wait this long before killing the process to retrieve a service banner / http header
202202
MAX_SOCKET_FAIL=${MAX_SOCKET_FAIL:-2} # If this many failures for TCP socket connects are reached we terminate
@@ -22014,12 +22014,19 @@ display_rdns_etc() {
2201422014

2201522015
datebanner() {
2201622016
local scan_time_f=""
22017-
22017+
local node_banner=""
22018+
22019+
if [[ -n "PROXY" ]] && $DNS_VIA_PROXY;then
22020+
node_banner="$NODE:$PORT"
22021+
else
22022+
node_banner="$NODEIP:$PORT ($NODE)"
22023+
fi
22024+
2201822025
if [[ "$1" =~ Done ]] ; then
2201922026
scan_time_f="$(printf "%04ss" "$SCAN_TIME")" # 4 digits because of windows
22020-
pr_reverse "$1 $(date +%F) $(date +%T) [$scan_time_f] -->> $NODEIP:$PORT ($NODE) <<--"
22027+
pr_reverse "$1 $(date +%F) $(date +%T) [$scan_time_f] -->> $node_banner <<--"
2202122028
else
22022-
pr_reverse "$1 $(date +%F) $(date +%T) -->> $NODEIP:$PORT ($NODE) <<--"
22029+
pr_reverse "$1 $(date +%F) $(date +%T) -->> $node_banner <<--"
2202322030
fi
2202422031
outln "\n"
2202522032
[[ "$1" =~ Start ]] && display_rdns_etc
@@ -23735,7 +23742,6 @@ lets_roll() {
2373523742
fi
2373623743
stopwatch initialized
2373723744

23738-
[[ -z "$NODEIP" ]] && fatal "$NODE doesn't resolve to an IP address" $ERR_DNSLOOKUP
2373923745
nodeip_to_proper_ip6
2374023746
reset_hostdepended_vars
2374123747
determine_rdns # Returns always zero or has already exited if fatal error occurred
@@ -23938,26 +23944,30 @@ lets_roll() {
2393823944
[[ -z "$NODE" ]] && parse_hn_port "${URI}" # NODE, URL_PATH, PORT, IPADDRs and IP46ADDR is set now
2393923945
prepare_logging
2394023946

23941-
if ! determine_ip_addresses; then
23942-
fatal "No IP address could be determined" $ERR_DNSLOOKUP
23943-
fi
23944-
if [[ $(count_words "$IPADDRs") -gt 1 ]]; then # we have more than one ipv4 address to check
23945-
MULTIPLE_CHECKS=true
23946-
pr_bold "Testing all IPv4 addresses (port $PORT): "; outln "$IPADDRs"
23947-
for ip in $IPADDRs; do
23948-
draw_line "-" $((TERM_WIDTH * 2 / 3))
23949-
outln
23950-
NODEIP="$ip"
23951-
lets_roll "${STARTTLS_PROTOCOL}"
23952-
RET=$((RET + $?)) # RET value per IP address
23953-
done
23954-
draw_line "-" $((TERM_WIDTH * 2 / 3))
23955-
outln
23956-
pr_bold "Done testing now all IP addresses (on port $PORT): "; outln "$IPADDRs"
23957-
else # Just 1x ip4v to check, applies also if CMDLINE_IP was supplied
23958-
NODEIP="$IPADDRs"
23959-
lets_roll "${STARTTLS_PROTOCOL}"
23960-
RET=$?
23961-
fi
23947+
if [[ -n "$PROXY" ]] && $DNS_VIA_PROXY; then
23948+
NODEIP="$NODE"
23949+
lets_roll "${STARTTLS_PROTOCOL}"
23950+
RET=$?
23951+
else
23952+
determine_ip_addresses
23953+
if [[ $(count_words "$IPADDRs") -gt 1 ]]; then # we have more than one ipv4 address to check
23954+
MULTIPLE_CHECKS=true
23955+
pr_bold "Testing all IPv4 addresses (port $PORT): "; outln "$IPADDRs"
23956+
for ip in $IPADDRs; do
23957+
draw_line "-" $((TERM_WIDTH * 2 / 3))
23958+
outln
23959+
NODEIP="$ip"
23960+
lets_roll "${STARTTLS_PROTOCOL}"
23961+
RET=$((RET + $?)) # RET value per IP address
23962+
done
23963+
draw_line "-" $((TERM_WIDTH * 2 / 3))
23964+
outln
23965+
pr_bold "Done testing now all IP addresses (on port $PORT): "; outln "$IPADDRs"
23966+
else # Just 1x ip4v to check, applies also if CMDLINE_IP was supplied
23967+
NODEIP="$IPADDRs"
23968+
lets_roll "${STARTTLS_PROTOCOL}"
23969+
RET=$?
23970+
fi
23971+
fi
2396223972

2396323973
exit $RET

0 commit comments

Comments
 (0)