Skip to content

Commit 0139ed6

Browse files
authored
Land rapid7#18931, adds notification when initially entering a SQL shell within SQL session types
2 parents b91b718 + 0fad7bb commit 0139ed6

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

lib/rex/post/sql/ui/console.rb

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,31 @@ def help_to_s(opts = {})
7777
super + format_session_compatible_modules
7878
end
7979

80+
#
81+
# Notification to display when initially interacting with the client via the query_interactive command
82+
#
83+
# @return [String]
84+
def interact_with_client_notification
85+
print_status("Starting interactive SQL shell for #{sql_prompt}")
86+
print_status('SQL commands ending with ; will be executed on the remote server. Use the %grnexit%clr command to exit.')
87+
print_line
88+
end
89+
90+
#
91+
# Create prompt via client and session data
92+
#
93+
# @return [String]
94+
def sql_prompt
95+
"#{session.type} @ #{client.peerinfo} (#{current_database})"
96+
end
97+
8098
#
8199
# Interacts with the supplied client.
82100
#
83101
def interact_with_client(client_dispatcher: nil)
84102
return unless client_dispatcher
85103

104+
interact_with_client_notification
86105
client.extend(InteractiveSqlClient) unless client.is_a?(InteractiveSqlClient)
87106
client.on_command_proc = self.on_command_proc if self.on_command_proc && client.respond_to?(:on_command_proc)
88107
client.on_print_proc = self.on_print_proc if self.on_print_proc && client.respond_to?(:on_print_proc)
@@ -96,8 +115,7 @@ def interact_with_client(client_dispatcher: nil)
96115
# @param [Object] val
97116
# @return [String]
98117
def format_prompt(val)
99-
prompt = "%und#{session.type} @ #{client.peerinfo} (#{current_database})%clr > "
100-
substitute_colors(prompt, true)
118+
substitute_colors("%und#{sql_prompt}%clr > ", true)
101119
end
102120

103121
#

0 commit comments

Comments
 (0)