Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import socket, select, sys
- import hashlib
- host = ''
- port = 45786
- s = socket.socket()
- s.connect(('localhost',port))
- print ("")
- print (" ##################################################################")
- print (" # client_point3 #")
- print (" ##################################################################")
- print ("")
- hasher = hashlib.md5()
- while True:
- # print server message
- msg_received = s.recv(1024)
- msg_received = msg_received.decode()
- print("\n>>> {} \n".format(msg_received))
- # get file name to send
- cond = input(str("[+] Do you want to send file [y]/[n]: "))
- if cond == 'y' or cond =='yes':
- f_send = input(str("[+] Please enter the filename to send : "))
- try: # try if the file exist
- with open(f_send, "rb") as f:
- # send file
- print("[+] Sending file...")
- data = f.read()
- s.sendall(data)
- hasher.update(data)
- print("[+] The hexadecimal equivalent of hash is : ", end ="")
- print(hasher.hexdigest())
- print("[+] Sending hash... ")
- hs = hasher.hexdigest()
- s.send(hs.encode())
- pass
- except IOError:
- print("[-] Error ! no file found with this name ")
- sys.exit()
- continue
- else:
- print("[-] Your connection will be closed...")
- s.close()
- break
- # close connection
- print("[-] Disconnected")
- sys.exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement