Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import argparse
- import paramiko
- import threading
- import time
- paramiko.util.log_to_file("sshiege.log")
- def open_ssh_connection(index, ip, retry):
- print('Thread {} smashing the SSH server ...'.format(index))
- client = paramiko.SSHClient()
- try:
- client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- if not retry:
- client.connect(ip, username='osirium_support', password='password')
- else:
- try:
- client.connect(
- ip, username='osirium_support', password='password'
- )
- except paramiko.SSHException:
- print('Thread {}: Sleeping a bit ...'.format(index))
- time.sleep(5)
- print('Thread {}: All good'.format(index))
- except Exception as e:
- print('Thread {}: Something went wrong {}'.format(index, str(e)))
- finally:
- client.close()
- def smash_ssh_server(ip, count, retry):
- threads = []
- for index in range(int(count)):
- thread = threading.Thread(
- target=open_ssh_connection, args=(index, ip, retry)
- )
- threads.append(thread)
- thread.start()
- for thread in threads:
- thread.join()
- if __name__ == '__main__':
- parser = argparse.ArgumentParser()
- parser.add_argument('ip')
- parser.add_argument('count')
- parser.add_argument('--retry', action='store_true')
- args = parser.parse_args()
- smash_ssh_server(args.ip, args.count, args.retry)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement