-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSubChecker.sh
executable file
·127 lines (82 loc) · 3.77 KB
/
SubChecker.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/bin/bash
option=$1
domain=$2
#calculate the number of days remaining before the registry expiration date
function dayRemaining () {
whois $domain | grep "Registry Expiry Date" | cut -d'T' -f1 | cut -d':' -f2 | cut -d ' ' -f2 > tmp/expiration
expiration=`cat tmp/expiration`
string=`uname -s`
if [[ $string == *"Linux"* ]]; then
#Linux
date +"%y-%m-%d" > tmp/today
today=`cat tmp/today`
printf "Registry expiry date \e[1;29m $domain\e[0m : $(( ($(date -d $expiration +%s) - $(date -d $today +%s)) / 86400 )) days left\n"
else
#OSX/BSD
#date +"%y-%m-%d" > tmp/today
#today=`cat tmp/today`
#printf "Registry expiry date \e[1;29m $domain\e[0m : $(( ($(date -d $expiration +%s) - $(date -d $today +%s)) / 86400 )) days left\n"
printf "If OSX works for you, then use it.\U1F4B0\n"
fi
}
# parsing crt.sh and enumerate subdomains + check status web server
function parsingHTML () {
curl --silent "https://crt.sh/?q=$domain" | grep "<TD>" | grep -v white-space | cut -d ">" -f2 | cut -d "<" -f1 |sort -u | grep -v -e '*' -e '@' | grep $domain | xargs -I {} ./check_status.sh {}
}
# Using api virustotal
function apiVirusTotal () {
apikey=`cat apikey.txt`
wget -q -O - https://www.virustotal.com/vtapi/v2/domain/report\?apikey\=$apikey\&domain\=$domain |grep -o "\b\w*\.$domain\b" > tmp/subdomainVirusTotal.txt
printf "$domain\n$(cat tmp/subdomainVirusTotal.txt)" | sort -u | xargs -I {} ./check_status.sh {}
}
# banner
function banner () {
echo " _____ _ _____ _ _ "
echo " / ____| | | / ____| | | | "
echo " | (___ _ _| |__ | | | |__ ___ ___| | _____ _ __ "
echo " \___ \| | | | '_ \| | | '_ \ / _ \/ __| |/ / _ \ '__| "
echo " ____) | |_| | |_) | |____| | | | __/ (__| < __/ | "
echo " |_____/ \__,_|_.__/ \_____|_| |_|\___|\___|_|\_\___|_| "
echo " __ ___ "
echo " |__) \ / |__| /\ |__ \_/ "
echo " |__) | | | /~~\ | / \ "
printf "\n"
}
#check wildcard DNS
function wildcardcheck () {
#generate random string
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1 | awk '{print $0"."}' > tmp/randomsub
subgen=`host $(cat tmp/randomsub)$domain`
if [[ $subgen == *"has address"* ]]; then
echo "checking for DNS wildcard : YES "
else
echo "checking for DNS wildcard : NO"
fi
}
#------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
banner
if [[ $option = "--EXT" ]]; then
printf "\e[1;31mYou are going to check the domain with an external website. (https://crt.sh) \e[0m\n\n"
dayRemaining "$domain"
# draw a horizontal line
#printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' -
printf '%80s\n' | tr ' ' -
wildcardcheck
printf '%80s\n' | tr ' ' -
parsingHTML $domain
#--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
elif [[ $option = "--API" ]]; then
printf "\e[1;31mYou are going to check the domain with the VirusTotal API. \nPlease make sur you have copy your own api key in \"apikey.txt\" \e[0m\n\n"
dayRemaining "$domain"
# draw a horizontal line
#printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' -
printf '%80s\n' | tr ' ' -
wildcardcheck
printf '%80s\n' | tr ' ' -
apiVirusTotal "$domain"
#----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
else
printf "Please choose an option (--EXT or --API)\n"
printf "example : ./SubChecker.sh --EXT github.com"
printf "example : ./SubChecker.sh --API github.com"
fi