OpenEMR
OpenEMR is an open-source medical practice management application. In the observed path, OpenEMR was exposed under /openemr/; valid admin credentials led to authenticated RCE with Exploit-DB 45161.py
Discovery
OpenEMR login path:
http://apex.offsec/openemr/interface/login/login.php?site=defaultAnonymous SMB enumeration may also reveal OpenEMR-related documents:
\\TARGET\docs
Path: C:\var\www\html\source\Documents
OpenEMR Success Stories.pdf
OpenEMR Features.pdfThe share path was also web-accessible:
http://apex.offsec/source/Documents/Admin Credential Discovery
Brute force the OpenEMR login with ffuf. A successful login returned a 302 response with a different size from failed attempts:
ffuf -X POST \
-H 'Host: apex.offsec' \
-H 'Origin: http://apex.offsec' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'Referer: http://apex.offsec/openemr/interface/login/login.php?site=default' \
-d 'new_login_session_management=1&authProvider=Default&authUser=admin&clearPass=FUZZ&languageChoice=1' \
-u 'http://apex.offsec/openemr/interface/main/main_screen.php?auth=login&site=default' \
-w /usr/share/wordlists/rockyou.txt \
-t 2 \
-fs 464Working credential:
Authenticated RCE
Exploit-DB 45161.py worked after a Python 3 bytes/string fix:
On Python 3, the original PoC failed with a bytes/string encoding error:
Patch the command encoding line.
Before:
After:
Confirm blind command execution with ICMP:
Run a reverse shell:
Successful shell:
Successful shell context:
Privilege Escalation
PwnKit (CVE-2021-4034) worked from the www-data shell. See Linux Privilege Escalation for the version checks and exploit commands.
Last updated