<?php

$s = fopen('php://temp/maxmemory=1024', 'wb+');
$t = fopen('php://temp/maxmemory=1024', 'wb+');
/* force conversion of inner stream to STDIO. */
$i = 0;
while ($i++ < 5000) {
    fwrite($t, str_repeat('a', 1024));
}
leak_variable($s, true);
leak_variable($t, true);
Beispiel #2
0
<?php

function do_stuff($url)
{
    $handle = curl_init('http://127.0.0.1:37349/');
    curl_setopt($handle, CURLOPT_VERBOSE, true);
    curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($handle, CURLOPT_STDERR, $o = fopen($url, "w+"));
    curl_exec($handle);
    echo "About to rewind!\n";
    rewind($o);
    echo stream_get_contents($o);
    return $o;
}
echo "temp stream (close after):\n";
fclose(do_stuff("php://temp"));
echo "\nmemory stream (close after):\n";
fclose(do_stuff("php://memory"));
echo "\ntemp stream (leak):\n";
leak_variable(do_stuff("php://temp"), true);
echo "\nmemory stream (leak):\n";
leak_variable(do_stuff("php://memory"), true);
echo "\nDone.\n";
<?php

$stream0 = stream_socket_server("udp://0.0.0.0:58380", $errno, $errstr, STREAM_SERVER_BIND);
$sock0 = socket_import_stream($stream0);
leak_variable($stream0, true);
$stream1 = stream_socket_server("udp://0.0.0.0:58381", $errno, $errstr, STREAM_SERVER_BIND);
$sock1 = socket_import_stream($stream1);
leak_variable($sock1, true);
echo "Done.\n";