Commit Graph

3996 Commits

Author SHA1 Message Date
Dirk Wetter 22272105c4
Merge pull request #2057 from mspncp/git-simplify-worktree-check
Simplify check for git working tree
2021-12-06 18:35:24 +01:00
Dr. Matthias St. Pierre 1e3f932932 Simplify check for git working tree
Sending the entire log to /dev/null is a rather expensive way of checking whether
we are inside a git working tree. Use `git rev-parse --is-inside-work-tree` instead.
2021-12-06 17:35:54 +01:00
Dirk Wetter 914dde501a Update Firefox UA used in sneaky mode
From FF 52 to FF 94.

Also one double quote was removed
2021-12-03 13:15:13 +01:00
Dirk Wetter f6571c7c76
Merge pull request #2050 from dcooper16/fix2049
Fix #2049
2021-11-30 11:19:44 +01:00
David Cooper 708cc672a2 Fix #2049
This commit fixes #2049 by converting newline characters to spaces in JSON and CSV findings.

fileout() calls newline_to_spaces() on the $findings that are to be written to JSON and CSV files. However, this only affects actual newline characters in the string, not escaped newline characters (i.e., "\n"). Escaped newline characters pass through this function unchanged, but then get converted to newline characters when they are written to the JSON and/or CSV files. This commit fixes the problem by also converting escaped newline characters ("\n") to spaces.
2021-11-29 14:36:29 -05:00
Dirk Wetter b40d38fc37
Merge pull request #2047 from drwetter/fix_badFileDescriptor
Fix for "Bad file descriptor" with --connect-timeout option
2021-11-28 18:11:36 +01:00
Dirk aca75822c1 Fix for "Bad file descriptor" with --connect-timeout option
This fixes #1834 and #1435.

The --connect-timeout option had the problem that under certain circumstances
like parallel mass scanning it didn't work. The culprit was that a subshell command
was used to connect to the target but the file descriptor wasn't exported.

The commit changes tha logic so that this connect is still done in a subshell
as a pre-check if it's possible to connect. If this fails it proceeds with
error handling if NR_SOCKET_FAIL is above threshold. Otherwsie it just connects
again.

When testing of the alexa 500 it worked for me(tm). It would be great if others
can give it a try.
2021-11-26 17:24:02 +01:00
Dirk Wetter f253920e92
Merge pull request #2044 from dcooper16/fix_sub_cipherlists
Fix sub_cipherlists()
2021-11-23 09:59:41 +01:00
David Cooper 6b7836d350 Fix sub_cipherlists()
This commit fixes a bug in sub_cipherlists() when using sockets to test whether a server supports a set of ciphers with SSLv2. Code that is supposed to extract the list of SSLv2 ciphers to test for is incorrectly reading from the list of non-SSLv2 ciphers.
2021-11-22 12:25:20 -05:00
Dirk Wetter 7e7458bff0
Merge pull request #2043 from dcooper16/shellcheck
Fix some Shellcheck issues
2021-11-16 17:28:14 +01:00
Dirk Wetter 92a0da1d75
Merge pull request #2042 from dcooper16/check_file_permissions
Check file permissions on ./testssl.sh
2021-11-16 17:25:38 +01:00
David Cooper 64d110f19d
Check file permissions on ./testssl.sh
This commit adds a check that ./testssl.sh has both read and execute permission. If ./testssl.sh is lacking execute permission, it will pass the tests in 00_testssl_help.t and 01_testssl_banner.t that run the program as `bash ./testssl.sh`, but will fail the subsequent tests that run the program as `./testssl.sh`, but the reason for the failure will not be clear.
2021-11-15 07:25:08 -05:00
David Cooper 80934c85e8 Fix some Shellcheck issues
This commit fixes a few issues found by Shellcheck.
2021-11-12 16:20:41 -05:00
Dirk Wetter 1b11575c28
Merge pull request #2040 from dcooper16/ossl31
Support OpenSSL 3.0.1-dev and 3.1.0-dev
2021-11-10 08:12:30 +01:00
Dirk Wetter 883d7bd237
Merge pull request #2039 from dcooper16/fix_debugme1_redirect
Fix calls to debugme1() with redirects
2021-11-10 08:09:22 +01:00
David Cooper f1df111a32 Fix calls to debugme1() with redirects
As noted in https://github.com/drwetter/testssl.sh/pull/1963#issuecomment-954935175, there are two places in which debugme1() is called in which the command to be run prints something to stdout, which is then redirected to a file. Now that debugme1() includes a redirect from stdout to stderr, these two lines do not work as expected. The output appears in the terminal and an empty file is created.

This commit fixes the issue by not using the debugme1() function in these two places.
2021-11-09 15:36:30 -05:00
David Cooper 095433774d Support OpenSSL 3.0.1-dev and 3.1.0-dev
This commit changes a few lines of code that checks OpenSSL version numbers to recognize 3.0.1 and 3.1.0 in addtion to 3.0.0.

According to https://www.openssl.org/blog/blog/2018/11/28/version, API/ABI compatibility is guaranteed for the same MAJOR version number (starting with version 3), so it should be sufficient to just check that $OSSL_VER_MAJOR is 3.
2021-11-08 08:04:34 -05:00
Dirk Wetter b7d6b7ca7b
Merge pull request #2034 from magnuslarsen/3.1dev
[Rating] Fix cipher rating, and add penalty for weak ciphers
2021-11-06 12:20:18 +01:00
Magnus Larsen 2b490bd3d3 Also calculate correct final score 2021-11-06 09:06:33 +01:00
Magnus Larsen cc25613138 [Rating] Fix cipher strength rating, and add penalty for weak cipher suites 2021-11-06 08:45:55 +01:00
Jens Wahnes 31c2ecfcb1 Consider HTTP 'Age' header field when calculating HTTP clock skew. 2021-11-01 19:08:37 +01:00
Dirk Wetter 75dd8fc89b
Merge pull request #2031 from dcooper16/fix2030
Fix 2030
2021-10-29 09:14:27 +02:00
David Cooper 3d9f109780
Fix 2030
Fix CI issue created by #2028 and by new certificate fingerprint.
2021-10-28 08:13:34 -04:00
Dirk Wetter b00e065546
Merge pull request #2028 from dcooper16/prioritize_chacha
Fix #1733
2021-10-28 09:09:53 +02:00
David Cooper 43f3b507c1 Fix #1733
This commit adds PrioritzeChaCha detection, as requested in #1733. If the server (1) enforces a cipher order for a given protocol, (2) supports at least one non-ChaCha cipher for that protocol, and (3) supports at least one ChaCha cipher that would normally be less preferred than the ChaCha cipher, then a test is performed to see if the server selects the ChaCha cipher if it is listed first in the ClientHello.
2021-10-27 13:53:30 -04:00
Dirk Wetter 1dc858dc90
Merge pull request #2026 from dcooper16/speedup_cipher_pref_check
Speedup cipher_pref_check()
2021-10-27 10:04:13 +02:00
Dirk Wetter 6f6eec25c1
Merge pull request #2025 from dcooper16/remove_extra_colon
Remove extra colon
2021-10-27 10:02:47 +02:00
David Cooper 15e3d61ddc Speedup cipher_pref_check()
While OpenSSL 1.0.2-chacha supports more than 128 cipher suites, other versions of OpenSSL tend to support far fewer than that.

Calling check_tls12_pref() adds to the run time of cipher_pref_check(), but is only needed if OpenSSL would otherwise send a ClientHello with more than 128 cipher suites. So, this commit adds another check and only calls check_tls12_pref() if the server has the size limit bug and OpenSSL supports more than 127 ciphers.
2021-10-26 15:56:08 -04:00
David Cooper d4606ad9f8 Remove extra colon
The code added by #2024 creates a cipher list with two consecutive colons. While this doesn't seem to be a problem, the commit removes the extra colon.
2021-10-26 15:43:01 -04:00
Dirk Wetter dc074ebdf1
Merge pull request #2024 from dcooper16/improve_cipher_pref_check
Improve cipher_pref_check()
2021-10-26 20:40:58 +02:00
David Cooper 2b752feea0 Remove unnecessary quotes 2021-10-26 12:05:36 -04:00
David Cooper 4536e933f9 Improve cipher_pref_check()
Some servers are configured to prioritize ChaCha ciphers if those ciphers are preferred by the client, even if the server is generally configured to use the server's cipher preferences rather than the client's. As a result of this, if a ChaCha cipher appears in the ClientHello before a non-ChaCha cipher, the server may select the ChaCha cipher even if the server is configured to prefer the non-ChaCha cipher.

In a few cases, e.g., cloudflare.com for TLS 1.2, this affects the ordering of the ciphers presented by cipher_pref_check(). This commit fixes the problem by having cipher_pref_check() (and check_tls12_pref()) always place any ChaCha ciphers at the end of the cipher list in the ClientHello. This ensures that cipher_pref_check() presents the ciphers in the server's preference order.
2021-10-25 14:28:51 -04:00
Dirk Wetter 1a66155c4a
Merge pull request #2022 from dcooper16/fix_s_client_options
Fix s_client_options()
2021-10-25 19:02:07 +02:00
David Cooper 00fb68f47c Fix s_client_options()
This commit fixes an error in s_client_options() when the function is called with an empty "-cipher" list and $OPENSSL supports "@SECLEVEL". This happens, for example, when ciphers_by_strength() is called for TLS 1.3.

The call to `openssl s_client` will fail is the cipher option is provided with an empty list or a list that just contains "@SECLEVEL=0". So, "@SECLEVEL=0" should only be added if the "$ciphers" list is non-empty. If "$ciphers" remains empty, then the "-cipher" option will not be added to the command line.
2021-10-25 12:15:13 -04:00
Dirk Wetter e36cfffb2c
Merge pull request #2020 from drwetter/improve_precheck_curves
Improve precheck for curves
2021-10-23 23:02:21 +02:00
Dirk Wetter 31162d2320 typo / wording 2021-10-23 18:40:29 +02:00
Dirk Wetter a11bd1585e Improvement for testing curves with several openssl / libressl versions
As noted in #2016 the detection of curves in find_openssl_binary()
copuld be improved.

This commit removes another connect call. Also it corrects the port statement
for LibreSSL-like pre-checks as port 0 generally seems to me better suited.
Inline documentation was added.

It worked so far with openssl 1.0.2, 1.1.1 and 3.0 and LibreSSL 3.4.

This needs to be backported to 3.0.
2021-10-23 18:38:04 +02:00
Dirk Wetter 6251a6c1d6
Merge pull request #2016 from drwetter/fix_double_ports
Fix double ports statement
2021-10-23 16:02:04 +02:00
Dirk Wetter 82fc8e7431
Update feature_request.md 2021-10-21 11:01:13 +02:00
Dirk Wetter d5e761e9e9
Update bug_report.md 2021-10-21 11:00:44 +02:00
Dirk Wetter 93c1180f9d
Update feature_request.md 2021-10-21 10:56:27 +02:00
Dirk Wetter ff919df2e0
Update bug_report.md 2021-10-21 10:52:34 +02:00
Dirk Wetter 489b63e9dd
Merge pull request #2017 from drwetter/cab_is4browsers
Add browser requirement for the entropy of cert serial
2021-10-21 09:51:00 +02:00
Dirk Wetter 110d1aa73c Add browser requirement for the entropy of cert serial 2021-10-20 19:26:23 +02:00
Dirk Wetter 3140352b0c Fix double ports statement
In order to be in line with 3.0 this adds a statement to avoid double port
statements for WSL users in a precheck condition

   $OPENSSL s_client -groups $curve -connect 127.0.0.1:0:8443

This commit changes that to $OPENSSL s_client -groups $curve -connect 127.0.0.1:8443
which could cause a delay for WSL users and needs further investigation.

Not clear why port 8443 was chosen.
2021-10-20 09:01:09 +02:00
Dirk Wetter 79df758023
Merge pull request #2014 from drwetter/fix_len_certserialnum
Check cert serial len + fix output when too big
2021-10-20 08:58:46 +02:00
Dirk Wetter 2edfa57eaa Check cert serial len + fix output when too big
OpenSSL shows certificate serial numbers >35 with a LF (0A). Testssl.sh
just output that which makes JSON invalid and displays the LF in the terminal
too.

This commit fixes that (#2010) by adding filters so that the
serialnumber is not a multiline string.

Also this commit introduces a new function: a size check of the cert serial.
Below 8 bytes the CAB Forum's lower limit is hit which says the *entropy*
from a CSPRNG should be at least 64 bits. It is assumed that below 8 bytes
length this requirement isn't possible to meet (needs to be clarified with
Shannon, 8 bytes seems to low to me).
  The high threshold is according to RFC 5280, Section-4.1.2.2 .

See also #2013.

The output has changed, so that on the terminal the serial has one line,
SHA1 and SHA256 each one line. The new json key is "cert_serialNumberLen".
2021-10-19 19:42:12 +02:00
Dirk Wetter 9683af44a2
Merge pull request #1988 from drwetter/windows_dns_fix
Addressing lame DNS responses on WSL
2021-10-18 16:52:35 +02:00
Dirk Wetter d496c0d44b
Merge pull request #2002 from smokris/1995-trusted-first
In determine_trust(), use the OpenSSL '-trusted_first' flag to ignore the now-expired DST Root CA X3 root certificate
2021-10-07 18:03:20 +02:00
Steve Mokris 5c4500ea4f Initialize/reset the TRUSTED1ST variable, in case determine_optimal_proto() changes the active openssl binary partway through execution 2021-10-06 16:01:13 -04:00