Created
January 6, 2023 23:24
-
-
Save AlLongley/8be503d9794c9750b5447aa73427e2c3 to your computer and use it in GitHub Desktop.
Fast DNS subdomain SSL certificate lookup directly from CRT.SH database crt_sh_psql.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 | |
if [ "x$1" = "x" ]; | |
then echo "You need to specify an input file containing domain names to iterate over!";echo "Usage: $0 list_of_domain_names.txt" | |
exit; | |
fi | |
if ! [ -x "$(command -v psql)" ]; then | |
echo 'Error: psql is not installed.' >&2 | |
echo 'Try installing it: sudo apt install postgresql-client' >&2 | |
exit 1 | |
fi | |
filename=$1 | |
while read dns; do | |
echo $dns | |
echo "" | |
Q="select distinct(lower(name_value)) FROM certificate_and_identities cai WHERE plainto_tsquery('$dns') @@ identities(cai.CERTIFICATE) AND lower(cai.NAME_VALUE) LIKE ('%.$dns')" | |
psql -P pager=off -P footer=off -U guest -d certwatch --host crt.sh -c "$Q" | sed -e '$d' -e 's/^ //' -e '1,2d' | |
done < "$filename" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment