Created
October 5, 2022 13:35
-
-
Save alecs/5085429f19fc6fbfe985378aabc57a84 to your computer and use it in GitHub Desktop.
ssl scanner
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
#!/usr/bin/awk -f | |
# | |
# Print validty of a cert from a nmap scan report | |
# | |
# Alex Negulescu | |
# | |
BEGIN { | |
nd=0 | |
start=0 | |
has_ssl=0 | |
} | |
{ | |
if ($0 ~ /Nmap scan report /) {host=$5" "$6} | |
if ($0 ~ /^[0-9]+\/tcp\s+open/) { start=NR; port[nd]=substr($0,0,index($0,"/")-1) } | |
if ($0 ~ /^\| ssl-cert:/ && NR == start+1) { has_ssl=1 } | |
if ($0 ~ /^\| Not valid after:/ && has_ssl == 1) { | |
if (match($0,/[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]/)) { | |
dates[nd]=substr($0,RSTART,RLENGTH) | |
let nd++ | |
has_ssl=0 | |
} | |
} | |
} | |
END { | |
for (key in dates) { | |
print host","port[key]","dates[key] } | |
} |
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 | |
[ -n "$1" ] || { echo "Need dns dump"; exit 1; } | |
awk '/IN\tA/ && ! /^@/ && ! /^\*/ { if ($NF ~ /[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/) { if (!map[$NF]++) { if ($1 !~ /__DOMAIN__\.com/) { print $1".__DOMAIN__.com" } else { print $1 } } } }' $1 | while read ipaddr; do | |
nmap --script ssl-cert $ipaddr -p 443,7666,8006,8443,8883 2>&1 | ./ssl_scanner.awk | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment