-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path37.py
More file actions
66 lines (48 loc) · 1.76 KB
/
37.py
File metadata and controls
66 lines (48 loc) · 1.76 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
import convert
import hash
import socket
import srp
import threading
class MaliciousSRPClient(srp.SRPClient):
def __init__(self, username, publicValue, sharedSecretValue):
self.username = username
self.publicValue = publicValue
self.sharedSecretValue = sharedSecretValue
'''
Returns true if logging in to the given server with the given username and password succeeds
'''
def login(self, ip, port):
sendSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sendSocket.connect((ip, port))
sendSocket.send(str(self.username)+","+str(self.publicValue))
salt, serverPublicValue = self.recieveServerValues(sendSocket)
if salt is None or serverPublicValue is None:
sendSocket.close()
return False
sharedSecret = convert.intToByteString(hash.sha256(convert.intToByteString(self.sharedSecretValue)))
validator = srp.generateClientValidator(sharedSecret, salt)
sendSocket.send(str(validator))
if self.recieveOK(sendSocket):
sendSocket.close()
return True
sendSocket.close()
return False
if __name__ == "__main__":
server = srp.SRPServer(50000)
server.addUser("steve", "password")
serverThread = threading.Thread(target=server.runServer)
serverThread.start()
client = MaliciousSRPClient("steve", 0, 0)
print client.login("localhost", 50000)
server = srp.SRPServer(50000)
server.addUser("steve", "password")
serverThread = threading.Thread(target=server.runServer)
serverThread.start()
client = MaliciousSRPClient("steve", srp.STANDARD_N, 0)
print client.login("localhost", 50000)
server = srp.SRPServer(50000)
server.addUser("steve", "password")
serverThread = threading.Thread(target=server.runServer)
serverThread.start()
client = MaliciousSRPClient("steve", srp.STANDARD_N*2, 0)
print client.login("localhost", 50000)