-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCertSub.sh
50 lines (44 loc) · 1.07 KB
/
CertSub.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
usage() {
echo -e "\033[1;34mCertSub v1.0 - written by the whalebone\033[0m"
echo -e "Usage: $0 [-u <domain>] [-f <file>]\n"
echo "Options:"
echo " -u <domain> Search for subdomains of a single domain."
echo " -f <file> Search for subdomains of domains listed in a
file (one domain per line)."
exit 1
}
if [ $# -eq 0 ]; then
usage
fi
while getopts ":u:f:" opt; do
case ${opt} in
u)
domain=$OPTARG
;;
f)
file=$OPTARG
;;
\?)
echo "Invalid option: -$OPTARG" >&2
usage
;;
:)
echo "Option -$OPTARG requires an argument." >&2
usage
;;
esac
done
if [ -z "$domain" ] && [ -z "$file" ]; then
usage
fi
get_subdomains() {
curl -s "https://crt.sh/?q=$1" | grep "<TD>" | grep "$1" | cut -d ">" -f 2 | cut -d "<" -f 1 | sort -u
}
if [ ! -z "$domain" ]; then
get_subdomains "$domain"
fi
if [ ! -z "$file" ]; then
while read -r line; do
get_subdomains "$line"
done < "$file"
fi