Commit Graph

4009 Commits

Author SHA1 Message Date
David Cooper 603f03e79a Remove tmp.json files after use
Remove tmp.json files after use so that testssl.sh doesn't complain that they already exist.
2017-03-29 11:43:03 -04:00
David Cooper 1723374511 Remove tmp.file files after use
Remove tmp.json files are use so that testssl.sh doesn't complain that they already exist.
2017-03-29 11:42:09 -04:00
David Cooper e7c0ca13f6 Remove tmp.json files after use
Remove tmp.json files are use so that testssl.sh doesn't complain that they already exist.
2017-03-29 11:41:23 -04:00
David Cooper 04f86f9469 Fix indentation of JSON pretty banner 2017-03-29 11:22:29 -04:00
David Cooper 86c81f2276 Use CHILD_MASS_TESTING environment variable
This PR introduces the environment variable `CHILD_MASS_TESTING`, and uses it as an indicator that testssl.sh is running as a child within mass testing rather than using the `$APPEND` flag. It also makes a number of other changes to make the handling, of HTML, CSV, JSON, and log files consistent, and it fixes a number of bugs related to the generation of these files when mass testing is being performed.

Please let me know if you disagree with any of the changes in this PR, or if you would prefer that it be broken up into multiple smaller PRs.

Some of the changes are as follows:
- When the `$APPEND` flag is true, all of these files are appended to and headers and footers are omitted. (Perhaps this should be changed. Appending to a log file isn't an issue, but appending to a JSON or HTML file without including headers or footers seems to just create an improperly formatted file).
- Following the code in `prepare_logging()`, an error is printed and the program stops if the `$APPEND` flag is false and one of the files to be written to already exists.

Some of the bugs fixed:

Creating log files did not work with mass testing:
- If `--logfile <logfile>` is used, then the parent and each child try to write to "logfile".
- If `--logging` is used, then a log file is created for each child, but an oddly-named log file is also created for the parent. The one created by the parent contains the entire output.

Plain JSON files:
- When `--jsonfile <jsonfile>` is run, there is no comma separating the final finding for one child and the first finding for the next child.

Pretty JSON files:
- When `--jsonfile-pretty <jsonfile>` is called without mass testing, the "target host" line is empty, since `$NODE` has not yet been set.
- When `--jsonfile <jsonfile>` is run with mass testing, there is no comma separating the final finding for one child and the first finding for the next child. In addition, `fileout_pretty_json_banner()` is never called, and the entries for individual tests have insufficient information to determine what is being tested (it lists "service" and "ip", but not port number).

For the final issue, when mass testing is being performed and all output is being placed in a single file, I have the parent call `fileout_pretty_json_banner()`, but tell `fileout_pretty_json_banner()` to not include a "target host" or "port", but then have each child include a "target host" or "port" (when the "service" and "ip" are being printed).
2017-03-29 11:16:09 -04:00
David Cooper 312598837f Merge branch '2.9dev' into openssl_location 2017-03-29 09:01:38 -04:00
Dirk 7953bfda5e correct DEBUGTIME 2017-03-29 11:17:24 +02:00
Dirk 05ea5675b8 one line per variable type 2017-03-29 10:44:22 +02:00
Dirk Wetter 2f8bc2e77a Merge pull request #686 from dcooper16/out_row_aligned_max_width
out_row_aligned_max_width()
2017-03-29 10:39:04 +02:00
David Cooper 227a31b788 out_row_aligned_max_width()
This PR improves `out_row_aligned_max_width()` in a few ways:

* It makes better use of bash's string manipulation capabilities in order to simplify the function.

* It improves the function's performance. One of the most costly parts of `out_row_aligned_max_width()` was the while loop to print each entry in the text. Since there is only one place in the code where the the entries are not all printed the same ways (the list of supported curves printed by `run_pfs()`), the PR changes `out_row_aligned_max_width()` to just return a plain text string, which the calling function prints in the appropriate way. For the curves printed by `run_pfs()`, a new function, `out_row_aligned_max_width_by_entry()` takes care of getting the output from `out_row_aligned_max_width()` and then printing each entry appropriately.

* The PR also introduces a trick so that when the TLS extensions are printed, the text for an extension won't get split across two rows. It does this by replacing the space charters within the text for an extension with "}", formatting the result with `out_row_aligned_max_width()`, and then converting the "}" back to space characters.
2017-03-28 13:54:54 -04:00
David Cooper 572d081882 Merge branch '2.9dev' into openssl_location 2017-03-28 08:54:52 -04:00
Dirk 53de1dc7c4 clarified help() 2017-03-28 12:07:45 +02:00
David Cooper 6ca55014ed Merge branch '2.9dev' into openssl_location 2017-03-27 15:58:43 -04:00
Dirk e2d5dc7778 part 2/2: fix for #653 2017-03-27 21:31:54 +02:00
David Cooper eca636f284 Merge branch '2.9dev' into openssl_location 2017-03-27 15:22:18 -04:00
Dirk Wetter 7df453c7f3 Merge pull request #683 from dcooper16/missing_html_banner
Missing HTML banner
2017-03-27 21:12:35 +02:00
David Cooper 3b7264ff1f Populate OPENSSL_LOCATION in find_openssl_binary
`$OPENSSL_LOCATION` is used in `fileout_pretty_json_banner()`, `html_banner()`, `mybanner()`, and `prepare_logging()`, but the value of `$OPENSSL_LOCATION` is populated in `mybanner()`. This is usually okay, since `mybanner()` is always called before the other three functions are called. However, if `$QUIET` is `true`, then `mybanner()` returns immediately, without populating `$OPENSSL_LOCATION`, even though the value of `$OPENSSL_LOCATION` may be needed by one or more of the other functions.

This PR addresses this problem by populating `$OPENSSL_LOCATION` in `find_openssl_binary()` rather than `mybanner()`.
2017-03-27 14:54:47 -04:00
David Cooper 684c231dcd Merge branch '2.9dev' into missing_html_banner 2017-03-27 12:36:14 -04:00
Dirk 38cf16854d FIX #682 2017-03-27 17:35:45 +02:00
David Cooper d629cbcc28 Missing HTML banner
With the commit made on March 26, "partly (1/2) fixing #653," an HTML banner isn't added to the HTML files anymore.  A banner should be added to the top of the HTML file if mass testing is being performed and a separate HTML file is being created for each test.

The `$APPEND` flag being `true` is an indicator that mass testing is being performed and that this is one of the individual tests being run. Given that `$APPEND` is `true`, `$HTMLHEADER` being `true` indicates that testssl.sh is creating the file name for the HTML output. So, it is when both flags are `true` that the HTML banner should be created.
2017-03-27 10:52:24 -04:00
Dirk bcc597dbab clarify help #680 2017-03-27 11:37:18 +02:00
Dirk c0af8b113f FIX #680 2017-03-27 11:29:21 +02:00
Dirk 7543aa30fb make travis mute again / introduce DEBUG_ALLINONE to use script for debug output all in one file 2017-03-27 08:59:29 +02:00
Dirk 9f1877b192 save work (still double footer, see #653) 2017-03-27 00:54:38 +02:00
Dirk a8b2dfec40 allow '=' after --htmlfile 2017-03-27 00:34:42 +02:00
Dirk 13ba1ce966 partly (1/2) fixing #653 2017-03-27 00:30:42 +02:00
Dirk c281956f6e ifix xtrace 2017-03-26 19:34:02 +02:00
Dirk e268a1564a * include runtime per default in "Done" banner
* enable better performance analysis
* minor polish
2017-03-25 19:37:30 +01:00
Dirk 10bbbd9334 minor cleanups 2017-03-25 13:23:21 +01:00
Dirk Wetter 039b293790 Merge pull request #679 from dcooper16/std_cipherlists_debug
Fix std_cipherlists with debug
2017-03-25 12:36:46 +01:00
Dirk 4ae1597b2b FIX #543 2017-03-25 12:26:08 +01:00
David Cooper 8d60e87040 Fix std_cipherlists with debug
`std_cipherlists()` does not include line breaks between tests in the output to the terminal when `$DEBUG` is 1, and it does not include line break between tests in the HTML output whenever `$DEBUG` is greater than 0.
2017-03-24 16:45:39 -04:00
Dirk Wetter edaffc85ec Merge pull request #674 from dcooper16/fix_client_simulation
Fix client simulation
2017-03-24 18:45:40 +01:00
David Cooper 9a86825ec2 Fix client simulation
In `create_client_simulation_tls_clienthello()` the variable `sni_extension_found` should be set if the ClientHello includes an SNI extension. Instead it was being set if and only if the ClientHello included some extension other than SNI.

This bug wasn't detected before for two reasons:

* It is rare to have a ClientHello that includes an SNI extension, but no other extensions.

* The code still works correctly if `sni_extension_found` is set even if there is no SNI in the ClientHello.

So, the bug only creates a problem if the browser's ClientHello include an SNI extension and no other extensions (see "BingPreview Jun 2014" in the client_simulation branch).
2017-03-24 11:37:06 -04:00
Dirk Wetter 3514c9d98d Merge pull request #672 from dcooper16/minor_bugs
Fix two minor bugs
2017-03-24 08:00:33 +01:00
Dirk Wetter 3879338040 Merge pull request #670 from dcooper16/client_sim_name_printing
Use printf to print browser names
2017-03-24 07:52:54 +01:00
David Cooper 3a2dd3e6d1 Fixing a third minor bug
When HTML output is not being created, the print functions last step is to call `html_out()`, which responds to `return` rather than `return 0`. This causes problems for lines of code that rely on receiving a return value of 0. For example:
```
[[ $VULN_COUNT -le $VULN_THRESHLD ]] && outln && pr_headlineln " Testing for LUCKY13 vulnerability " && outln
```
2017-03-23 16:43:04 -04:00
David Cooper 7f64170402 Fix two minor bugs
This PR fixes two minor bugs:

* In `run_hpkp()`, the call to `$OPENSSL s_client` includes the option `-showcerts` twice. This PR removes one of them.

* In `get_server_certificate()`, the first call to `$OPENSSL s_client` includes `$addcmd`, but `$addcmd` has not yet been initialized. Instead, `$SNI` should be used.
2017-03-23 16:19:21 -04:00
David Cooper 005fe3f27e Remove unnecessary spaces 2017-03-23 14:15:26 -04:00
David Cooper 13f42774ae Use printf to print browser names 2017-03-23 14:13:47 -04:00
Dirk d5bb4edd80 * FIX #654 (no logfile when -file is specified)
* filename has now instead of just the number p+#
* minor polishing
2017-03-23 16:36:29 +01:00
Dirk Wetter 0d511e40e4 Merge pull request #669 from dcooper16/extract_tls_extensions
Cleanup extraction of TLS extensions
2017-03-23 08:56:13 +01:00
David Cooper 63d02688bc Fix typo 2017-03-22 15:21:22 -04:00
David Cooper 9ad1492236 Cleanup extraction of TLS extensions
Currently there is code to extract TLS extensions in three places, in `get_server_certificate()` and two places in `determine_tls_extensions()`. This PR replaces them with one new function, `extract_new_tls_extensions()`.

In order for the new function to work correctly whether OpenSSL or `tls_sockets()` is being used, this PR also changes `parse_tls_serverhello()` so that extensions are formatted in the file it creates in the same way as they are formatted by OpenSSL.
2017-03-22 15:18:38 -04:00
Dirk 43463da4fc improvements for performance measurements (small solution)
- in gerneral better performance measurements , starts from the real beginning (almost)
- allows results to put into file (MEASURE_TIME_FILE=google.txt testssl.sh google.com)
2017-03-22 16:02:48 +01:00
Dirk 27d0570fb5 - changed performance debugging options (small solution) so that the last delta is being shown
- PS4 improved: has now a performance debugging options (big solution)
- PS4 with proper alignment
- SCAN_TIME is now global so that it can be used not only by JSON-PRETTY (small performance debugging options uses it)
- prepare_debug() has now debugging stuff only, rest went to prepare_arrays()
2017-03-21 12:44:03 +01:00
Dirk 8c0b0083d0 further separation of data / code 2017-03-21 09:15:30 +01:00
Dirk 273361fbb9 raw time assements via env var MEASURE_TIME=true 2017-03-20 22:53:18 +01:00
Dirk 60a8e0a190 monor resorting and cosmetic improvements 2017-03-19 09:47:49 +01:00
Dirk bb5b778ee1 update/resort 2017-03-19 09:36:19 +01:00