-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathspydomains
195 lines (159 loc) · 5.13 KB
/
spydomains
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#!/bin/bash
# copyright ©️ 2022 - Black Bug Group
# Author: Edgar Nyandoro - Github: Major2000
PROJDIR="$(dirname "$0")"
cd "${PROJDIR}" || return
# echo "Total arguments : $#"
# echo "1st Argument = $1"
# echo "2nd argument = $2"
# echo "3 argument = $3"
# echo "4 argument = $4"
# echo "5 argument = $5"
# echo "6 argument = $6"
# echo "7 argument = $7"
# echo "8 argument = $8"
# echo "9 argument = $9"
# Help function
Help()
{
# Display Help
echo
echo "Looks like you're lost, This HELP Message is enough for the guide!"
echo
echo "Syntax: spydomains -[options:|u, U|f, F|o, O|h, H] [args]"
echo
echo "options:"
echo " -u, -U Add the domain you want to brute force for subdomains."
echo " -f, -F Add a custom brute-force world list of domains"
echo " -o, -O Print to external file"
echo " -h, -H Print this Help."
echo
echo "Example: spydomains -u example.com -f wordlist.txt -o domains.txt - With word list"
echo "Example: spydomains -u example.com - without word list"
echo
}
############################################################
############################################################
# Main program #
############################################################
############################################################
# Set variables
upos=0; fpos=0; opos=0
file=$(wget -O- -q https://drive.google.com/file/d/1NQSNZLJVEOKZA_ka1ox9ygYLJi8UF7XE/view?usp=sharing)
###### Check and capture the arguments
if [[ -z "$1" || "$#" == 0 ]]; then
echo
echo "No option(s)!"
echo "Try -h option for HELP!"
exit
else
while getopts "hHu:U:o:O:f:F:" option; do
case $option in
h | H)
Help
exit
;;
u | U)
for i in $@; do
let "upos++"
# echo $i
# echo $upos
if [[ $i == "-u" || $i == "-U" ]]; then
let "upos++"
case $upos in
2) domain=$2;;
3) domain=$3;;
4) domain=$4;;
5) domain=$5;;
6) domain=$6;;
7) domain=$7;;
8) domain=$8;;
9) domain=$9;;
esac
fi
done
;;
f | F)
for i in $@; do
# echo $i
# echo $fpos
let "fpos++"
if [[ $i == "-f" || $i == "-F" ]]; then
let "fpos++"
case $fpos in
2) file=$2;;
3) file=$3;;
4) file=$4;;
5) file=$5;;
6) file=$6;;
7) file=$7;;
8) file=$8;;
9) file=$9;;
esac
fi
done
;;
o | O)
for i in $@; do
# echo $i
# echo $opos
let "opos++"
if [[ $i == "-o" || $i == "-O" ]]; then
let "opos++"
case $opos in
2) out=$2;;
3) out=$3;;
4) out=$4;;
5) out=$5;;
6) out=$6;;
7) out=$7;;
8) out=$8;;
9) out=$9;;
esac
fi
done
;;
*)
echo
echo "Invalid option(s)!"
echo "Try -h option for HELP!"
exit
;;
esac
done
# shift $(($OPTIND -1))
fi
##### Reccon starts here!
# read if output argument is availabe
if [[ $out ]]; then
touch $out
while read sub; do
if host "$sub.$domain" &> /dev/null; then
if [ -s $out ]; then
if ! grep -q "$sub.$domain" $out; then
echo "$sub.$domain" >> $out
fi
else
echo "$sub.$domain" >> $out
fi
fi
done < $file
echo
echo "Output exported to $out!"
else
# touch domains.txt
while read sub; do
if host "$sub.$domain" &> /dev/null; then
echo "$sub.$domain"
# if [ -s domains.txt ]; then
# if ! grep -q "$sub.$domain" domains.txt; then
# echo "$sub.$domain" >> domains.txt
# fi
# else
# echo "$sub.$domain" >> domains.txt
# fi
fi
done < $file
# echo
# echo "Saved to domains.txt!"
fi