-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchal37.py
executable file
·36 lines (30 loc) · 1.03 KB
/
chal37.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
#!/usr/bin/env python
# chal37.py - Break SRP with zero key.
#
# Copyright (C) 2015 Andrew J. Zimolzak <andyzimolzak@gmail.com>,
# and licensed under GNU GPL version 3. Full notice is found in
# the file 'LICENSE' in the same directory as this file.
from cryptopals import warn
from srp import Client, Server
from diffie_hellman import p as nist_prime
import random
me = Client(nist_prime, 2, 3, 'billg@ms.com', 'PASSW0RD1')
you = Server(nist_prime, 2, 3, 'billg@ms.com', 'PASSW0RD1')
print "For benign,",
me.logon_to(you)
assert me.K == you.K
assert me.salt == you.salt
failure = Client(nist_prime, 2, 3, 'billg@ms.com', 'haha')
print "For built to fail,",
failure.logon_to(you)
assert failure.K != you.K
for k in range(0,11):
pw = ''
for i in range(8):
pw = pw + chr(random.randint(97,122))
print "A%N=0 password", pw,
sneak = Client(nist_prime, 2, 3, 'billg@ms.com', pw, ntimes=k)
sneak.logon_to(you)
assert sneak.K == you.K
assert sneak.salt == you.salt
warn("Passed assertions:", __file__)