Bugku_CTF Writeup 之 never give up

Posted izayoi

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Bugku_CTF Writeup 之 never give up相关的知识,希望对你有一定的参考价值。

题目描述:

http://120.24.86.145:8006/test/hello.php

作者:御结冰城

 

1.打开题目页面啥都没有,去源码中找线索,发现注释:<!--1p.html-->

 

2.试图访问http://120.24.86.145:8006/test/1p.html,发现被重定向到bugku主页。可1p.html里面肯定有什么东西......(never give up?!)

 

3.通过访问view-source:http://120.24.86.145:8006/test/1p.html查看到源码

 

4.发现一段url编码+base64编码的文本:

%3Cscript%3Ewindow.location.href%3D%27http%3A//www.bugku.com%27%3B%3C/script%3E%20%0A%3C%21--JTIyJTNCaWYlMjglMjElMjRfR0VUJTVCJTI3aWQlMjclNUQlMjklMEElN0IlMEElMDloZWFkZXIlMjglMjdMb2NhdGlvbiUzQSUyMGhlbGxvLnBocCUzRmlkJTNEMSUyNyUyOSUzQiUwQSUwOWV4aXQlMjglMjklM0IlMEElN0QlMEElMjRpZCUzRCUyNF9HRVQlNUIlMjdpZCUyNyU1RCUzQiUwQSUyNGElM0QlMjRfR0VUJTVCJTI3YSUyNyU1RCUzQiUwQSUyNGIlM0QlMjRfR0VUJTVCJTI3YiUyNyU1RCUzQiUwQWlmJTI4c3RyaXBvcyUyOCUyNGElMkMlMjcuJTI3JTI5JTI5JTBBJTdCJTBBJTA5ZWNobyUyMCUyN25vJTIwbm8lMjBubyUyMG5vJTIwbm8lMjBubyUyMG5vJTI3JTNCJTBBJTA5cmV0dXJuJTIwJTNCJTBBJTdEJTBBJTI0ZGF0YSUyMCUzRCUyMEBmaWxlX2dldF9jb250ZW50cyUyOCUyNGElMkMlMjdyJTI3JTI5JTNCJTBBaWYlMjglMjRkYXRhJTNEJTNEJTIyYnVna3UlMjBpcyUyMGElMjBuaWNlJTIwcGxhdGVmb3JtJTIxJTIyJTIwYW5kJTIwJTI0aWQlM0QlM0QwJTIwYW5kJTIwc3RybGVuJTI4JTI0YiUy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aWQlM0QlM0QwJTIwYW5kJTIwc3RybGVuJTI4JTI0YiUyOSUzRTUlMjBhbmQlMjBlcmVnaSUyOCUyMjExMSUyMi5zdWJzdHIlMjglMjRiJTJDMCUyQzElMjklMkMlMjIxMTE0JTIyJTI5JTIwYW5kJTIwc3Vic3RyJTI4JTI0YiUyQzAlMkMxJTI5JTIxJTNENCUyOSUwQSU3QiUwQSUwOXJlcXVpcmUlMjglMjJmNGwyYTNnLnR4dCUyMiUyOSUzQiUwQSU3RCUwQWVsc2UlMEElN0IlMEElMDlwcmludCUyMCUyMm5ldmVyJTIwbmV2ZXIlMjBuZXZlciUyMGdpdmUlMjB1cCUyMCUyMSUyMSUyMSUyMiUzQiUwQSU3RCUwQSUwQSUwQSUzRiUzRQ==-->

6.base64解码得到:

%22%3Bif%28%21%24_GET%5B%27id%27%5D%29%0A%7B%0A%09header%28%27Location%3A%20hello.php%3Fid%3D1%27%29%3B%0A%09exit%28%29%3B%0A%7D%0A%24id%3D%24_GET%5B%27id%27%5D%3B%0A%24a%3D%24_GET%5B%27a%27%5D%3B%0A%24b%3D%24_GET%5B%27b%27%5D%3B%0Aif%28stripos%28%24a%2C%27.%27%29%29%0A%7B%0A%09echo%20%27no%20no%20no%20no%20no%20no%20no%27%3B%0A%09return%20%3B%0A%7D%0A%24data%20%3D%[email protected]_get_contents%28%24a%2C%27r%27%29%3B%0Aif%28%24data%3D%3D%22bugku%20is%20a%20nice%20plateform%21%22%20and%20%24id%3D%3D0%20and%20strlen%28%24b%29%3E5%20and%20eregi%28%22111%22.substr%28%24b%2C0%2C1%29%2C%221114%22%29%20and%20substr%28%24b%2C0%2C1%29%21%3D4%29%0A%7B%0A%09require%28%22f4l2a3g.txt%22%29%3B%0A%7D%0Aelse%0A%7B%0A%09print%20%22never%20never%20never%20give%20up%20%21%21%21%22%3B%0A%7D%0A%0A%0A%3F%3E

7.url解码得到PHP代码:

 1 if(!$_GET[‘id‘])
 2 {
 3 header(‘Location: hello.php?id=1‘);
 4 exit();
 5 }
 6 $id=$_GET[‘id‘];
 7 $a=$_GET[‘a‘];
 8 $b=$_GET[‘b‘];
 9 if(stripos($a,‘.‘))
10 {
11 echo ‘no no no no no no no‘;
12 return ;
13 }
14 $data = @file_get_contents($a,‘r‘);
15 if($data=="bugku is a nice plateform!" and $id==0 and strlen($b)>5 and eregi("111".substr($b,0,1),"1114") and substr($b,0,1)!=4)
16 {
17 require("f4l2a3g.txt");
18 }
19 else
20 {
21 print "never never never give up !!!";
22 }

 

 8.代码里花里胡哨一堆逻辑,可我们直接访问 http://120.24.86.145:8006/test/f4l2a3g.txt 就能得到flag了

 


以上是关于Bugku_CTF Writeup 之 never give up的主要内容,如果未能解决你的问题,请参考以下文章

Bugku_CTF Writeup 之 文件包含(60)

Bugku_CTF Writeup 之 web2(20)

Bugku_CTF Writeup 之 域名解析(50)

Bugku_CTF Writeup 之 管理员系统 (60)

Bugku_CTF Writeup 之 这是一张单纯的图片

bugku_ctf,web第四题_post