Advertisement
Guest User

Untitled

a guest
Sep 25th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. import socket
  2. import time
  3. import base64
  4. def netcat(s,content=''):
  5. if content:
  6. if content[-2::]!='\r\n':
  7. content = content + '\r\n'
  8. s.sendall(content)
  9.  
  10. # s.shutdown(socket.SHUT_WR)
  11. data = s.recv(1024)
  12.  
  13. # print "Connection closed."
  14. # s.close()
  15. return repr(data)
  16. username =
  17. password =
  18.  
  19.  
  20. def main():
  21. hostname =
  22. port =
  23. s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  24. s.connect((hostname, port))
  25.  
  26. start_time = time.time()
  27. print netcat(s)
  28. print("--- Connection establishment time: %s seconds ---" % (time.time() - start_time))
  29. start_time = time.time()
  30. netcat(s,'USER ' + username + '')
  31. print netcat(s,'PASS ' + base64.b64decode(password) + '')
  32. print("--- Authentication time: %s seconds ---" % (time.time() - start_time))
  33. start_time = time.time()
  34. print netcat(s,'LIST')
  35. print netcat(s,'QUIT')
  36. s.close()
  37. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement