-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSSLCheck-smtp
executable file
·51 lines (46 loc) · 1.27 KB
/
SSLCheck-smtp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
# Hacked together by Mike Harris
# Vast majority of script stolen from sslthing.sh by [email protected]
#
openssl=/usr/bin/openssl
###### END OF CONFIGURATION #####
if [ ! $1 ]; then
echo "Syntax: $0 HOST:SSLPORT [-v]"
exit 1
fi
if [ ! -e $openssl ]; then
echo "Please correct path to OpenSSL $0"
exit 2
fi
#
## Create temp file to do some actions in
SSLCHECKTMP=$(mktemp /tmp/sslcheck.XXXXXXXXXXXX) || { echo "Failed to create temp file"; exit 1; }
## Make a request
echo "GET / HTTP/1.1" > $SSLCHECKTMP
## Request available ciphers from openssl and test them
for ssl in -ssl2 -ssl3 -tls1
do
echo "Testing `echo $ssl | cut -c2- | tr "a-z" "A-Z"`..."
$openssl ciphers $ssl -v | while read line
do
cipher=`echo $line | awk '{print $1}'`
bits=`echo $line | awk '{print $5}' | cut -f2 -d\( | cut -f1 -d\)`
if [ $2 ]; then
echo -n "$cipher - $bits bits..."
fi
if ($openssl s_client $ssl -starttls smtp -crlf -cipher $cipher -connect $1 < $SSLCHECKTMP 2>&1 | egrep ^New | egrep -v NONE > /dev/null); then
if [ $2 ]; then
echo "OK"
else
echo "$cipher - $bits bits"
fi
else
if [ $2 ]; then
echo "Failed"
fi
fi
done | grep -v error
done
## Remove temporary file
rm -f $SSLCHECKTMP
exit 0