NMap
┌[parrot@parrot]─[~/tryhackme/lazyadmin]
└╼[★ ]$nmap -sC -sV 10.10.246.35
Starting Nmap 7.92 ( https://nmap.org ) at 2022-09-03 03:25 CEST
Nmap scan report for 10.10.246.35
Host is up (0.092s latency).
Not shown: 998 closed tcp ports (conn-refused)
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 7.2p2 Ubuntu 4ubuntu2.8 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 2048 49:7c:f7:41:10:43:73:da:2c:e6:38:95:86:f8:e0:f0 (RSA)
| 256 2f:d7:c4:4c:e8:1b:5a:90:44:df:c0:63:8c:72:ae:55 (ECDSA)
|_ 256 61:84:62:27:c6:c3:29:17:dd:27:45:9e:29:cb:90:5e (ED25519)
80/tcp open http Apache httpd 2.4.18 ((Ubuntu))
|_http-title: Apache2 Ubuntu Default Page: It works
|_http-server-header: Apache/2.4.18 (Ubuntu)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Mamy otwarte tylko 2 porty.
Port 80 to domyślna strona Apache2.
FeroxBuster
Podstawowy skan odkrył podfolder content
.
Zrobiłem głębszy skan.
┌[parrot@parrot]─[~/tryhackme/lazyadmin]
└╼[★ ]$feroxbuster -w /opt/SecLists/Discovery/Web-Content/raft-small-words.txt -u http://10.10.246.35/content -d 1 -r -t 50
___ ___ __ __ __ __ __ ___
|__ |__ |__) |__) | / ` / \ \_/ | | \ |__
| |___ | \ | \ | \__, \__/ / \ | |__/ |___
by Ben "epi" Risher 🤓 ver: 2.3.3
───────────────────────────┬──────────────────────
🎯 Target Url │ http://10.10.246.35/content
🚀 Threads │ 50
📖 Wordlist │ /opt/SecLists/Discovery/Web-Content/raft-small-words.txt
👌 Status Codes │ [200, 204, 301, 302, 307, 308, 401, 403, 405, 500]
💥 Timeout (secs) │ 7
🦡 User-Agent │ feroxbuster/2.3.3
💉 Config File │ /etc/feroxbuster/ferox-config.toml
📍 Follow Redirects │ true
🔃 Recursion Depth │ 1
🎉 New Version Available │ https://github.com/epi052/feroxbuster/releases/latest
───────────────────────────┴──────────────────────
🏁 Press [ENTER] to use the Scan Cancel Menu™
──────────────────────────────────────────────────
403 9l 28w 277c http://10.10.246.35/content/.php
200 20l 103w 1776c http://10.10.246.35/content/js/
200 44l 352w 6684c http://10.10.246.35/content/inc/
200 15l 49w 773c http://10.10.246.35/content/attachment/
200 36l 151w 2198c http://10.10.246.35/content/
200 16l 60w 963c http://10.10.246.35/content/_themes/
403 9l 28w 277c http://10.10.246.35/content/.htaccess
403 9l 28w 277c http://10.10.246.35/content/.htm
403 9l 28w 277c http://10.10.246.35/content/.php3
403 9l 28w 277c http://10.10.246.35/content/.phtml
403 9l 28w 277c http://10.10.246.35/content/.html
200 28l 174w 3443c http://10.10.246.35/content/images/
403 9l 28w 277c http://10.10.246.35/content/.htc
200 114l 252w 3667c http://10.10.246.35/content/as/
403 9l 28w 277c http://10.10.246.35/content/.php5
403 9l 28w 277c http://10.10.246.35/content/.html_var_DE
403 9l 28w 277c http://10.10.246.35/content/.php4
403 9l 28w 277c http://10.10.246.35/content/.htpasswd
403 9l 28w 277c http://10.10.246.35/content/.html.
Mamy parę ciekawych folderów -> js
, attachment
, images
, as
, _themes
W podfolderze inc
znalazłem sporo danych. Szczególnie ciekawy jest backup MySQLa.
Znalazłem w nim dane do logowania na panel.
Po sprawdzeniu hasha okazało się, że hasło to
Password123
.
manager:Password123
W plikach znalazłem również, że CMS to SweetRice 1.5.1
, ale udało mi się zalogować na panel pod /content/as
z użyciem danych powyżej.
Shell jako www-data oraz flaga
Włączyłem działanie CMS oraz dodałem kod php-reverse-shella w motywie. W ten sposób po otwarciu dowolnej strony otrzymałem połączenie na wskazanym porcie 1234
.
Nawet jako www-data
mogłem wejść na folder usera itguy
i odczytałem flagę.
THM{63e5bce9271952aad1113b6f1ac28a07}
Privilege escalation
User www-data
może uruchamiać perla z sudo.
Plik backup.pl
:
#!/usr/bin/perl
system("sh", "/etc/copy.sh");
A plik /etc/copy.sh
zawiera szereg komend do uzyskania reverse shella.
Zatem widać, że uruchomienie perlem pliku
backup.pl
uruchamia powyższą komendę.
Podmieniłem adres ip i port na własne i włączyłem całość.
sudo /usr/bin/perl /home/itguy/backup.pl
Na nasłuchu otrzymałem połączenie jako root.
Root proof