Advertisement
Guest User

Untitled

a guest
Jun 20th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. import argparse
  2. import paramiko
  3. import threading
  4. import time
  5.  
  6. paramiko.util.log_to_file("sshiege.log")
  7.  
  8.  
  9. def open_ssh_connection(index, ip, retry):
  10. print('Thread {} smashing the SSH server ...'.format(index))
  11. client = paramiko.SSHClient()
  12. try:
  13. client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  14. if not retry:
  15. client.connect(ip, username='osirium_support', password='password')
  16. else:
  17. try:
  18. client.connect(
  19. ip, username='osirium_support', password='password'
  20. )
  21. except paramiko.SSHException:
  22. print('Thread {}: Sleeping a bit ...'.format(index))
  23. time.sleep(5)
  24. print('Thread {}: All good'.format(index))
  25. except Exception as e:
  26. print('Thread {}: Something went wrong {}'.format(index, str(e)))
  27. finally:
  28. client.close()
  29.  
  30.  
  31. def smash_ssh_server(ip, count, retry):
  32. threads = []
  33. for index in range(int(count)):
  34. thread = threading.Thread(
  35. target=open_ssh_connection, args=(index, ip, retry)
  36. )
  37. threads.append(thread)
  38. thread.start()
  39. for thread in threads:
  40. thread.join()
  41.  
  42.  
  43. if __name__ == '__main__':
  44. parser = argparse.ArgumentParser()
  45. parser.add_argument('ip')
  46. parser.add_argument('count')
  47. parser.add_argument('--retry', action='store_true')
  48. args = parser.parse_args()
  49. smash_ssh_server(args.ip, args.count, args.retry)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement