Advertisement
Guest User

Untitled

a guest
May 20th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. import socket, select, sys
  2. import hashlib
  3.  
  4. host = ''
  5. port = 45786
  6.  
  7. s = socket.socket()
  8. s.connect(('localhost',port))
  9.  
  10. print ("")
  11. print (" ##################################################################")
  12. print (" # client_point3 #")
  13. print (" ##################################################################")
  14. print ("")
  15.  
  16. hasher = hashlib.md5()
  17.  
  18. while True:
  19. # print server message
  20. msg_received = s.recv(1024)
  21. msg_received = msg_received.decode()
  22. print("\n>>> {} \n".format(msg_received))
  23. # get file name to send
  24. cond = input(str("[+] Do you want to send file [y]/[n]: "))
  25. if cond == 'y' or cond =='yes':
  26. f_send = input(str("[+] Please enter the filename to send : "))
  27. try: # try if the file exist
  28. with open(f_send, "rb") as f:
  29. # send file
  30. print("[+] Sending file...")
  31. data = f.read()
  32. s.sendall(data)
  33. hasher.update(data)
  34. print("[+] The hexadecimal equivalent of hash is : ", end ="")
  35. print(hasher.hexdigest())
  36. print("[+] Sending hash... ")
  37. hs = hasher.hexdigest()
  38. s.send(hs.encode())
  39. pass
  40. except IOError:
  41. print("[-] Error ! no file found with this name ")
  42. sys.exit()
  43. continue
  44. else:
  45. print("[-] Your connection will be closed...")
  46. s.close()
  47. break
  48.  
  49. # close connection
  50. print("[-] Disconnected")
  51. sys.exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement