Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds a notification when initially entering a SQL shell within SQL session types #18931

Conversation

cgranleese-r7
Copy link
Contributor

@cgranleese-r7 cgranleese-r7 commented Mar 6, 2024

This PR adds a notification when a user enters a SQL shell within SQL session types via the query_interactive command.

The aim was to offer some basic information to the users upon entering the shell.

image

Verification

  • Start msfconsole
  • Ensure you have the features set for the new session types - features set <session type> true
  • Get a session for Meterpreter, MySQL, MSSQL, PostgreSQL and SMB - mysql_login, mssql_login, postgres_login and smb_login
  • Verify the notification appears when entering each of the new session types
  • Verify code changes are sane

@cgranleese-r7 cgranleese-r7 added the rn-enhancement release notes enhancement label Mar 6, 2024
@cgranleese-r7 cgranleese-r7 force-pushed the adds-notification-when-initially-interacting-with-sql-shell branch from 69c787a to 7de3d97 Compare March 6, 2024 17:35
@cgranleese-r7 cgranleese-r7 changed the title Adds a notification when initially enters a SQL shell within SQL session types Adds a notification when initially entering a SQL shell within SQL session types Mar 7, 2024
@cgranleese-r7 cgranleese-r7 force-pushed the adds-notification-when-initially-interacting-with-sql-shell branch from 7de3d97 to 8c7a784 Compare March 7, 2024 11:20
# Create prompt via client and session data
#
# @return [String]
def prompt
Copy link
Contributor

@adfoster-r7 adfoster-r7 Mar 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this shadows the existing prompt method:

>> framework.sessions[1].console.method(:prompt)
=> #<Method: Rex::Post::PostgreSQL::Ui::Console(Rex::Ui::Text::Shell)#prompt() /Users/user/Documents/code/metasploit-framework/lib/rex/ui/text/shell.rb:290>

It looks like since you're not re-using this prompt method in more than one place, it would be good to revert - otherwise existing code that want to call the expected prompt method implementation will explode

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops I had meant to add it above as well. I can just remove it and handle both instances with

#{session.type} @ #{client.peerinfo} (#{current_database}

If that works for you?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good; just remember to rename the method to something that doesn't currently exist already 👍

@cgranleese-r7 cgranleese-r7 force-pushed the adds-notification-when-initially-interacting-with-sql-shell branch from 8c7a784 to 0fad7bb Compare March 7, 2024 11:34
@adfoster-r7 adfoster-r7 merged commit 0139ed6 into rapid7:master Mar 7, 2024
33 of 34 checks passed
@adfoster-r7
Copy link
Contributor

Release Notes

Adds additional help information when interacting with a SQL session

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rn-enhancement release notes enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants