etc~ scripts and random things |
| git clone https://github.com/djnnvx/etc.git |
| log | files | refs | archive |
crt.sh (727B)
1 #!/usr/bin/env bash 2 3 # little wrapper to query crt.sh service and retrieve a list of domain names 4 # usage: 5 # crt.sh djnn.sh 6 7 set -euo pipefail 8 9 10 check_installed () { 11 # check if dependencies are installed 12 for i in "${@}"; do 13 which "${i}" >/dev/null || { echo "[!] error: please install ${1}." && exit 1 ; } 14 done 15 } 16 17 18 check_installed jq curl sed sort uniq 19 20 [ "${#}" -eq 0 ] && { echo "[!] one argument is required" && head -n 5 ${0} && exit 1 ; } 21 22 search="$(curl -s "https://crt.sh?q=${1}&output=json")" 23 24 echo "${search}" | jq ".[].common_name,.[].name_value" | \ 25 cut -d'"' -f2 | sed 's/\\n/\n/g' | sed 's/\*.//g' | \ 26 sed -r 's/([A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4})//g' | \ 27 sort | uniq