2014-01-08 21:41:44 +00:00
|
|
|
##
|
|
|
|
# This module requires Metasploit: http//metasploit.com/download
|
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Auxiliary
|
|
|
|
|
|
|
|
include Msf::Exploit::Remote::DCERPC
|
|
|
|
include Msf::Exploit::Remote::SMB
|
|
|
|
include Msf::Auxiliary::Scanner
|
|
|
|
include Msf::Auxiliary::Report
|
|
|
|
|
|
|
|
def initialize
|
|
|
|
super(
|
2014-01-09 00:11:18 +00:00
|
|
|
'Name' => 'MS08-067 Scanner',
|
|
|
|
'Description' => 'This module uses the check in ms08_067_netapi to scan a network for the vulnerability.',
|
2014-01-08 21:41:44 +00:00
|
|
|
'References' =>
|
|
|
|
[
|
|
|
|
[ 'CVE', '2008-4250'],
|
|
|
|
[ 'OSVDB', '49243'],
|
|
|
|
[ 'MSB', 'MS08-067' ],
|
|
|
|
# If this vulnerability is found, ms08-67 is exposed as well
|
|
|
|
[ 'URL', 'http://www.rapid7.com/vulndb/lookup/dcerpc-ms-netapi-netpathcanonicalize-dos']
|
|
|
|
],
|
|
|
|
'Author' =>
|
|
|
|
[
|
|
|
|
'hdm', # with tons of input/help/testing from the community
|
|
|
|
'Brett Moore <brett.moore[at]insomniasec.com>',
|
|
|
|
'frank2 <frank2@dc949.org>', # check() detection
|
|
|
|
'jduck', # XP SP2/SP3 AlwaysOn DEP bypass
|
2014-01-09 02:16:09 +00:00
|
|
|
'sho-luv', # Cut frank2's check into auxiliary module
|
|
|
|
'wvu' # Added scan labels cleaned up code
|
2014-01-08 21:41:44 +00:00
|
|
|
],
|
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
'DefaultOptions' => {}
|
|
|
|
)
|
|
|
|
register_options(
|
|
|
|
[
|
2014-01-09 02:16:09 +00:00
|
|
|
OptString.new('SMBPIPE', [ true, "The pipe name to use (BROWSER, SRVSVC)", 'BROWSER'])
|
2014-01-08 21:41:44 +00:00
|
|
|
], self.class)
|
|
|
|
end
|
|
|
|
|
2014-01-08 23:09:41 +00:00
|
|
|
def run_host(ip)
|
2014-01-09 01:38:54 +00:00
|
|
|
case check_vuln
|
|
|
|
when Msf::Exploit::CheckCode::Vulnerable
|
2014-01-08 23:09:41 +00:00
|
|
|
print_good("#{ip}:#{rport} - MS08-067 VULNERABLE")
|
2014-01-09 00:11:18 +00:00
|
|
|
report_vuln({
|
|
|
|
:host => ip,
|
|
|
|
:name => "MS08-067",
|
|
|
|
:info => "Vulnerability in Server service could allow remote code execution",
|
|
|
|
:refs => self.references
|
|
|
|
})
|
2014-01-09 01:38:54 +00:00
|
|
|
when Msf::Exploit::CheckCode::Safe
|
|
|
|
vprint_status("#{ip}:#{rport} - MS08-067 SAFE")
|
|
|
|
when Msf::Exploit::CheckCode::Unknown
|
|
|
|
vprint_status("#{ip}:#{rport} - MS08-067 UNKNOWN")
|
2014-01-08 23:09:41 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def check_vuln
|
2014-01-08 21:41:44 +00:00
|
|
|
begin
|
|
|
|
connect()
|
|
|
|
smb_login()
|
2014-01-09 01:38:54 +00:00
|
|
|
rescue Rex::Proto::SMB::Exceptions::LoginError
|
2014-01-08 23:09:41 +00:00
|
|
|
return Msf::Exploit::CheckCode::Unknown
|
2014-01-08 21:41:44 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
# Build the malicious path name
|
|
|
|
# 5b878ae7 "db @eax;g"
|
|
|
|
prefix = "\\"
|
|
|
|
path =
|
|
|
|
"\x00\\\x00/"*0x10 +
|
|
|
|
Rex::Text.to_unicode("\\") +
|
|
|
|
Rex::Text.to_unicode("R7") +
|
|
|
|
Rex::Text.to_unicode("\\..\\..\\") +
|
|
|
|
Rex::Text.to_unicode("R7") +
|
|
|
|
"\x00"*2
|
|
|
|
|
|
|
|
server = Rex::Text.rand_text_alpha(rand(8)+1).upcase
|
|
|
|
|
|
|
|
handle = dcerpc_handle( '4b324fc8-1670-01d3-1278-5a47bf6ee188', '3.0',
|
|
|
|
'ncacn_np', ["\\#{datastore['SMBPIPE']}"]
|
|
|
|
)
|
|
|
|
|
|
|
|
begin
|
|
|
|
# Samba doesn't have this handle and returns an ErrorCode
|
|
|
|
dcerpc_bind(handle)
|
|
|
|
rescue Rex::Proto::SMB::Exceptions::ErrorCode
|
|
|
|
return Msf::Exploit::CheckCode::Safe
|
|
|
|
end
|
|
|
|
|
|
|
|
stub =
|
|
|
|
NDR.uwstring(server) +
|
|
|
|
NDR.UnicodeConformantVaryingStringPreBuilt(path) +
|
|
|
|
NDR.long(8) +
|
|
|
|
NDR.wstring(prefix) +
|
|
|
|
NDR.long(4097) +
|
|
|
|
NDR.long(0)
|
|
|
|
|
|
|
|
resp = dcerpc.call(0x1f, stub)
|
|
|
|
error = resp[4,4].unpack("V")[0]
|
|
|
|
|
|
|
|
# Cleanup
|
|
|
|
simple.client.close
|
|
|
|
simple.client.tree_disconnect
|
|
|
|
disconnect
|
|
|
|
|
|
|
|
if (error == 0x0052005c) # \R :)
|
|
|
|
return Msf::Exploit::CheckCode::Vulnerable
|
|
|
|
else
|
|
|
|
return Msf::Exploit::CheckCode::Safe
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|