2019-05-03 19:27:31 +02:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
|
|
|
|
# Just a functional test, whether there are any problems on the client side
|
2019-05-06 14:07:08 +02:00
|
|
|
# Probably we could also inspect the JSON for any problems for
|
2019-05-03 19:27:31 +02:00
|
|
|
# "id" : "scanProblem"
|
|
|
|
# "finding" : "Scan interrupted"
|
|
|
|
|
2019-05-03 20:08:31 +02:00
|
|
|
# Catches:
|
|
|
|
# - This unit test takes very long
|
|
|
|
# - Hosts which match the regex patterns should be avoided
|
|
|
|
|
2019-05-03 19:27:31 +02:00
|
|
|
use strict;
|
|
|
|
use Test::More;
|
|
|
|
use Data::Dumper;
|
2019-05-06 14:07:08 +02:00
|
|
|
# use JSON;
|
|
|
|
# if we need JSON we need to comment this and the lines below in
|
2019-05-03 19:27:31 +02:00
|
|
|
|
|
|
|
my $tests = 0;
|
2019-05-06 14:07:08 +02:00
|
|
|
my $prg="./testssl.sh";
|
2020-11-27 13:19:52 +01:00
|
|
|
my $check2run_smtp="--protocols --standard --fs --server-preference --headers --vulnerable -q --ip=one --color 0";
|
2019-05-03 19:27:31 +02:00
|
|
|
my $check2run="-q --ip=one --color 0";
|
|
|
|
my $uri="";
|
2019-05-06 14:07:08 +02:00
|
|
|
my $socket_out="";
|
|
|
|
my $openssl_out="";
|
|
|
|
# Blacklists we use to trigger an error:
|
2020-11-26 13:41:44 +01:00
|
|
|
my $socket_regex_bl='(e|E)rror|\.\/testssl\.sh: line |(f|F)atal|(c|C)ommand not found';
|
|
|
|
my $openssl_regex_bl='(e|E)rror|(f|F)atal|\.\/testssl\.sh: line |Oops|s_client connect problem|(c|C)ommand not found';
|
2019-05-06 14:07:08 +02:00
|
|
|
|
|
|
|
# my $socket_json="";
|
|
|
|
# my $openssl_json="";
|
2019-05-03 19:27:31 +02:00
|
|
|
# $check2run_smtp="--jsonfile tmp.json $check2run_smtp";
|
|
|
|
# $check2run="--jsonfile tmp.json $check2run";
|
|
|
|
|
2019-05-06 14:07:08 +02:00
|
|
|
die "Unable to open $prg" unless -f $prg;
|
|
|
|
|
2019-05-03 19:27:31 +02:00
|
|
|
$uri="smtp-relay.gmail.com:587";
|
|
|
|
|
|
|
|
# we will have client simulations later, so we don't need to run everything again:
|
2019-05-06 14:07:08 +02:00
|
|
|
# unlink "tmp.json";
|
2019-05-03 19:27:31 +02:00
|
|
|
printf "\n%s\n", "STARTTLS SMTP unit test via sockets --> $uri ...";
|
2019-05-06 14:07:08 +02:00
|
|
|
$socket_out = `./testssl.sh $check2run_smtp -t smtp $uri 2>&1`;
|
|
|
|
# $socket_json = json('tmp.json');
|
|
|
|
unlike($socket_out, qr/$socket_regex_bl/, "");
|
2019-05-03 19:27:31 +02:00
|
|
|
$tests++;
|
|
|
|
|
2019-05-06 14:07:08 +02:00
|
|
|
# unlink "tmp.json";
|
2019-05-03 19:27:31 +02:00
|
|
|
printf "\n%s\n", "STARTTLS SMTP unit tests via OpenSSL --> $uri ...";
|
2019-05-06 14:07:08 +02:00
|
|
|
$openssl_out = `./testssl.sh --ssl-native $check2run_smtp -t smtp $uri 2>&1`;
|
|
|
|
# $openssl_json = json('tmp.json');
|
|
|
|
unlike($openssl_out, qr/$openssl_regex_bl/, "");
|
2019-05-03 19:27:31 +02:00
|
|
|
$tests++;
|
|
|
|
|
|
|
|
|
|
|
|
$uri="pop.gmx.net:110";
|
|
|
|
|
2019-05-06 14:07:08 +02:00
|
|
|
# unlink "tmp.json";
|
2019-05-03 19:32:25 +02:00
|
|
|
printf "\n%s\n", "STARTTLS POP3 unit tests via sockets --> $uri ...";
|
2019-05-06 14:07:08 +02:00
|
|
|
$socket_out = `./testssl.sh $check2run -t pop3 $uri 2>&1`;
|
|
|
|
# $socket_json = json('tmp.json');
|
|
|
|
unlike($socket_out, qr/$socket_regex_bl/, "");
|
2019-05-03 19:27:31 +02:00
|
|
|
$tests++;
|
|
|
|
|
2020-11-27 13:19:52 +01:00
|
|
|
# commented out, bc of travis' limits
|
|
|
|
#
|
|
|
|
#printf "\n%s\n", "STARTTLS POP3 unit tests via OpenSSL --> $uri ...";
|
2019-05-06 14:07:08 +02:00
|
|
|
# unlink "tmp.json";
|
2020-11-27 13:19:52 +01:00
|
|
|
#$openssl_out = `./testssl.sh --ssl-native $check2run -t pop3 $uri 2>&1`;
|
2019-05-06 14:07:08 +02:00
|
|
|
# $openssl_json = json('tmp.json');
|
2020-11-27 13:19:52 +01:00
|
|
|
#unlike($openssl_out, qr/$openssl_regex_bl/, "");
|
|
|
|
#$tests++;
|
2019-05-03 19:27:31 +02:00
|
|
|
|
|
|
|
|
|
|
|
$uri="imap.gmx.net:143";
|
|
|
|
|
2019-05-06 14:07:08 +02:00
|
|
|
# unlink "tmp.json";
|
2019-05-03 19:27:31 +02:00
|
|
|
printf "\n%s\n", "STARTTLS IMAP unit tests via sockets --> $uri ...";
|
2019-05-06 14:07:08 +02:00
|
|
|
$socket_out = `./testssl.sh $check2run -t imap $uri 2>&1`;
|
|
|
|
# $socket_json = json('tmp.json');
|
|
|
|
unlike($socket_out, qr/$socket_regex_bl/, "");
|
2019-05-03 19:27:31 +02:00
|
|
|
$tests++;
|
|
|
|
|
|
|
|
printf "\n%s\n", "STARTTLS IMAP unit tests via OpenSSL --> $uri ...";
|
2019-05-06 14:07:08 +02:00
|
|
|
$openssl_out = `./testssl.sh --ssl-native $check2run -t imap $uri 2>&1`;
|
|
|
|
# $openssl_json = json('tmp.json');
|
|
|
|
unlike($openssl_out, qr/$openssl_regex_bl/, "");
|
2019-05-03 19:27:31 +02:00
|
|
|
$tests++;
|
|
|
|
|
|
|
|
|
|
|
|
$uri="jabber.org:5222";
|
|
|
|
|
2019-05-06 14:07:08 +02:00
|
|
|
# unlink "tmp.json";
|
2019-05-03 19:27:31 +02:00
|
|
|
printf "\n%s\n", "STARTTLS XMPP unit tests via sockets --> $uri ...";
|
2019-05-06 14:07:08 +02:00
|
|
|
$socket_out = `./testssl.sh $check2run -t xmpp $uri 2>&1`;
|
|
|
|
# $socket_json = json('tmp.json');
|
|
|
|
unlike($openssl_out, qr/$openssl_regex_bl/, "");
|
2019-05-03 19:27:31 +02:00
|
|
|
$tests++;
|
|
|
|
|
2020-11-27 13:19:52 +01:00
|
|
|
# commented out, bc of travis' limits
|
|
|
|
#
|
|
|
|
#printf "\n%s\n", "STARTTLS XMPP unit tests via OpenSSL --> $uri ...";
|
|
|
|
#$openssl_out = `./testssl.sh --ssl-native $check2run -t xmpp $uri 2>&1`;
|
2019-05-06 14:07:08 +02:00
|
|
|
# $openssl_json = json('tmp.json');
|
2020-11-27 13:19:52 +01:00
|
|
|
#unlike($openssl_out, qr/$openssl_regex_bl/, "");
|
|
|
|
#$tests++;
|
2019-05-03 19:27:31 +02:00
|
|
|
|
2020-05-02 19:40:45 +02:00
|
|
|
# $uri="jabber.ccc.de:5269";
|
|
|
|
# printf "\n%s\n", "Quick STARTTLS XMPP S2S unit tests via sockets --> $uri ...";
|
|
|
|
# $openssl_out = `./testssl.sh --openssl=/usr/bin/openssl -p $check2run -t xmpp-server $uri 2>&1`;
|
|
|
|
# # $openssl_json = json('tmp.json');
|
|
|
|
# unlike($openssl_out, qr/$openssl_regex_bl/, "");
|
|
|
|
# $tests++;
|
2020-05-01 18:39:36 +02:00
|
|
|
|
2019-05-03 19:27:31 +02:00
|
|
|
|
|
|
|
$uri="ldap.uni-rostock.de:21";
|
|
|
|
|
2019-05-06 14:07:08 +02:00
|
|
|
# unlink "tmp.json";
|
2019-05-03 19:27:31 +02:00
|
|
|
printf "\n%s\n", "STARTTLS FTP unit tests via sockets --> $uri ...";
|
2019-05-06 14:07:08 +02:00
|
|
|
$socket_out = `./testssl.sh $check2run -t ftp $uri 2>&1`;
|
|
|
|
# $socket_json = json('tmp.json');
|
2019-05-03 20:08:31 +02:00
|
|
|
# OCSP stapling fails sometimes with: 'offered, error querying OCSP responder (ERROR: No Status found)'
|
2019-05-06 14:07:08 +02:00
|
|
|
$socket_out =~ s/ error querying OCSP responder .*\n//g;
|
|
|
|
unlike($socket_out, qr/$socket_regex_bl/, "");
|
2019-05-03 19:27:31 +02:00
|
|
|
$tests++;
|
|
|
|
|
2020-11-27 13:19:52 +01:00
|
|
|
# commented out, bc of travis' limits
|
|
|
|
#
|
|
|
|
# printf "\n%s\n", "STARTTLS FTP unit tests via OpenSSL --> $uri ...";
|
|
|
|
# $openssl_out = `./testssl.sh --ssl-native $check2run -t ftp $uri 2>&1`;
|
2019-05-06 14:07:08 +02:00
|
|
|
# $openssl_json = json('tmp.json');
|
2019-05-03 20:46:06 +02:00
|
|
|
# OCSP stapling fails sometimes with: 'offered, error querying OCSP responder (ERROR: No Status found)'
|
2020-11-27 13:19:52 +01:00
|
|
|
# $openssl_out =~ s/ error querying OCSP responder .*\n//g;
|
|
|
|
# unlike($openssl_out, qr/$openssl_regex_bl/, "");
|
|
|
|
# $tests++;
|
2019-05-03 19:27:31 +02:00
|
|
|
|
|
|
|
|
|
|
|
# https://ldapwiki.com/wiki/Public%20LDAP%20Servers
|
2019-09-25 09:36:16 +02:00
|
|
|
$uri="db.debian.org:389";
|
2019-05-03 19:27:31 +02:00
|
|
|
|
|
|
|
printf "\n%s\n", "STARTTLS LDAP unit tests via OpenSSL --> $uri ...";
|
2019-05-06 14:07:08 +02:00
|
|
|
$openssl_out = `./testssl.sh --ssl-native $check2run -t ldap $uri 2>&1`;
|
|
|
|
# $openssl_json = json('tmp.json');
|
|
|
|
unlike($openssl_out, qr/$openssl_regex_bl/, "");
|
2019-05-03 19:27:31 +02:00
|
|
|
$tests++;
|
|
|
|
|
|
|
|
|
|
|
|
$uri="news.newsguy.com:119";
|
|
|
|
|
2019-05-06 14:07:08 +02:00
|
|
|
# unlink "tmp.json";
|
2019-05-03 19:27:31 +02:00
|
|
|
printf "\n%s\n", "STARTTLS NNTP unit tests via sockets --> $uri ...";
|
2019-05-06 14:07:08 +02:00
|
|
|
$socket_out = `./testssl.sh $check2run -t nntp $uri 2>&1`;
|
|
|
|
# $socket_json = json('tmp.json');
|
|
|
|
unlike($socket_out, qr/$socket_regex_bl/, "");
|
2019-05-03 19:27:31 +02:00
|
|
|
$tests++;
|
|
|
|
|
2020-11-27 13:19:52 +01:00
|
|
|
# commented out, bc of travis' limits
|
|
|
|
#
|
|
|
|
#printf "\n%s\n", "STARTTLS NNTP unit tests via OpenSSL --> $uri ...";
|
|
|
|
#$openssl_out = `./testssl.sh --ssl-native $check2run -t nntp $uri 2>&1`;
|
2019-05-06 14:07:08 +02:00
|
|
|
# $openssl_json = json('tmp.json');
|
2020-11-27 13:19:52 +01:00
|
|
|
#unlike($openssl_out, qr/$openssl_regex_bl/, "");
|
|
|
|
#$tests++;
|
2019-05-03 19:27:31 +02:00
|
|
|
|
|
|
|
|
|
|
|
# IRC: missing
|
|
|
|
# LTMP, mysql, postgres
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
done_testing($tests);
|
2019-05-06 14:07:08 +02:00
|
|
|
# unlink "tmp.json";
|
2019-05-03 19:27:31 +02:00
|
|
|
|
|
|
|
sub json($) {
|
|
|
|
my $file = shift;
|
|
|
|
$file = `cat $file`;
|
|
|
|
unlink $file;
|
|
|
|
return from_json($file);
|
|
|
|
}
|
|
|
|
|
2021-05-31 22:39:22 +02:00
|
|
|
|
|
|
|
# vim:ts=5:sw=5:expandtab
|
|
|
|
|