-
Notifications
You must be signed in to change notification settings - Fork 3
/
hfuzz.sh
executable file
·222 lines (172 loc) · 6.83 KB
/
hfuzz.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
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
196
197
198
199
200
#!/bin/bash
red='\033[0;31m'
green='\033[0;32m'
yellow='\033[0;33m'
blue='\033[0;34m'
magenta='\033[0;35m'
cyan='\033[0;36m'
NC='\033[0m'
printf "
_ __
| |__ / _|_ _ ________
| '_ \| |_| | | |_ /_ /
| | | | _| |_| |/ / / /
|_| |_|_| \__,_/___/___|
${cyan}Developed by MHA & Meweez${NC}
${yellow}mha4065.com${NC}
"
usage() {
echo -e "${yellow}Usage:${NC} ./hfuzz.sh
[-d (domain just for append mode)]
[-s (For TLS (By default, the scheme is http) )] {-i|-I} [-w wordlist] [-S] [-t] [-m] [-f]
[-i (just a single IP -> 1.2.3.4)]
[-I (a list of IP -> ip.txt)]
[-w (a wordlist -> words.txt)]
[-S (a wordlist of subdomains -> subdomains.txt)]
[-t thread]
[-m match-codes]
[-f filter-codes]
" 1>&2;
exit 1;
}
ip=
protocol="http"
domain=
ips=
wordlist=
swordlist=
matchcode=" -mc "
filtercode=" -fc "
thread=" -t "
while getopts "h:d:i:I:w:t:m:f:S:s" o; do
case $o in
i)
ip=$OPTARG
;;
m)
matchcode="$matchcode$OPTARG"
;;
f)
filtercode="$filtercode$OPTARG"
;;
d)
domain=$OPTARG
;;
I)
ips=$OPTARG
;;
t)
thread="$thread$OPTARG"
;;
w)
wordlist=$OPTARG
;;
s)
protocol="https"
;;
S)
swordlist=$OPTARG
;;
h | *)
echo "$o"
usage
;;
esac
done
# Check results/domain is exist or not
#=======================================================================
if [ ! -d "hfuzz-result" ]; then
mkdir "hfuzz-results"
if [ ! -d "hfuzz-results/$domain" ]; then
mkdir "hfuzz-results/$domain"
fi
fi
#=======================================================================
# Check the requirements
#=======================================================================
echo
echo -e "${blue}[!]${NC} Check the requirements :"
if ! command -v ffuf &> /dev/null
then
echo -e " ${red}[-]${NC} ffuf could not be found !"
exit
fi
echo -e " ${green}[+]${NC} All requirements are installed :)"
#=======================================================================
#get options ready
options=
if [ ! "$matchcode" = " -mc " ]; then
options="$matchcode "
fi
if [ ! "$filtercode" = " -fc " ]; then
options="$options$filtercode "
fi
if [ ! "$thread" = " -t " ]; then
options="$options$thread "
fi
#echo -e "$options"
echo
echo -e "${blue}[!]${NC} Host header fuzzing : "
# Step 1 : only static wordlist as host header
#=======================================================================
echo -e " ${green}[+]${NC} Fuzzing step 1 - fuzzing method -> host: <word>"
if ([ -z "$ip" ] && [ -z "$ips" ]) || ([ -z "$wordlist" ]);then
echo -e "Please define Ip, wordlist"
usage
else
if [ -z "$ip" ];then
# fuzz list of ips with the wordlist
for i in $(cat "$ips");do
# with this filter we want to remove those are showing the same website as default
filterrespsize=$(curl -s -k -I "$protocol://$i" | grep -i Content-Length | cut -f2 -d' ' | tr -d '\r\n')
ffuf -c -w "$wordlist" -u "$protocol://$i" -H "Host: FUZZ" -fs "$filterrespsize" "$options" -H 'User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X x.y; rv:42.0) Gecko/20100101 Firefox/42.0' -s > hfuzz-results/$domain/step1-$i.txt 2>/dev/null
done
else
# fuzz one ip with the wordlist
filterrespsize=$(curl -s -k -I "$protocol://$ip" | grep -i Content-Length | cut -f2 -d' ' | tr -d '\r\n')
ffuf -c -w "$wordlist" -u "$protocol://$ip" -H "Host: FUZZ" -fs "$filterrespsize" "$options" -H 'User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X x.y; rv:42.0) Gecko/20100101 Firefox/42.0' -s > hfuzz-results/$domain/step1.txt 2>/dev/null
fi
fi
#=======================================================================
# Step 2 : static wordlist+domain.tld as host header
#=======================================================================
echo -e " ${green}[+]${NC} Fuzzing step 2 - fuzzing method -> host: <word>.domain.tld"
if ([ -z "$ip" ] && [ -z "$ips" ]) || ([ -z "$wordlist" ]) || ([ -z "$domain" ]);then
echo -e "Please define Ip, wordlist and Domain"
usage
else
if [ -z "$ip" ];then
# fuzz list of ips with the wordlist
for i in $(cat "$ips");do
# with this filter we want to remove those are showing the same website as default
filterrespsize=$(curl -s -k -I "$protocol://$i" | grep -i Content-Length | cut -f2 -d' ' | tr -d '\r\n')
ffuf -c -w "$wordlist" -u "$protocol://$i" -H "Host: FUZZ.$domain" -fs "$filterrespsize" "$options" -H 'User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X x.y; rv:42.0) Gecko/20100101 Firefox/42.0' -s > hfuzz-results/$domain/step2-$i.txt 2>/dev/null
done
else
# fuzz one ip with the wordlist
filterrespsize=$(curl -s -k -I "$protocol://$ip" | grep -i Content-Length | cut -f2 -d' ' | tr -d '\r\n')
ffuf -c -w "$wordlist" -u "$protocol://$ip" -H "Host: FUZZ.$domain" -fs "$filterrespsize" "$options" -H 'User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X x.y; rv:42.0) Gecko/20100101 Firefox/42.0' -s > hfuzz-results/$domain/step2.txt 2>/dev/null
fi
fi
#=======================================================================
# Step 3 : subdomians as host header
#=======================================================================
echo -e " ${green}[+]${NC} Fuzzing step 3 - fuzzing method -> host: <subdomain>"
if ([ -z "$ip" ] && [ -z "$ips" ]) || ([ -z "$swordlist" ]) ;then
echo -e "Please define Ip and Subdomain wordlist"
usage
else
if [ -z "$ip" ];then
# fuzz list of ips with the wordlist
for i in $(cat "$ips");do
# with this filter we want to remove those are showing the same website as default
filterrespsize=$(curl -s -k -I "$protocol://$i" | grep -i Content-Length | cut -f2 -d' ' | tr -d '\r\n')
ffuf -c -w "$swordlist" -u "$protocol://$i" -H "Host: FUZZ" -fs "$filterrespsize" "$options" -H 'User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X x.y; rv:42.0) Gecko/20100101 Firefox/42.0' -s > hfuzz-results/$domain/step3-$i.txt 2>/dev/null
done
else
# fuzz one ip with the wordlist
filterrespsize=$(curl -s -k -I "$protocol://$ip" | grep -i Content-Length | cut -f2 -d' ' | tr -d '\r\n')
ffuf -c -w "$swordlist" -u "$protocol://$ip" -H "Host: FUZZ" -fs "$filterrespsize" "$options" -H 'User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X x.y; rv:42.0) Gecko/20100101 Firefox/42.0' -s > hfuzz-results/$domain/step3.txt 2>/dev/null
fi
fi
#=======================================================================