Last active
February 22, 2020 10:26
-
-
Save mosajjal/d151d8270d328877b76c624b0df3f9be to your computer and use it in GitHub Desktop.
CertSpotter -- Certificate Transparency Monitor by SSLMate Bash client with curl and jq
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
#!/usr/bin/env bash | |
#title :sslmate.sh | |
#description :This script will look for transparency logs and shows the JSON output | |
#author :Ali Mosajjal | |
#date :20200222 | |
#version :0.1 | |
#usage :bash sslmate.sh --domain YOURDOMA.IN --apikey APIKEY_FROM_SSLMATE --subdomains true/false | |
#notes :Install curl and jq to use this script. | |
#bash_version :5.0.16(1)-release | |
#api documents :https://sslmate.com/certspotter/api/docs-v1 | |
#============================================================================== | |
LINE=$(printf '%0.s=' $(seq 1 ${COLUMNS:-$(tput cols)})) | |
BLD="\e[1m" #Bold | |
BLK="\e[5m" #Blink | |
YLW="\e[33m" #Yellow Text | |
GRN="\e[32m" #Green Text | |
RED="\e[31m" #Red Text | |
YLWBG="\e[43m" #Yellow Background | |
GRNBG="\e[42m" #Green Background | |
REDBG="\e[41m" #Red Background | |
E="\e[0m" #Erase all attributes | |
echo -e "Here's how you parse arguments\n" | |
usage() { | |
echo -e "--domain example.com\t\t scans for domain" | |
echo -e "--apikey ***\t\t\t API key for certspotter" | |
echo -e "--subdomains true/false\t\t Include subdomains in search (or not)" | |
echo -e "--yes true\t\t\t says yes to any question automatically" | |
exit 0 | |
} | |
POSITIONAL=() | |
while [[ $# -gt 0 ]] | |
do | |
key="$1" | |
case $key in | |
-d|--domain) | |
domain=$2 | |
shift # past argument | |
shift # past value | |
;; | |
-a|--apikey) | |
apikey=$2 | |
shift # past argument | |
shift # past value | |
;; | |
-s|--subdomains) | |
subdomains=$2 | |
shift # past argument | |
shift # past value | |
;; | |
--yes) | |
yes=0 | |
shift # past argument | |
;; | |
*) # unknown option | |
POSITIONAL+=("$1") # save it in an array for later | |
usage | |
shift # past argument | |
;; | |
esac | |
done | |
set -- "${POSITIONAL[@]}" # restore positional parameters | |
if [ -z $apikey ] | |
then | |
echo here | |
usage | |
fi | |
echo -e $GRN$LINE$E | |
echo -e "Scanning CTL for domain $domain with subdomain scanning set to $subdomains" | |
c=0 | |
if y==0 | |
then | |
read -p "Do you wish to continue? " -n 1 -r | |
if [[ $REPLY =~ ^[Yy]$ ]] | |
then | |
c=1 | |
fi | |
else | |
c=1 | |
fi | |
echo | |
echo -e $GRN$LINE$E | |
if (($c==0)) | |
then | |
exit | |
fi | |
curl -s -H "Authorization: Bearer $apikey" "https://api.certspotter.com/v1/issuances?include_subdomains=$subdomains&expand=issuer&expand=cert&expand=dns_names&dns_names=pubkey_sha256&domain=$domain" | jq . |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment