-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMITM.py
More file actions
67 lines (40 loc) · 748 Bytes
/
MITM.py
File metadata and controls
67 lines (40 loc) · 748 Bytes
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
import socket
import time
def AliceMITM():
# Pretends to be bob
print "Pretends to be bob"
s = socket.socket()
host = socket.gethostname()
port = 10110
n = 105
g = 7
p = 3
B = (g**p)%n
s.bind((host,port))
s.listen(5)
conn,addr = s.accept()
A = conn.recv(1024)
A = float(A)
conn.send(str(B))
Bkey = (A**p)%n
print "Key between Alice and MITM(bob)"
print Bkey
def BobMITM():
# Pretends to be Aice
print "Pretends to be Alice"
s = socket.socket()
host = socket.gethostname()
port = 10111
n = 105
g = 7
p = 4
A = (g**p)%n
s.connect((host,port))
s.send(str(A))
B = s.recv(1024)
B = float(B)
Akey = (B**p)%n
print "Key between Bob and MITM(A)"
print Akey
AliceMITM()
BobMITM()