Skip to content

Commit

Permalink
Adds a notification when initially interatcing with SQL shell via com…
Browse files Browse the repository at this point in the history
…mand
  • Loading branch information
cgranleese-r7 committed Mar 6, 2024
1 parent 8f759af commit 69c787a
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions lib/rex/post/sql/ui/console.rb
Expand Up @@ -77,12 +77,30 @@ def help_to_s(opts = {})
super + format_session_compatible_modules
end

#
# Notification to display when initially interacting with the client via the query_interactive command
#
# @return [String]
def interact_with_client_notification
print_good("[*] Starting interactive SQL shell for #{session.type} @ #{client.peerinfo} (#{current_database})")
print_good('[*] SQL commands ending with ; will be executed on the remote server. Use the %grnexit%clr command to exit.')
end

#
# Create prompt via client and session data
#
# @return [String]
def prompt
"#{session.type} @ #{client.peerinfo} (#{current_database})"
end

#
# Interacts with the supplied client.
#
def interact_with_client(client_dispatcher: nil)
return unless client_dispatcher

interact_with_client_notification
client.extend(InteractiveSqlClient) unless client.is_a?(InteractiveSqlClient)
client.on_command_proc = self.on_command_proc if self.on_command_proc && client.respond_to?(:on_command_proc)
client.on_print_proc = self.on_print_proc if self.on_print_proc && client.respond_to?(:on_print_proc)
Expand All @@ -96,8 +114,7 @@ def interact_with_client(client_dispatcher: nil)
# @param [Object] val
# @return [String]
def format_prompt(val)
prompt = "%und#{session.type} @ #{client.peerinfo} (#{current_database})%clr > "
substitute_colors(prompt, true)
substitute_colors("%und#{prompt}%clr > ", true)
end

#
Expand Down

0 comments on commit 69c787a

Please sign in to comment.