-
Notifications
You must be signed in to change notification settings - Fork 0
/
client_mini.py
43 lines (37 loc) · 1.11 KB
/
client_mini.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
37
38
39
40
41
42
43
import time
import socket
import getpass
import sys
number = sys.argv[1]
sys.stdin = open("./mininet_helper/input{}.txt".format(number),'r')
HOST = "10.0.0.1"
PORT = 12345
socket_client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
socket_client.connect((HOST, PORT))
print("Connected to Server")
f = open("1.txt",'a')
while 1:
p, addr = socket_client.recvfrom(4096+1024)
p = p.decode('utf-8')
if(p == "Password: "):
reply = getpass.getpass(prompt= "Password: ")
socket_client.send(reply.encode())
continue
if(p == "Please Enter New Password: "):
reply = getpass.getpass(prompt= "Please Enter New Password: ")
socket_client.send(reply.encode())
continue
if(p == "Please Confirm New Password: "):
reply = getpass.getpass(prompt="Please Confirm New Password: ")
socket_client.send(reply.encode())
continue
if(p == "Thank you for using Mini-Face"):
print(p)
f.write(p)
time.sleep(0.5)
break
print(p)
reply = input()
socket_client.send(reply.encode())
f.close()
socket_client.close()