-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpythontest20b.py
More file actions
101 lines (72 loc) · 1.85 KB
/
Copy pathpythontest20b.py
File metadata and controls
101 lines (72 loc) · 1.85 KB
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
import urllib
import Cookie
import httplib
import string
import base64
userid = 'butter'
passwd = 'fly'
auth = 'Basic ' + string.strip(base64.encodestring(userid + ':' + passwd))
k = 30203
for ii in range(100):
conn = httplib.HTTPConnection("www.pythonchallenge.com",80)
conn.putrequest("GET", "/pc/hex/unreal.jpg")
conn.putheader('Authorization', auth)
conn.putheader('Range','bytes=' + str(k) + '-')
conn.endheaders()
r1 = conn.getresponse()
#print r1.status, r1.reason
headers1 = r1.getheaders()
#print headers1
data1 = r1.read()
print data1
j=-1
for i in range(len(headers1)):
if headers1[i][0]=='content-range':
j=i
if j==-1:
break
s1 = headers1[j][1]
i=s1.find('-')
j=s1.find('/')
k = int(s1[i+1:j])+1
conn.close()
k = 2123456789
for ii in range(100):
conn = httplib.HTTPConnection("www.pythonchallenge.com",80)
conn.putrequest("GET", "/pc/hex/unreal.jpg")
conn.putheader('Authorization', auth)
conn.putheader('Range','bytes=' + str(k) + '-')
conn.endheaders()
r1 = conn.getresponse()
#print r1.status, r1.reason
headers1 = r1.getheaders()
#print headers1
data1 = r1.read()
print data1
j=-1
for i in range(len(headers1)):
if headers1[i][0]=='content-range':
j=i
if j==-1:
break
s1 = headers1[j][1]
i=s1.find(' ')
j=s1.find('-')
k = int(s1[i+1:j])-1
conn.close()
k = 1152983631
conn = httplib.HTTPConnection("www.pythonchallenge.com",80)
conn.putrequest("GET", "/pc/hex/unreal.jpg")
conn.putheader('Authorization', auth)
conn.putheader('Range','bytes=' + str(k) + '-')
conn.endheaders()
r1 = conn.getresponse()
#print r1.status, r1.reason
headers1 = r1.getheaders()
print headers1
data1 = r1.read()
print len(data1)
conn.close()
myFile = open("puzzle20.txt","wb")
myFile.write(data1)
myFile.close()