-
-
Save visar/905082e57b780c7344c7 to your computer and use it in GitHub Desktop.
cgi bin script to check ssl domains for expiry - https://damjan.softver.org.mk/cgi-bin/ssl.sh
This file contains hidden or 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 | |
set -x | |
WARNDAYS=30 | |
PANICDAYS=6 | |
DOMAIN_LIST_URL=https://raw.githubusercontent.com/skopjehacklab/dns-zone-files/master/ssl/list_of_ssl_enabled_domains.txt | |
WARNSECONDS=$(($WARNDAYS * 24 * 60 * 60)) | |
PANICSECONDS=$(($PANICDAYS * 24 * 60 * 60)) | |
PANIC () { | |
echo "<div style='color:red' data-index=$3>" | |
echo "✗ $1 expires in $3 days ($2)" | |
echo "</div>" | |
} | |
WARN () { | |
echo "<div style='color:rgb(255,128,0)' data-index=$3>" | |
echo "⚠ $1 expires in $3 days ($2)" | |
echo "</div>" | |
} | |
INFO () { | |
echo "<div title='Expires in $3 days on $2' data-index=$3>" | |
echo "✓ $1" | |
echo "</div>" | |
} | |
exec 2>/dev/null | |
echo 'Content-Type: text/html' | |
echo | |
echo '<body style="font-family:monospace; font-size:2em">' | |
curl "$DOMAIN_LIST_URL" | | |
egrep -v '^#' | egrep -v '^[[:space:]]*$' | | |
while read domain | |
do | |
cert=`openssl s_client -servername "$domain" -connect "$domain":443 < /dev/null` | |
enddate=`echo "$cert" | openssl x509 -noout -enddate | cut -f2 -d=` | |
now=`date +%s` | |
cert_expires_formated=`date --date="$enddate" +%s` | |
expires_days=$((($cert_expires_formated - $now)/60/60/24)) | |
if ! echo "$cert" | openssl x509 -noout -checkend $PANICSECONDS; then | |
PANIC "$domain" "$enddate" "$expires_days" | |
elif ! echo "$cert" | openssl x509 -noout -checkend $WARNSECONDS; then | |
WARN "$domain" "$enddate" "$expires_days" | |
else | |
INFO "$domain" "$enddate" "$expires_days" | |
fi | |
done | |
echo '</body>' |
This file contains hidden or 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
// inject jquery | |
var s = document.createElement('script') | |
s.setAttribute('src', '//code.jquery.com/jquery.min.js') | |
s.addEventListener('load', function () { | |
sort() | |
}, false) | |
document.head.appendChild(s) | |
function sort() { | |
$(function () { | |
$('body>div').sort(function (a, b) { | |
return + a.dataset.index - + b.dataset.index | |
}).appendTo($('body')) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment