Last active
May 9, 2018 19:56
-
-
Save lxhunter/fd28cc73ee4727382d9b03d054ffb70a to your computer and use it in GitHub Desktop.
SSL Domain Checker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
output_file="shop.csv" | |
if [ ! -f $output_file ]; then | |
echo "domain,connection,status" >> "${output_file}" | |
fi | |
function domain_check_ssl { | |
RED="\033[1;31m" | |
GREEN="\033[1;32m" | |
YELLOW="\033[1;33m" | |
ORANGE="\033[1;36m" | |
NOCOLOR="\033[0m" | |
domain=$1 | |
output_file="shop.csv" | |
curl_opts="--max-time 5.5 --connect-timeout 5 --silent --head --location -w \"%{http_code}\" -o /dev/null --request GET" | |
if grep -q "^${domain}," $output_file; then | |
echo "${domain} already in ${output_file}" | |
else | |
status=$(curl $curl_opts --insecure "https://${domain}" | sed -e 's/"//g') | |
if [ "$status" = "000" ]; then | |
status=$(curl $curl_opts --insecure "https://www.${domain}" | sed -e 's/"//g') | |
if [ "$status" = "000" ]; then | |
status=$(curl $curl_opts "http://${domain}" | sed -e 's/"//g') | |
if [ "$status" = "000" ]; then | |
status=$(curl $curl_opts "http://www.${domain}" | sed -e 's/"//g') | |
if [ "$status" = "000" ]; then | |
transport="kaputt" | |
else | |
transport="http" | |
fi | |
else | |
transport="http" | |
fi | |
else | |
transport="https-invalid-cert" | |
fi | |
else | |
transport="https-invalid-cert" | |
secure_call=$(curl $curl_opts "https://${domain}" | sed -e 's/"//g') | |
if [ "$secure_call" -ne "000" ]; then | |
transport="https-valid-cert" | |
fi | |
fi | |
echo "${domain},${transport},${status}" >> "${output_file}" | |
case "$transport" in | |
"https-valid-cert") | |
echo -e "${GREEN}${domain}: https(${status}) with valid certificate ${NOCOLOR}" | |
;; | |
"https-invalid-cert") | |
echo -e "${YELLOW}${domain}: https(${status}) with invalid certificate ${NOCOLOR}" | |
;; | |
"http") | |
echo -e "${ORANGE}${domain}: ${transport}(${status})${NOCOLOR}" | |
;; | |
"kaputt") | |
echo -e "${RED}${domain}: cannot connect!${NOCOLOR}" | |
;; | |
esac | |
fi | |
} | |
export -f domain_check_ssl | |
sed -E 's/([a-z0-9|-]+\.*[a-z0-9|-]+\.[a-z]{1,})(\/.*)?/\1/g' shop.list | parallel --no-notice domain_check_ssl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Check a list of domains for ssl. It outputs a CSV and can be restarted. It will continue where it left off