repositories

daemon-sec-cheatsheet

The cheatsheet vault for operators: AD, enumeration, exploitation, priv-esc, web, DFIR

clonegit clone https://git.daemon-sec.xyz/daemon-sec-cheatsheet.git
disable-functions-bypass-php-5-2-fopen-exploit.mdMarkdown24 lines1.5 KiBsource raw download

title: "PHP 5.2 fopen safemode Bypass" section: "Network Services" sectionSlug: "network-services-pentesting" sourcePath: "src/network-services-pentesting/pentesting-web/php-tricks-esp/php-useful-functions-disable_functions-open_basedir-bypass/disable_functions-bypass-php-5.2-fopen-exploit.md" sourceUrl: "https://github.com/HackTricks-wiki/hacktricks/blob/188de82beb54e70956b2952367a0af91d26758b8/src/network-services-pentesting/pentesting-web/php-tricks-esp/php-useful-functions-disable_functions-open_basedir-bypass/disable_functions-bypass-php-5.2-fopen-exploit.md" sha: "188de82beb54e70956b2952367a0af91d26758b8" isIndex: false modified: true license: "CC-BY-NC-4.0"#

PHP 5.2 fopen safe_mode Bypass#

This historical local exploit targets a safe_mode restriction-bypass issue reported in PHP 5.2.0. In a shared-hosting scenario where an attacker could already execute PHP code, a crafted srpath:// URI passed to fopen could write a file outside the intended location.[1] This is not a general bypass for modern PHP because safe_mode and its related configuration options were removed in PHP 5.4.[2]

php -r 'fopen("srpath://../../../../../../../dir/pliczek", "a");'

References#