Commit Graph

2675 Commits

Author SHA1 Message Date
Dirk Wetter
94ef475255
Merge pull request #2461 from akabe1/3.2
Add mTLS new feature to support scans with client authentication
2024-02-27 15:47:03 +01:00
Dirk Wetter
f84e8c05f5
Merge pull request #2470 from Tazmaniac/renego_timing_fix
Correct client_renego timing bug.
2024-02-21 17:17:51 +01:00
Emmanuel Fusté
af20952b86 Fix subshell killing to avoid zombies
Learned from the rest of the code ...
2024-02-19 16:19:23 +01:00
Emmanuel Fusté
6277613906 Usual spell fixes. 2024-02-13 15:41:35 +01:00
Emmanuel Fusté
4066766de5 MongoDB identification fix
The actual code grep for "MongoDB" keyword in the head of the HTTP
session.
In case of "compressed" HTML, a big page is on one line.
On a IT page, we could encounter the "MongoDB" keyword and
miss-identify the application protocol.

Fixed by matching on a longuer string taken from a live MogoDB
server.
2024-02-13 15:00:19 +01:00
Emmanuel Fusté
faae91edbc Correct client_renego timing bug.
OpenSSL will buffer only the first command till the establishment of the
session.
In case of slow session establishment, we could:
  * loose some renego trys missing proper mitigation implementation
  * loose some renego trys missing a real vulnerable host if 2/3 of the
    tries are lost during session establishment (very slow startup).

Wait for the session to be fully establised before starting the renego
loop.
2024-02-13 14:40:53 +01:00
Odinmylord
eb661dadb8 Add SNI to ticketbleed check 2024-02-08 15:01:12 +01:00
Maurizio S
ec4ceb2c20
Add mTLS feature
Added new feature to support mutual TLS via client certificate and private key, when a remote server requires client authentication.
2024-01-20 11:49:05 +01:00
Emmanuel Fusté
4cc02a63ef One more spell fix... 2024-01-19 17:09:44 +01:00
Emmanuel Fusté
02a3c2cc14 Fixed regression in printing results
And improve it with the effective number of renego before disconnection
as it is now tracked.
2024-01-19 16:22:50 +01:00
Dirk Wetter
ad04a90b2a
Merge pull request #2459 from Tazmaniac/client-renego-fix
Secure Client-Initiated Renegotiation : fixes/enhancements
2024-01-18 18:37:58 +01:00
Emmanuel Fusté
67c362c89a One more spell fix 2024-01-15 10:07:09 +01:00
Emmanuel Fusté
de364b0c84 Introduce SSL_REGEG_WAIT and reduce wait to 0.25s
Reduce wait between reneg test to 0.25s. Still robust and accelerates
the test as now we do up to 10 renego tests.

With the global loop timeout, the backoff identification seem unneeded.
But if we switch to 0.25s, we no longuer trigger the global timeout so
it is still valuable.
Adjust write out messages as bash do not support floating point number
arithmetic.
2024-01-12 11:30:35 +01:00
Emmanuel Fusté
9b79e3917a Bump SSL_RENEG_ATTEMPTS=10 for Stormshield
Stormshield allows 9x and then blocks. So then 10x should be tested.
Example: https://ems.ocapiat.fr
2024-01-11 18:34:47 +01:00
Emmanuel Fusté
b793f54c3e Add timeout for the client initiated renego loop
Some site hang/block the connection after some renego reties
Example: https://feedback.amadeus.com

Hand written timeout logic because:
- we want to get the result of the command in case of normal exit
- we want to have working log fd redirection
- we want to known the timeout condition
2024-01-11 18:30:44 +01:00
Emmanuel Fusté
d30d8e09f2 tab/space corrections and "grep -ac" in place of "grep -a | wc -l" 2024-01-10 18:31:41 +01:00
Dirk Wetter
810e870d16
Merge pull request #2454 from Odinmylord/3.2
Make cert_keysize output consistent
2024-01-10 12:21:42 +01:00
Odinmylord
e404cf8bdb add utf8 support to intermediate cert names 2024-01-03 14:27:11 +01:00
Odinmylord
f4b1bb28a0 Update certificate_info function to include key algorithm in error messages 2024-01-02 14:06:18 +01:00
Dirk Wetter
3f9cc7b6a5
Merge pull request #1871 from dcooper16/quit_on_cmd_line_errors
Quit testssl.sh on all command line errors
2023-12-24 15:34:00 +01:00
Dirk Wetter
bbf770ac7f
Merge pull request #2447 from Odinmylord/3.2
Add Brainpool signature algorithms to output
2023-12-24 14:00:42 +01:00
Dirk Wetter
c5265e33b7 fix wrong temp file var 2023-12-23 13:13:16 +01:00
Dirk Wetter
3b5f2022b3 fix typo 2023-12-23 13:03:57 +01:00
Dirk Wetter
8e517e0a70 Bail out if user error bc of umask
If a user chose a broken umask testssl.sh will start but emits
subsequent errors.

This patch adds two sanity checks whether it is allowed to create
and read files in the temp directory.

Fixes #2449
2023-12-23 12:58:05 +01:00
Odinmylord
90272f1d12 Add Brainpool signature algorithms to output 2023-12-13 14:23:28 +01:00
Emmanuel Fusté
2c84a525cc Fix mitigation detection with debug level 0 2023-12-07 18:58:58 +01:00
Emmanuel Fusté
52c6ac7fec Spell fix. 2023-11-28 15:22:01 +01:00
Emmanuel Fusté
429db592e2 Crudely detect exponential backoff as a mitigation 2023-11-28 14:41:25 +01:00
Dirk
81ba1fe818 Implement warning for wildcard match
fixes #2122
2023-11-10 15:37:13 +01:00
David Cooper
e867e53ff9 Quit testssl.sh on all command line errors
As suggested in #1844, this commit changes testssl.sh so that the parent process quits immediately if there is an error in the command line for one of the child processes.

Currently, a signal is sent to the parent process to quit if the child process encounters an error and calls help(), but sometimes parse_cmd_line() just prints an error message and calls fatal() rather than help(), in which case the parent process does not stop. This commit addresses the issue by creating a new function, fatal_cmd_line(), which is almost the same as fatal(), but additionally sends a signal to the parent indicating that the parent should stop. This commit also changes calls to fatal() to calls to fatal_cmd_line() if json_header(), csv_header(), html_header(), or prepare_logging() encounter a problem. The same is done if prettyprint_local() with the command-line option provided for it.

There may be other places in which it would be appropriate to call fatal_cmd_line() rather than fatal() (e.g., in parse_hn_port() or check_proxy()), but those changes are not made in this commit.
2023-11-01 11:55:06 -07:00
Dirk
cbb32d375b Fix output: PROXY string vs $PROXY variable
See also #2428.
2023-10-30 21:39:30 +01:00
Dirk
a9103fdfee Put the redirection into the right spot 2023-10-30 15:27:37 +01:00
Dirk
92b28c5f1c Fix weird bash globbing #2429
What was problematic was the error message when the certificate
stores were missing. This fixes it by redirecting the error
message to /dev/null so that if the sub function detects the missing
file it returns with an error by the program and not by executing
"basename"
2023-10-30 15:11:10 +01:00
Dirk
b21c5ee780 Add IP protocol to debug msg 2023-10-11 15:22:46 +02:00
Dirk Wetter
f50a958fa9
Merge pull request #2417 from vsbs-david/local_hostname_drill
Added drill command to get_a[aaa]_record() for local hostname
2023-10-11 15:19:44 +02:00
vsbs-david
3f7428083e
Used debugme function 2023-10-11 09:26:43 +02:00
vsbs-david
cbefcf0feb
Fixed redirect stderr to /dev/null, added debug echo for mDNS resolution failure, fixed some spelling 2023-10-10 13:55:34 +02:00
vsbs-david
b8f770dbe3
Added drill command to get_a[aaa]_record() for local hostname 2023-10-10 09:05:48 +02:00
Dirk Wetter
bdeda3ab1c Bump version number 2023-10-09 22:51:44 +02:00
Geert Hendrickx
e09e2c519c Fix SMTP detection.
Extended regex was missing -E.
2023-10-07 14:15:40 +02:00
Geert Hendrickx
16e6826225 Improve detection for POP3 and IMAP. 2023-10-07 13:56:39 +02:00
Dirk Wetter
65da627820 better English 2023-10-03 15:56:18 +02:00
Dirk Wetter
d46301e9f7 Deprecate --ssl-native 2023-10-03 15:51:58 +02:00
Dirk Wetter
2acffa5a3f fix spellcheck issues 2023-10-03 15:06:46 +02:00
David Cooper
06e7205687 Support OpenSSL with no TLSv1
RFC 8996, Deprecating TLS 1.0 and TLS 1.1, states that TLS clients MUST NOT send a TLS 1.0 or TLS 1.1 ClientHello and MUST respond to a TLS 1.0 or TLS 1.1 ServerHello with a "protocol_version" alert.

At the moment, all versions of OpenSSL support TLS 1.0, TLS 1.1, and TLS 1.2. However, TLS 1.0 and TLS 1.1 are disabled in LibreSSL 3.8.1 and it is possible to compile OpenSSL without support for these protocols (using the configure options no-tls1, no-tls1_1, and no-tls1_2). This commit adds support for versions of $OPENSSL that do not support TLS 1.0 or TLS 1.1.
2023-09-07 07:26:48 -07:00
Dirk Wetter
765b5855cc
Merge pull request #2386 from drwetter/strict_parsing_HSTS
Strict parser for HSTS
2023-08-28 19:55:57 +02:00
Dirk
01ab3acde5 Strict parser for HSTS
As suggested in #2381 this parses strictly the value for mag-age
in the HSTS header line. While it is implemented only in run_hsts()
it could be extracted to a separate functioni in the future and used
elsewhere too.

The improvement is more strict and catches e.g. '==' signs and issues
a warning. See https://www.rfc-editor.org/rfc/rfc6797#section-6.1.1 .

Also it is picky regarding quotes now which are only allowed enclosing
the value.
2023-08-28 18:33:41 +02:00
Dirk Wetter
c55207d45c
Merge pull request #2385 from drwetter/hide_fast
Hide --fast option in help() and issue a warning when it's used
2023-08-28 18:26:36 +02:00
Dirk
0fcddff1cd Warn when using --fast
... in the terminal only for now.
2023-08-28 16:08:04 +02:00
Dirk
d19675136a Deprecating $FAST / --fast
As this option shows inconsistencies / wrong results and a fix would require
too much work at this moment this option is being hidden from the help. It
wasn't in the ~/doc .

See #849 , #2382, #1732 etc.
2023-08-28 15:53:02 +02:00
Dirk
79577a84eb Introducing variable OPENSSL2_HAS_TLS_1_3
If we run with supplied binary AND /usr/bin/openssl supports TLS 1.3
we now have a variable OPENSSL2_HAS_TLS_1_3 which is set to true.

It can be used for subsequent changes where we need TLS 1.3 for or
where it would be better to use TLS 1.3.
2023-08-28 15:42:17 +02:00
Geert Hendrickx
38a09d342c
Fix another grep-3.8 warning on needlessly escaped exclamation mark.
See also #2241 and #2242.
2023-08-28 13:55:46 +02:00
Dirk
858f00304c tiny clarification in debug mode 2023-06-02 16:57:47 +02:00
Dirk
6e2b9ae1c6 Make clear where the parsing error comes from: SSL or TLS 2023-06-02 16:43:27 +02:00
teki69
eb76fd08cb
Adds a warning when downloaded CRL is PEM format 2023-05-23 11:37:03 +02:00
teki69
ebcb5554a8
Fix CRL conversion issue when already in PEM format
If downloaded CRL file is already in PEM format, openssl command will fail as it is always trying to convert from a DER-encoded CRL. 
This commit is for adding a test of the CRL format prior to running the openssl crl conversion. 

Note: as the openssl verify command then assumes that a .pem tmpfile has been generated by the conversion, there would be an issue when the conversion was not needed (i.e. CRL already PEM-encoded) as that .pem would be missing; therefore I also added a copy of the .crl file to a .crl.pem file before the optional conversion.
2023-05-22 17:10:25 +02:00
Dirk Wetter
9b8dc3a07e Fix misleading output
... when instructed to do no DNS queries at all
2023-05-16 09:05:04 +02:00
mum-viadee
22a4f52774 Clarify comment, redone 2023-05-15 15:20:54 +02:00
mum-viadee
6216bcd635 Revert "Update testssl.sh"
This reverts commit e33e0bc204.
2023-05-15 15:16:16 +02:00
Dirk Wetter
e33e0bc204
Update testssl.sh
clarify comment
2023-05-15 15:04:59 +02:00
mum-viadee
93466806f5 Added SNI to openssl call for testing secure client-initiated renegotiation 2023-05-15 08:13:21 +02:00
mum-viadee
f0f6b1a4fb Typo in comment corrected 2023-05-12 14:26:27 +02:00
mum-viadee
04f7b34028 Added SNI to openssl call for testing secure renegotiation 2023-05-12 13:53:54 +02:00
Dirk Wetter
aa5235e658
Merge pull request #2346 from Odinmylord/3.1dev
Add information to RSA-PSS report
2023-04-01 09:51:27 +02:00
Dirk Wetter
a04291fdb1
Merge pull request #2352 from dcooper16/pss_cert_tls13
Find RSASSA-PSS certificates with TLS 1.3
2023-03-31 16:38:14 +02:00
David Cooper
dc996ba2b9 Find RSASSA-PSS certificates with TLS 1.3
This commit fixes get_server_certificate() so that it can obtain certificates with RSASSA-PSS subject public keys over TLS 1.3.
2023-03-28 14:31:28 -07:00
David Cooper
5002dd23b1 Add support for brainpool curves with TLS 1.3
This commit adds support for the curves brainpoolP256r1tls13, brainpoolP384r1tls13, and brainpoolP512r1tls13.
2023-03-28 08:53:20 -07:00
Dirk Wetter
f95d0dd09a
Merge pull request #2328 from drwetter/w4ntun-merge
fixed DNS via Proxy
2023-03-23 14:31:17 +01:00
Odinmylord
cf0c1c1f5f Added more details to the SignatureAlgorithms 2023-03-22 23:14:56 +01:00
Dirk
d001bba86b Finalize DNS via Proxy
See #2328, original PR #2295 from @w4ntun .

Formally testssl.sh returned an error when it wasn't not possible to determine IP
addresses through DNS resolution, even if --proxy and --ip=proxy flags are set.
The main function always tried to determine IP addresses via DNS and exits with
a fatal error if it cannot do it. Although the client cannot get the IP, the
proxy could, so the SSL/TLS analysis is still possible.

This PR allows the analysis for an HTTP service via a proxy server and the DNS
traffic can be sent directly or through the proxy using the flag --ip=proxy.

ATTENTION: This may be a breaking change for those who don't have a local resolver.
They now have to add --ip=proxy.

In addition:
* help() was amended to add --ip=proxy (was only in the ~i/doc dir before)
* amending ~/doc dir to document it's better to add --nodns=min when there's
  no local resolver
2023-03-21 19:40:40 +01:00
Dirk Wetter
b84e182ca2
Merge pull request #2332 from drwetter/sanitize_fileout
Make sure control chars from HTTP header don't end up in html,csv,json
2023-03-12 16:18:20 +01:00
Dirk Wetter
2e33c483dd remove comma in tr as it was interpreted as such 2023-03-12 14:52:11 +01:00
Dirk Wetter
fab67d0cca Remove CR in server banner
... which caused a problem in t/32_isHTML_valid.t.

Also the test for an empty server banner was simplified
2023-03-12 14:00:55 +01:00
Dirk Wetter
06506b371e Make sure control chars from HTTP header don't end up in html,csv,json
This addresses the bug #2330 by implementing a function which removes
control characters from the file output format html,csv,json at the
output.

In every instance called there's a check before whether the string
contains control chars, hoping it'll save a few milli seconds.

A tr function is used, omitting LF.

It doesn't filter the terminal output and the log file output.
2023-03-11 13:38:28 +01:00
Dirk
9afa277c02 another indent correction 2023-03-03 12:50:02 +01:00
Dirk
2b6bd2f1dd fix indentation 2023-03-03 12:47:12 +01:00
Dirk
581788ff39 Merge branch '3.1dev' of https://github.com/w4ntun/testssl.sh into w4ntun-3.1dev 2023-03-03 12:31:26 +01:00
Dirk
a14fc5bdcf Fix Accept header
see #2325.

"whenever HTTP/1.1 is used then the Accept header uses "text/*" as a MIME type.
This causes some minor issues with some of the checks we are doing"
2023-02-20 15:01:40 +01:00
Dirk Wetter
6f881dc70b Rename 3 jsonIDs in run_cipherlists(): breaking change
see #2316 / #2320

AVERAGE --> OBSOLETED
GOOD    --> STRONG_NOFS
STRONG  --> STRONG_FS
2023-02-05 19:32:08 +01:00
David Cooper
3d82f7cb21 Fix HTML output in Bash 5.2 and newer
As noted in #2304, the way that the '&' character is treated in the string part of a pattern substitution changed in Bash 5.2. As a result, the change that was made in #1481 to accommodate older versions of Bash (e.g., on MacOS) now causes testssl.sh to produce incorrect HTML output when run on Bash 5.2.

This commit encodes the '&' characters in the substitution strings in a way that produces correct results on multiple versions of Bash (3.2 on MacOS, 5.2 on Ubuntu 23.10, 5.0 on Ubuntu 20.04).
2023-02-03 14:18:02 -08:00
Sole
3670c1e4ad Removed non-relevant CA's that no longer have active certificates. 2023-02-02 01:13:00 +00:00
Sole
9fc8c33704 Change exception for removed root certificates into easy edit multi-value regular expression for Organization name and making it clear that CA's are actively removed from 1+ root stores. 2023-02-02 00:42:15 +00:00
Dirk Wetter
fdd72d2785 Cleanup code, clarfy comments for AD/LDAP + STARTTLS 2023-01-17 14:23:53 +01:00
Dirk Wetter
fc2a020294 Add logic for STARTTLS enabled AD servers
There are two different scenarios. x0C is the buffsize reply from openldap-like servers
whereas AD servers probably have x84 and return also the OID. The following is kind of
hackish as ldap_ExtendedResponse_parse() in apps/s_client.c of openssl is kind of hard
to understand. It was deducted from a number of hosts.
Bottom line: We'll look at the 9th byte or at the 17th when retrieving the result code

AD:
30 84 00 00 00 7d 02 01 01 78 84 00 00 00 74 0a 01 34 04 00 04 55 30 30 30 30 30 30 30 30 3a 20 [ failed AD .. LdapErr + OID..]
30 84 00 00 00 28 02 01 01 78 84 00 00 00 1F 0A 01 00 04 00 04 00 8A 16 [.. OID ..]
   ^^ bufflen                                      ^^ resultcode

30 0C 02 01 01 78 07 0A 01 00 04 00 04 00
   ^^ bufflen              ^^ result code
2023-01-17 11:16:05 +01:00
Kali
0af73c2d19 fixed DNS via Proxy 2023-01-05 14:11:44 +01:00
Dirk Wetter
c67cefaf8e add info about error handling 2022-12-26 19:15:49 +01:00
Dirk Wetter
336d3c947a better use safe_echo() 2022-12-26 16:14:26 +01:00
Dirk Wetter
b633efae69 make starttls_ldap_dialog() more readable...
... add references + better debugging output
2022-12-26 16:10:31 +01:00
David Cooper
e2942966d2 Fix whitespace issues
This commit fixes incorrect indentations introduced in #2276 and #2278, and also removes the extra whitespace that would have been removed by #2279.
2022-11-25 07:44:48 -08:00
David Cooper
907126a285 Fix extract_calist()
When a server supports client authentication, extract_calist() extracts the list of supported certification authorities sent by the server. extract_calist() uses different code to extract the list from a TLS 1.3 response than from a TLS 1.2 or earlier response, since the CertificateRequest message was changed for TLS 1.3.

For TLS 1.2 and earlier, extract_calist() assumes that the CertificateRequest message is a sequence of certificate types, signature algorithms, and certification authorities. However, the signature algorithms field was added in TLS 1.2 and does not appear in TLS 1.1 and earlier. So, the current code does not work unless the server supports TLS 1.2 or TLS 1.3.

This commit fixes the problem by checking whether the response is a TLS 1.2 response, and skipping over the extraction of the signature algorithms field if the response is neither TLS 1.2 nor TLS 1.3.
2022-11-23 08:35:45 -08:00
David Cooper
c7644ad58e Limit size of signature_algorithms extension
Some servers get confused if the signature_algorithms extension is too large. This commit addresses the problem by:

* For TLS 1.2, generally limiting the signature algoritms to those consistent with the key type being tested.

* For TLS 1.3, breaking the list of signature schemes in two, and testing each half of the list separately.
2022-11-18 06:23:24 -08:00
David Cooper
6088eddab6 Show server supported signature algorithms
This commit modifies run_fs() to show the signature algorithms the server supports in the ServerKeyExchange message for TLS 1.2 and in the CertificateVerify message for TLS 1.3.

Signature algorithms are not shown for TLS 1.1 and earlier, since for those protocol versions the signature algorithm to use is specified by the protocol. While the signature algorithm used in TLS 1.1 and earlier is weak, testssl.sh already warns if these protocol versions are supported.
2022-11-18 06:23:24 -08:00
David Cooper
3eb8cf6754 Fix #1747
This commit fixes #1747 by converting PEM encoded certificates that are sent to fileout() to a single line. As suggested in #1747, '\n' is added after the '----- BEGIN ... -----' line and before the '------ END ... ------' line.

In order to ensure that '\n' appears in the string in the JSON and CSV files, '\\n' is sent to fileout() so that 'printf -- "%b"' converts '\\n' to '\n' rather than converting '\n' to a newline character.

In order to prevent fileout() from converting '\\n' to '\ ', this commit move the fix for #2049 (see PR #2050) from fileout() to fatal().
2022-11-17 06:31:52 -08:00
Dirk Wetter
1842b9eefb Remove Negotiated cipher / protocol in server preferences
As a first cleanup action I removed in run_server_preference()
the line with Negotiated Protocol and Negotiated Cipher as
the don't have any real information, see #2235 , comment below:
https://github.com/drwetter/testssl.sh/pull/2235
2022-11-14 17:23:13 +01:00
David Cooper
43fade414c Fix #2271
This commit fixes #2271 by adding the `-no_ssl2` option to the call to get_host_cert() in run_drown(). There is at least one server that causes OpenSSL to hang if this call to get_host_cert() results in an SSLv2 ClientHello being sent. Since this call to get_host_cert() only needs to find the server's certificate in cases in which the server does not support SSLv2, there is no need to send an SSLv2 ClientHello.
2022-11-10 11:24:56 -08:00
Dirk Wetter
6716dc7465
Merge pull request #2261 from osown/3.1dev
if PROXY variable is set there is no need to do a direct connection attempt
2022-11-10 10:52:14 +01:00
Dirk Wetter
2b0fdfdf64
Merge pull request #2262 from dcooper16/run_fs_infnite_loop
Fix infinite loop in run_fs()
2022-11-10 09:43:29 +01:00
Dirk Wetter
a4419fa9c9
Merge pull request #2264 from dcooper16/padding
Clean up adding padding
2022-11-10 09:37:42 +01:00
David Cooper
f5162c9897 Fix #2249
This commit fixes #2249 by recognizing "sha1WithRSA" synonym for "sha1WithRSAEncryption."

OpenSSL uses "sha1WithRSAEncryption" to represent 1.2.840.113549.1.1.5 and "sha1WithRSA" to represent 1.3.14.3.2.29. While 1.2.840.113549.1.1.5 is generally recognized as the "standard" OID for RSA with SHA-1 (see, for example, RFC 3279), 1.3.14.3.2.29 has been used in some places as well (https://codereview.chromium.org/1223763002, https://bugzilla.mozilla.org/show_bug.cgi?id=1042479, https://github.com/pyca/cryptography/issues/3160).
2022-11-09 10:26:38 -08:00
David Cooper
e59d6ab9f6 Clean up adding padding
This commit simplifies the adding of padding data in a few places. Rather than adding one or two bytes at a time in a "for" loop, all of the padding is added in one step by extracting it from a long padding string. (The one exception is in run_robot(), where a "for" loop is used to add additional padding in case in which the RSA modulus is longer than the pre-defined padding string.)

Extracting the padding from a long string is faster than using a "for" loop and it makes the debugging file a little cleaner.

The idea is the same as PR #1940.
2022-11-07 14:13:45 -08:00