-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhttps-ciphers.sh
executable file
·31 lines (26 loc) · 967 Bytes
/
https-ciphers.sh
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
#!/bin/bash
if [ -z "${HOST}" ]; then
echo "Please enter hostname to scan, or press enter to scan localhost:"
read HOST
echo "Please enter port to scan, or press enter for default HTTPS/443:"
read PORT
fi
if [ -z "${HOST}" ]; then HOST=localhost; fi
if [ -z "${PORT}" ]; then PORT=443; fi
CIPHERS=`openssl ciphers`
VALID=":"
while [ -n "${CIPHERS}" ]; do
echo -e -n "Attempt #`echo ${VALID} | awk '-F:' 'END { print NF - 1 }'`\r"
PICK=`echo | openssl s_client -cipher ${CIPHERS} -connect ${HOST}:${PORT} 2> /dev/null | grep "Cipher :" | cut --delim=":" -f 2`
if [ -z "${PICK}" ]; then break; fi
VALID="${VALID}:${PICK}"
CIPHERS=`echo -n ${CIPHERS} | xargs -n 1 --delim=":" echo | grep -v ${PICK} | xargs echo | sed -e "s/ /:/g"`
done
BANNER="Supported ciphers for https://${HOST}"
if [ ${PORT} -ne 443 ]; then
BANNER="${BANNER}:${PORT}"
fi
BANNER="${BANNER} are:\n\t"
echo -n ${VALID} |
cut --delim=":" -f 3- |
xargs --delim=":" echo -e "${BANNER}"