Skip to content

Commit

Permalink
Add guard clause to not print out session info unless the session is …
Browse files Browse the repository at this point in the history
…enabled
  • Loading branch information
dwelch-r7 committed May 13, 2024
1 parent 771c183 commit bc9a25a
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 9 deletions.
1 change: 0 additions & 1 deletion lib/rex/post/ldap/ui/console.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ def queue_cmd(cmd)
# Runs the specified command wrapper in something to catch exceptions.
#
def run_command(dispatcher, method, arguments)
# TODO: double check these are the correct errors to handle
super
rescue Timeout::Error
log_error('Operation timed out.')
Expand Down
7 changes: 4 additions & 3 deletions lib/rex/post/ldap/ui/console/command_dispatcher/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module LDAP
module Ui
###
#
# Core SMB client commands
# Core LDAP client commands
#
###
class Console::CommandDispatcher::Client
Expand Down Expand Up @@ -41,17 +41,18 @@ def commands
end

#
# Shares
# Client
#
def name
'Client'
end

#
# Query the LDAP server
#
def cmd_query(*args)
if args.include?('-h') || args.include?('--help')
cmd_shares_help
cmd_query_help
return
end

Expand Down
4 changes: 3 additions & 1 deletion modules/auxiliary/scanner/ldap/ldap_login.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ def run
logins = results.flat_map { |_k, v| v[:successful_logins] }
sessions = results.flat_map { |_k, v| v[:successful_sessions] }
print_status("Bruteforce completed, #{logins.size} #{logins.size == 1 ? 'credential was' : 'credentials were'} successful.")
if datastore['CreateSession']
return results unless framework.features.enabled?(Msf::FeatureManager::LDAP_SESSION_TYPE)

if create_session?
print_status("#{sessions.size} LDAP #{sessions.size == 1 ? 'session was' : 'sessions were'} opened successfully.")
else
print_status('You can open an LDAP session with these credentials and %grnCreateSession%clr set to true')
Expand Down
4 changes: 3 additions & 1 deletion modules/auxiliary/scanner/mssql/mssql_login.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ def run
logins = results.flat_map { |_k, v| v[:successful_logins] }
sessions = results.flat_map { |_k, v| v[:successful_sessions] }
print_status("Bruteforce completed, #{logins.size} #{logins.size == 1 ? 'credential was' : 'credentials were'} successful.")
if datastore['CreateSession']
return results unless framework.features.enabled?(Msf::FeatureManager::MSSQL_SESSION_TYPE)

if create_session?
print_status("#{sessions.size} MSSQL #{sessions.size == 1 ? 'session was' : 'sessions were'} opened successfully.")
else
print_status('You can open an MSSQL session with these credentials and %grnCreateSession%clr set to true')
Expand Down
4 changes: 3 additions & 1 deletion modules/auxiliary/scanner/mysql/mysql_login.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ def run
logins = results.flat_map { |_k, v| v[:successful_logins] }
sessions = results.flat_map { |_k, v| v[:successful_sessions] }
print_status("Bruteforce completed, #{logins.size} #{logins.size == 1 ? 'credential was' : 'credentials were'} successful.")
if datastore['CreateSession']
return results unless framework.features.enabled?(Msf::FeatureManager::MYSQL_SESSION_TYPE)

if create_session?
print_status("#{sessions.size} MySQL #{sessions.size == 1 ? 'session was' : 'sessions were'} opened successfully.")
else
print_status('You can open an MySQL session with these credentials and %grnCreateSession%clr set to true')
Expand Down
4 changes: 3 additions & 1 deletion modules/auxiliary/scanner/postgres/postgres_login.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ def run
logins = results.flat_map { |_k, v| v[:successful_logins] }
sessions = results.flat_map { |_k, v| v[:successful_sessions] }
print_status("Bruteforce completed, #{logins.size} #{logins.size == 1 ? 'credential was' : 'credentials were'} successful.")
if datastore['CreateSession']
return results unless framework.features.enabled?(Msf::FeatureManager::POSTGRESQL_SESSION_TYPE)

if create_session?
print_status("#{sessions.size} Postgres #{sessions.size == 1 ? 'session was' : 'sessions were'} opened successfully.")
else
print_status('You can open a Postgres session with these credentials and %grnCreateSession%clr set to true')
Expand Down
4 changes: 3 additions & 1 deletion modules/auxiliary/scanner/smb/smb_login.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ def run
logins = results.flat_map { |_k, v| v[:successful_logins] }
sessions = results.flat_map { |_k, v| v[:successful_sessions] }
print_status("Bruteforce completed, #{logins.size} #{logins.size == 1 ? 'credential was' : 'credentials were'} successful.")
if datastore['CreateSession']
return results unless framework.features.enabled?(Msf::FeatureManager::SMB_SESSION_TYPE)

if create_session?
print_status("#{sessions.size} SMB #{sessions.size == 1 ? 'session was' : 'sessions were'} opened successfully.")
else
print_status('You can open an SMB session with these credentials and %grnCreateSession%clr set to true')
Expand Down

0 comments on commit bc9a25a

Please sign in to comment.