Skip to content

Commit 2a4de68

Browse files
committed
Merge branch 'nodns-935' into 2.9dev
2 parents c357ea7 + 9f0e442 commit 2a4de68

4 files changed

Lines changed: 30 additions & 17 deletions

File tree

doc/testssl.1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ Please note that the content of \fBfname\fR has to be in Unix format\. DOS carri
149149
\fB\-\-assuming\-http\fR testssl\.sh does upfront an application protocol detection\. In cases where for some reasons the usage of HTTP cannot be automatically detected you may want to use this option\. It tells testssl\.sh not to skip HTTP specific tests and to run the client simulation with browsers\. Sometimes also the severity depends on the application protocol, e\.g\. SHA1 signed certificates, the lack of any SAN matches and some vulnerabilities will be punished harder when checking a web server as opposed to a mail server\.
150150
.
151151
.IP "\(bu" 4
152-
\fB\-n, \-\-no\-dns\fR instructs testssl\.sh to not do any DNS lookups\. This is useful if you either can\'t or are not willing to perform DNS lookups\. The latter applies e\.g\. to some pentests, the former could e\.g\. help you to avoid timeouts by DNS lookups\. \fBNODNS=true\fR has the same effect\.
152+
\fB\-n, \-\-nodns <min|none>\fR tells testssl\.sh which DNS lookups should be performed\. \fBmin\fR uses only forward DNS resolution (A and AAAA record or MX record) and skips CAA lookups and PTR records from the IP address back to a DNS name\. \fBnone\fR performs no DNS lookups at all\. For the latter you either have to supply the IP address as a target, to use \fB\-\-ip`` or have the IP address in /etc/hosts\. The use of the switch is only useful if you either can\'t or are not willing to perform DNS lookups\. The latter can apply e\.g\. to some pentestsi\. In general this option could e\.g\. help you to avoid timeouts by DNS lookups\.\fRNODNS` is the enviroment variable for this\.
153153
.
154154
.IP "\(bu" 4
155155
\fB\-\-sneaky\fR as a friendly feature for the server side testssl\.sh uses a HTTP user agent \fBTLS tester from ${URL}\fR\. With this option your traces are less verbose and a Firefox user agent is being used\. Be aware that it doesn\'t hide your activities\. That is just not possible (environment preset via \fBSNEAKY=true\fR)\.

doc/testssl.1.html

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

doc/testssl.1.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ Please note that the content of `fname` has to be in Unix format. DOS carriage r
120120
`--assuming-http` testssl.sh does upfront an application protocol detection. In cases where for some reasons the usage of HTTP cannot be automatically detected you may want to use this option. It tells testssl.sh not to skip HTTP specific tests and to run the client simulation with browsers. Sometimes also the severity depends on the application protocol, e.g. SHA1 signed certificates, the lack of any SAN matches and some vulnerabilities will be punished harder when checking a web server as opposed to a mail server.
121121

122122

123-
* `-n, --no-dns` instructs testssl.sh to not do any DNS lookups. This is useful if you either can't or are not willing to perform DNS lookups. The latter applies e.g. to some pentests, the former could e.g. help you to avoid timeouts by DNS lookups. `NODNS=true` has the same effect.
123+
* `-n, --nodns <min|none>` tells testssl.sh which DNS lookups should be performed. `min` uses only forward DNS resolution (A and AAAA record or MX record) and skips CAA lookups and PTR records from the IP address back to a DNS name. `none` performs no
124+
DNS lookups at all. For the latter you either have to supply the IP address as a target, to use `--ip`` or have the IP address
125+
in /etc/hosts. The use of the switch is only useful if you either can't or are not willing to perform DNS lookups. The latter can apply e.g. to some pentestsi. In general this option could e.g. help you to avoid timeouts by DNS lookups. `NODNS` is the enviroment variable for this.
124126

125127
* `--sneaky` as a friendly feature for the server side testssl.sh uses a HTTP user agent `TLS tester from ${URL}`. With this option your traces are less verbose and a Firefox user agent is being used. Be aware that it doesn't hide your activities. That is just not possible (environment preset via `SNEAKY=true`).
126128

testssl.sh

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ HTMLFILE="${HTMLFILE:-""}" # HTML if used
207207
FNAME=${FNAME:-""} # file name to read commands from
208208
FNAME_PREFIX=${FNAME_PREFIX:-""} # output filename prefix, see --outprefix
209209
APPEND=${APPEND:-false} # append to csv/json file instead of overwriting it
210-
NODNS=${NODNS:-false} # always do DNS lookups per default. For some pentests it might save time to set this to true
210+
# NODNS=${NODNS:-"no"} # if unset it does all DNS lookups per default. "min" only for hosts or "none" at all
211211
HAS_IPv6=${HAS_IPv6:-false} # if you have OpenSSL with IPv6 support AND IPv6 networking set it to yes
212212
ALL_CLIENTS=${ALL_CLIENTS:-false} # do you want to run all client simulation form all clients supplied by SSLlabs?
213213

@@ -7420,8 +7420,8 @@ certificate_info() {
74207420
all_caa=${all_caa%, } # strip trailing comma
74217421
pr_italic "$(out_row_aligned_max_width "$all_caa" "$indent " $TERM_WIDTH)"
74227422
fileout "${jsonID}${json_postfix}" "OK" "$all_caa"
7423-
elif "$NODNS"; then
7424-
pr_warning "(was instructed to not use DNS)"
7423+
elif [[ -n "$NODNS" ]]; then
7424+
pr_warning "(instructed to minimize DNS queries)"
74257425
fileout "${jsonID}${json_postfix}" "WARN" "check skipped as instructed"
74267426
else
74277427
pr_svrty_low "not offered"
@@ -14945,7 +14945,7 @@ tuning / connect options (most also can be preset via environment variables):
1494514945
-6 also use IPv6. Works only with supporting OpenSSL version and IPv6 connectivity
1494614946
--ip <ip> a) tests the supplied <ip> v4 or v6 address instead of resolving host(s) in URI
1494714947
b) arg "one" means: just test the first DNS returns (useful for multiple IPs)
14948-
-n, --nodns do not try any DNS lookup
14948+
-n, --nodns [min|none] if "none": do not try any DNS lookups, "min" queries A, AAAA and MX records
1494914949
--sneaky leave less traces in target logs: user agent, referer
1495014950

1495114951
output options (can also be preset via environment variables):
@@ -15450,7 +15450,7 @@ get_a_record() {
1545015450
local ip4=""
1545115451
local saved_openssl_conf="$OPENSSL_CONF"
1545215452

15453-
"$NODNS" && return 0 # if no DNS lookup was instructed, leave here
15453+
[[ "$NODNS" == none ]] && return 0 # if no DNS lookup was instructed, leave here
1545415454
OPENSSL_CONF="" # see https://github.com/drwetter/testssl.sh/issues/134
1545515455
check_resolver_bins
1545615456
if [[ "$NODE" == *.local ]]; then
@@ -15490,7 +15490,7 @@ get_aaaa_record() {
1549015490
local ip6=""
1549115491
local saved_openssl_conf="$OPENSSL_CONF"
1549215492

15493-
"$NODNS" && return 0 # if no DNS lookup was instructed, leave here
15493+
[[ "$NODNS" == none ]] && return 0 # if no DNS lookup was instructed, leave here
1549415494
OPENSSL_CONF="" # see https://github.com/drwetter/testssl.sh/issues/134
1549515495
check_resolver_bins
1549615496
if [[ -z "$ip6" ]]; then
@@ -15527,7 +15527,7 @@ get_caa_rr_record() {
1552715527
local saved_openssl_conf="$OPENSSL_CONF"
1552815528
local all_caa=""
1552915529

15530-
"$NODNS" && return 0 # if no DNS lookup was instructed, leave here
15530+
[[ -n "$NODNS" ]] && return 0 # if minimum DNS lookup was instructed, leave here
1553115531
# if there's a type257 record there are two output formats here, mostly depending on age of distribution
1553215532
# roughly that's the difference between text and binary format
1553315533
# 1) 'google.com has CAA record 0 issue "symantec.com"'
@@ -15689,9 +15689,10 @@ determine_ip_addresses() {
1568915689

1569015690
determine_rdns() {
1569115691
local saved_openssl_conf="$OPENSSL_CONF"
15692-
local nodeip="$(tr -d '[]' <<< $NODEIP)" # for DNS we do not need the square brackets of IPv6 addresses
15692+
local nodeip=""
1569315693

15694-
"$NODNS" && rDNS="--" && return 0
15694+
[[ -n "$NODNS" ]] && rDNS="(instructed to minimize DNS queries)" && return 0 # PTR records were not asked for
15695+
local nodeip="$(tr -d '[]' <<< $NODEIP)" # for DNS we do not need the square brackets of IPv6 addresses
1569515696
OPENSSL_CONF="" # see https://github.com/drwetter/testssl.sh/issues/134
1569615697
check_resolver_bins
1569715698
if [[ "$NODE" == *.local ]]; then
@@ -15974,7 +15975,7 @@ display_rdns_etc() {
1597415975
outln "$PROXYIP:$PROXYPORT "
1597515976
fi
1597615977
if [[ $(count_words "$IP46ADDRs") -gt 1 ]]; then
15977-
out " further IP addresses: $CORRECT_SPACES"
15978+
out " Further IP addresses: $CORRECT_SPACES"
1597815979
for ip in $IP46ADDRs; do
1597915980
if [[ "$ip" == "$NODEIP" ]] || [[ "[$ip]" == "$NODEIP" ]]; then
1598015981
continue
@@ -15989,7 +15990,10 @@ display_rdns_etc() {
1598915990
elif [[ -n "$CMDLINE_IP" ]]; then
1599015991
outln " A record via $CORRECT_SPACES supplied IP \"$CMDLINE_IP\""
1599115992
fi
15992-
if [[ -n "$rDNS" ]]; then
15993+
if [[ "$rDNS" =~ instructed ]]; then
15994+
out "$(printf " %-23s %s" "rDNS ($nodeip):")"
15995+
pr_warning "$rDNS"
15996+
elif [[ -n "$rDNS" ]]; then
1599315997
out "$(printf " %-23s %s" "rDNS ($nodeip):")"
1599415998
out "$(out_row_aligned_max_width "$rDNS" " $CORRECT_SPACES" $TERM_WIDTH)"
1599515999
fi
@@ -16662,7 +16666,11 @@ parse_cmd_line() {
1666216666
fi
1666316667
;;
1666416668
-n|--nodns)
16665-
NODNS=true
16669+
NODNS="$(parse_opt_equal_sign "$1" "$2")"
16670+
[[ $? -eq 0 ]] && shift
16671+
if [[ "$NODNS" != none ]] && [[ "$NODNS" != min ]]; then
16672+
fatal "Value for nodns switch can be either \"min\" or \"none\""
16673+
fi
1666616674
;;
1666716675
-V|-V=*|--local|--local=*) # attention, this could have a value or not!
1666816676
do_display_only=true
@@ -17046,15 +17054,16 @@ parse_cmd_line() {
1704617054
done
1704717055

1704817056
# Show usage if no further options were specified
17049-
if [[ -z "$1" ]] && [[ -z "$FNAME" ]] && ! $do_display_only; then
17057+
if [[ -z "$1" ]] && [[ -z "$FNAME" ]] && ! "$do_display_only"; then
1705017058
fatal "URI missing" "1"
1705117059
else
1705217060
# left off here is the URI
1705317061
URI="$1"
1705417062
# parameter after URI supplied:
1705517063
[[ -n "$2" ]] && fatal "URI comes last" "1"
1705617064
fi
17057-
[[ $CMDLINE_IP == "one" ]] && "$NODNS" && fatal "\"--ip=one\" and \"--nodns\" doesn't work together"
17065+
[[ $CMDLINE_IP == one ]] && [[ "$NODNS" == none ]] && fatal "\"--ip=one\" and \"--nodns=none\" don't work together" 2
17066+
"$do_mx_all_ips" && [[ "$NODNS" == none ]] && fatal "\"--mx\" and \"--nodns=none\" don't work together" 2
1705817067
ADDITIONAL_CA_FILES="${ADDITIONAL_CA_FILES//,/ }"
1705917068
for fname in $ADDITIONAL_CA_FILES; do
1706017069
[[ -s "$fname" ]] || fatal "CA file \"$fname\" does not exist" -2

0 commit comments

Comments
 (0)