Skip to content

Commit e7c9792

Browse files
committed
Added players, sockets and keys
1 parent 7e2ff45 commit e7c9792

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

mitm/eve.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,31 @@
99
print("You must provide exactly one of these tags as an argument upon execution: --relay --break-heart --custom")
1010
exit(0)
1111
else:
12+
dialog = Dialog('print')
1213

1314
#1) Connect to Alice and get her key
15+
player1 = os.path.basename(sys.argv[0]).split('.', 1)[0]
16+
socket1, aes1 = setup(player1, BUFFER_DIR, BUFFER_FILE_NAME)
1417

1518
#2) Connect to Bob and get his key
19+
player2 = os.path.basename(sys.argv[0]).split('.', 1)[0]
20+
socket2, aes2 = setup(player2, BUFFER_DIR, BUFFER_FILE_NAME)
1621

1722
#3) Communication cases:
1823
#3.1) Relay - decrypt, re-encrypt and send each message using respective keys
1924
#3.2) Break Heart - encrypt and send messages (-> Alice: "I hate you!", -> Bob "You broke my heart...")
2025
#3.3) Custom - prompt user to add message upon message receival from Bob/Alice, encrypt and send it
2126

22-
dialog = Dialog('print')
23-
player = os.path.basename(sys.argv[0]).split('.', 1)[0]
24-
socket, aes = setup(player, BUFFER_DIR, BUFFER_FILE_NAME)
25-
26-
if CUSTOM_CHAT:
27+
if args[1] == "--custom":
2728
dialog.prompt('Please input message...')
2829
to_send = input()
29-
else:
30+
elif args[1] == "--relay":
3031
to_send = NICE_MSG[player]
32+
elif args[1] == "--break-heart":
33+
to_send = BAD_MSG[player]
34+
else:
35+
print("ERROR: you have an entered an invalid argument")
36+
3137
encrypt_and_send(to_send, aes, socket)
3238
dialog.info('Message sent! Waiting for reply...')
3339
received = receive_and_decrypt(aes, socket)

0 commit comments

Comments
 (0)