Beispiel #1
0
def myrec():
    a = s.recv(4000)
    length = struct.unpack("<I", a[:4])[0]
    neww = proto_pb2.Exchange()
    neww.ParseFromString(a[4:])
    return neww
Beispiel #2
0
nonce = r.reply.headers[1].value
nonce = nonce[nonce.find('nonce=') + len('nonce=') + 1:]
nonce = str(nonce[:nonce.find('"')])

r.reply.headers[1].value = 'Basic realm="In the realm of hackers"'
mysend(r.SerializeToString())
r = myrec()
print 'server: ' + str(r)

t = r.request.headers[0].value
t = t[len('Basic '):].decode('base64')
username, password = t.split(':')

print username, password

e = proto_pb2.Exchange()
req = e.request
req.ver = 0
req.uri = '/protected/secret'
head = req.headers.add()
head.key = r1.request.headers[0].key
head.value = r1.request.headers[0].value

req = e.request
head = req.headers.add()
head.key = "Authorization"
username = '******'
cnonce = '12345678'
nc = '00000001'
opts = {
    'username':