Commit Graph

284 Commits

Author SHA1 Message Date
Julien Vehent 8a03b8d4e7 fix pubkey quality test 2015-09-18 14:49:51 -04:00
Julien Vehent 3dd0f58f4c When in JSON mode, run curve and tolerance tests 2015-09-18 13:05:49 -04:00
Julien Vehent 55918f3afb Add OK/KO flags in terminal output 2015-09-18 13:05:49 -04:00
Julien Vehent 249b3be23d Rephrase TLS tolerance output in terminal 2015-09-18 12:35:17 -04:00
Julien Vehent 0de6abab61 Merge pull request #81 from floatingatoll/argparse_fixes
Argparse fixes
2015-09-18 09:35:42 -04:00
Julien Vehent 5e2b12d940 Merge pull request #80 from floatingatoll/cacerts_logic
Replace CACERTS env logic with --cafile parameter.
2015-09-18 09:35:06 -04:00
Julien Vehent b951fd5588 Merge pull request #79 from floatingatoll/autodetection-perf
separate darwin and non-darwin OS autodetection, add NOAUTODETECT support for top1m performance
2015-09-18 09:32:33 -04:00
Julien Vehent 9dace07f4d Merge pull request #76 from floatingatoll/curves-by-default
enable curves by default
2015-09-18 09:29:18 -04:00
Julien Vehent 3770389b5c Merge pull request #68 from kenoh/master
Fix: incorrect list + string concatenation (issue #64)
2015-09-18 09:27:41 -04:00
Richard Soderberg 4b87301eb4 separate darwin and non-darwin OS autodetection, add NOAUTODETECT support for top1m performance
This patch implements two structural changes.

First, OS-level detection routines are broken out into a case statement.

Darwin doesn't need to test for readlink/timeout nor Busybox, so this
noticeably improves performance over multiple runs on Darwin.

Linux suffers no additional penalty, since we already ran if $(uname)
every time anyways, and continues to use the more complex
timeout/gtimeout/busybox logic at the (preexisting, unaffected) cost to
performance over multiple runs.

Second, if NOAUTODETECT is set, then the script assumes (and verifies)
that you're providing TIMEOUTBIN and OPENSSLBIN values. If both of those
values are executable files, then the script will proceed, else it will
abort. In this scenario, readlink is unnecessary and is thus unused.

The combination of these two changes will improve performance over
multiple runs both on Darwin and when NOAUTODETECT is set for top1m.
2015-09-05 05:04:37 -07:00
Richard Soderberg 12ede64882 bash4 version check failure should go to STDERR. 2015-09-05 05:04:04 -07:00
Richard Soderberg 6adda69af5 Revise CACERTS autodetection logic, ensure that CACERTS/CAPATH is readable/directory, add undocumented CAPATH env override.
This takes advantage of the new --cafile logic to avoid running CACERTS
autodetection when a file is provided on the command line.

It then ensures the readability of that file, whether provided or
autodetected.

This also adds an undocumented CAPATH environment variable alternative
to --capath, to go along with the existing undocumented CACERTS
environment variable alternative to --cafile, to provide legacy support
for preexisting users.
2015-09-05 04:59:17 -07:00
Richard Soderberg 5dc692566a Refuse to accept both --cafile and --capath.
Prior to this commit, the code accepts both the --cafile and the
--capath options, as that's how it's always behaved. This patch corrects
that, refusing to proceed if the options are provided.

Technically, openssl permits the use of both the -CAfile and -CApath
options. However, cipherscan itself can only make use of one of the two
options, and does not currently support "one or both" scenarios.

So this patch ensures that users are not caught unaware when they
specify --capath and --cafile and the script refuses to honor the
latter.
2015-09-05 04:45:28 -07:00
Richard Soderberg 097bd0c43b Rewrite HOST[:PORT] extraction routine (less sed, more validation).
The HOST[:PORT] extraction routine was written using several calls to
sed and a bunch of regex post-processing of the bash $@ array.

This replaces that with bash-native array commands, copying $@ into
a $PARAMS array, removing the last element into $TARGET, and then
passing the remainder to openssl s_client.

This adds validation of the TARGET to ensure that it matches what we
expect for a HOST[:PORT]; if a ':' is present, it must be preceded by a
hostname and followed by a port number, otherwise :443 is appended.

The check to ensure that HOST is not an -option is merged into this as
well, since we already test for : at the beginning of the HOST
(indicating that only a port was provided).

Additionally, this now defends against an empty string "" being passed
as the final option, which could occur if a script calling cipherscan
goes awry and starts passing empty values as the target.

top1m may see a slight speed improvement from this commit, as 4 calls to
sed are replaced with native bash functions.

Fixes one "SC2086: Double quote to prevent globbing and word splitting.":

In cipherscan line 1402:
SCLIENTARGS=$(sed -e s,${TEMPTARGET},,<<<"${@}")
                       ^-- SC2086: Double quote to prevent globbing and
                       word splitting.
2015-09-05 02:10:50 -07:00
Richard Soderberg d81ee1c801 Refuse to proceed if no HOST[:PORT] is provided after the options.
Prior to this patch, if the user fails to provide a host:port after
specifying cipherscan options, the script runs sed on an empty variable
(failing with a syntax error) and then asttempts to cipherscan the
target ':443'.

This adds a simple test to ensure that a target was actually provided.
2015-09-05 01:35:47 -07:00
Richard Soderberg 28555b03f0 Refuse to proceed if the final argument starts with a hyphen.
This detects and prevents a specific category of user error, where an
incomplete cipherscan command line ending in an OpenSSL -option results
in cipherscan attempting to scan the target '-option:443'.
2015-09-05 01:01:19 -07:00
Richard Soderberg e35a6155bc Add --cafile <filename.crt>, alongside --capath <dirpath/>.
For unknown reasons, while we previously supported --capath we did not
support --cafile. This forces the --cafile autodetection logic to run
every time, unnecessarily, when we have a specific file in mind to use.

This patch relocates the -CAfile autodetection logic to run *only if*
the --cafile parameter is not provided. If it is not provided, the
autodetection logic occurs precisely as before.

This patch declines to address what happens if both --capath and
--cafile are passed. The previous logic already ensured that the CA file
was *always* set, and then only sometimes was the CA path set. The new
logic maintains that behavior precisely, reserving logic flow changes
for a separate commit.
2015-09-05 00:22:40 -07:00
Richard Soderberg 0728751208 move bash4 detection as early as possible in the script to permit logic later on 2015-09-05 00:06:31 -07:00
Julien Vehent 3f3e22b09a Merge pull request #77 from floatingatoll/bashisms
Various bash cleanups and one bugfix
2015-09-03 10:13:30 -04:00
Richard Soderberg 22adaf188a verify that the openssl binary is emitting a valid s_client -help.
This catches instances where the wrong openssl binary is selected (for
instance, if uname -s is neither Darwin nor Linux) and serves as a
simple up-front test to make sure that openssl is working before we
proceed further into the script.
2015-09-03 07:02:40 -07:00
Richard Soderberg 9a0e055628 remove crude_grep in favor of a simple =~ substring match.
The crude_grep function served only to perform a simple substring check
against the output of openssl -help. So, instead of running the command
each time, iterating its output line by line, and checking for the
substring within it, this simply caches the -help output at startup and
uses $help =~ substring to produce the same result in a single pass.
2015-09-03 06:58:05 -07:00
Richard Soderberg f0142c323a remove one unnecessary assignment when on Darwin. 2015-09-03 06:47:47 -07:00
Richard Soderberg 5ec3184a37 call dirname $0 three fewer times by caching the unmodified value prior to readlink modifications 2015-09-03 06:40:48 -07:00
Richard Soderberg f002b3573a fixes for "SC2004: $/${} is unnecessary on arithmetic variables."
In cipherscan line 451:
        for ((i=0; i<$certificate_count; i=i+1 )); do
                     ^-- SC2004: $/${} is unnecessary on arithmetic variables.

In cipherscan line 603:
    cipherbenchms="$((t/1000/$BENCHMARKITER))"
                             ^-- SC2004: $/${} is unnecessary on arithmetic variables.
2015-09-03 06:37:09 -07:00
Richard Soderberg 21871b5bd7 fixes for "SC2046: Quote this to prevent word splitting." and "SC2086: Double quote to prevent globbing and word splitting."
In cipherscan line 13:
REALPATH=$(dirname $0)
                   ^-- SC2086: Double quote to prevent globbing and word splitting.

In cipherscan line 15:
readlink -f $0 &>/dev/null && REALPATH=$(dirname $(readlink -f $0))
            ^-- SC2086: Double quote to prevent globbing and word splitting.
                                                 ^-- SC2046: Quote this to prevent word splitting.
                                                               ^-- SC2086: Double quote to prevent globbing and word splitting.

In cipherscan line 46:
if [[ -e $(dirname $0)/openssl.cnf ]]; then
                   ^-- SC2086: Double quote to prevent globbing and word splitting.

In cipherscan line 47:
    export OPENSSL_CONF="$(dirname $0)/openssl.cnf"
           ^-- SC2155: Declare and assign separately to avoid masking return values.
                                   ^-- SC2086: Double quote to prevent globbing and word splitting.

In cipherscan line 60:
    CACERTS="$(dirname $0)/ca-bundle.crt"
                       ^-- SC2086: Double quote to prevent globbing and word splitting.
2015-09-03 06:26:36 -07:00
Richard Soderberg 4405d3fdce remove unused variable "fallback_available" 2015-09-03 06:17:15 -07:00
Richard Soderberg 3664b1a199 fixes for "SC2145: Argument mixes string and array. Use * or separate argument."
In cipherscan line 941:
    verbose "Server supported curves: ${tmp_curves[@]}"
                                      ^-- SC2145: Argument mixes string and array. Use * or separate argument.

In cipherscan line 968:
            verbose "ephem_data: ${ephem_data[@]}"
                                 ^-- SC2145: Argument mixes string and array. Use * or separate argument.
2015-09-03 06:14:28 -07:00
Richard Soderberg bbb3496627 trim dead trailing ; 2015-09-03 06:02:15 -07:00
Richard Soderberg 1c15af1ce3 verify the results of pushd rather than trusting it 2015-09-03 06:02:12 -07:00
Richard Soderberg 81481cd016 requote, reindent ciphers and curves to the same format 2015-09-03 06:00:38 -07:00
Richard Soderberg 10057f93dc revise whitespace layout of cipher, curve arrays to improve future diffs 2015-09-03 06:00:31 -07:00
Richard Soderberg 9e563782e2 fix syntax error in busybox check - $(( is not the same as $( (, and a subshell is unnecessary here in any case 2015-09-03 06:00:23 -07:00
Richard Soderberg 6efb1a4afb replace if [ ... ] with if [[ ... ]]
Bash implements a backwards-compatible sh syntax for [ .. ], which
handles undef variables poorly. Use [[ .. ]] instead, to take full
advantage of the Bash improvements to the comparison brackets.
2015-09-03 05:51:57 -07:00
Richard Soderberg 5fa972c534 enable curves by default 2015-09-02 21:11:25 -07:00
Julien Vehent 5f43f911bd Merge pull request #70 from tomato42/python3-analyze-fix
fix analyze.py Python3 compatibility
2015-08-23 15:23:45 -04:00
Hubert Kario a3e04d3d01 fix analyze.py Python3 compat
because subprocess returns `bytes` in Python 3
we need to interpret them to characters, which are needed by json
input and string parsing

fixes #69, #71
2015-08-23 17:31:04 +02:00
Matúš Honěk c9529b5977 Fix: incorrect list + string concatenation (issue #64) 2015-08-14 16:55:54 +02:00
Julien Vehent db4b16e50c Merge pull request #60 from tomato42/tls-intolerancies
TLS intolerancies
2015-07-16 10:30:27 -04:00
Hubert Kario abe8d329a9 Big handshake intolerance report 2015-07-16 16:15:39 +02:00
Hubert Kario 5f5487307d Interpret some intolerance test results 2015-07-16 16:15:39 +02:00
Hubert Kario 5c98fe2107 do a scan with -no_tlsext openssl if possible 2015-07-16 16:15:39 +02:00
Hubert Kario a71bfe5ebd detect some TLS intolerancies
buggy servers may choke on large ClientHello's, TLSv1.2 ClientHello's,
etc. try to detect such failures and report them

among tried connections are TLS1.2, TLS1.1, TLS1.0 and SSLv3 with
ability to downgrade to lower protocol versions as well as a size
limited client hello, both TLS1.2 and TLS1.0 version
2015-07-16 16:15:39 +02:00
Julien Vehent 0ab0575274 Merge pull request #58 from tomato42/fallback-scan
Fallback scan
2015-07-15 10:21:47 -04:00
Julien Vehent 0119b9c115 Merge pull request #59 from tomato42/parsing-fixes
Fixes for results parsing
2015-06-10 07:33:17 +02:00
Julien Vehent 90ed0bbb3e Merge pull request #62 from tomato42/python3
Python 3 compatibility
2015-06-10 07:00:21 +02:00
Julien Vehent 19983c0c2b Merge pull request #61 from tomato42/gost-support
GOST support
2015-06-10 06:39:37 +02:00
Hubert Kario 86bc8e8574 fix is_fubar key size check 2015-05-30 19:48:56 +02:00
Hubert Kario a53a91695e make scripts python 3 compatible 2015-05-30 15:46:26 +02:00
Hubert Kario 8ea6b57f9d cipherscan - capture whole Signature Algorithm line
the GOST certificates have a signature algorithm name with spaces
2015-05-30 14:58:23 +02:00
Hubert Kario d151705218 parse_results.py - GOST support 2015-05-30 14:58:23 +02:00