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

Improve tab completion for set command. #18270

Merged
merged 1 commit into from
Sep 8, 2023

Conversation

pbarry25
Copy link
Contributor

@pbarry25 pbarry25 commented Aug 6, 2023

Tell us what this change does. If you're fixing a bug, please mention
the github issue number. ✅

  • Improve tab completion for set command.
  • Also minor improvement for tab completion with the unset command.

Fixes #18217.

Please ensure you are submitting from a unique branch in your repository to master in Rapid7's. ✅

Verification

List the steps needed to make sure this thing works

NOTE: that <TAB> seen below indicates pressing the tab key to initiate tab completion via the console.

  • Start msfconsole
  • test tab completion via set <TAB><TAB>
  • Verify you see all options offered (including -c,--clear, -g, --global, -h, --help)
  • test tab completion via set Log<TAB>
  • Verify command is tab completed to become set LogLevel
  • press enter to display current value of LogLevel
  • test tab completion via set -<TAB><TAB>
  • Verify you see only -c,--clear, -g, --global, -h, and --help options offered
  • type an additional -<TAB><TAB> (so that your command now looks like set --<TAB><TAB>)
  • Verify you see only --clear, --global, --help options offered
  • type an additional c<TAB> to tab complete as --clear
  • Verify your command is now set --clear
  • type an additional <TAB><TAB>
  • Verify you see completion options for ConsoleLogging, LogLevel, MeterpreterPrompt, etc.
  • type L<TAB>
  • Verify command is tab completed to set --clear LogLevel
  • press enter to clear LogLevel's value
  • select the exploit multi handler module via use exploit/multi/handler
  • type set PAY<TAB>
  • Verify it tab completes to set PAYLOAD
  • type <TAB><TAB>
  • Verify you are prompted to view all the available payloads
  • type n to not list all PAYLOADS
  • clear the command line (i.e. hit backspace a bunch)
  • type set LH<TAB>
  • Verify it tab completes to set LHOST
  • press enter to show LHOST's value
  • type set --clear LH<TAB>
  • Verify it tab completes to set --clear LHOST
  • Document the thing and how it works (Example)
    • N/A

@pbarry25
Copy link
Contributor Author

pbarry25 commented Aug 6, 2023

It's been a hot minute since I've been in the code base, happy to make any needed changes (or perhaps this becomes an example of Cunningham's law and someone writes a better solution... 😸).

Also minor improvement for tab completion with the `unset` command.

Fixes rapid7#18217.
@sjanusz-r7
Copy link
Contributor

Works as expected along with unset.

Following the verification steps:

  • Start msfconsole
  • Test tab completion via set <TAB><TAB>
msf6 payload(windows/x64/meterpreter_reverse_tcp) > set <TAB><TAB>
set --clear                      set AutoLoadStdapi               set ENCODER                      set InitialAutoRunScript         set MeterpreterPrompt            set PayloadUUIDTracking          set PromptChar                   set ReverseListenerThreaded      set SessionTlvLogging
set --global                     set AutoRunScript                set EXITFUNC                     set LHOST                        set MinimumRank                  set PingbackRetries              set PromptTimeFormat             set SessionCommunicationTimeout  set StagerRetryCount
set --help                       set AutoSystemInfo               set EXTENSIONS                   set LPORT                        set PayloadProcessCommandLine    set PingbackSleep                set ReverseAllowProxy            set SessionExpirationTimeout     set StagerRetryWait
set -c                           set AutoUnhookProcess            set EXTINIT                      set LogLevel                     set PayloadUUIDName              set PrependMigrate               set ReverseListenerBindAddress   set SessionLogging               set TimestampOutput
set -g                           set AutoVerifySessionTimeout     set EnableUnicodeEncoding        set MeterpreterDebugBuild        set PayloadUUIDRaw               set PrependMigrateProc           set ReverseListenerBindPort      set SessionRetryTotal            set VERBOSE
set -h                           set ConsoleLogging               set HandlerSSLCert               set MeterpreterDebugLogging      set PayloadUUIDSeed              set Prompt                       set ReverseListenerComm          set SessionRetryWait             set WORKSPACE
  • Verify you see all options offered (including -c, --clear, -g, --global, -h, --help)
  • Test tab completion via set Log<TAB>
msf6 payload(windows/x64/meterpreter_reverse_tcp) > set Log<TAB>
msf6 payload(windows/x64/meterpreter_reverse_tcp) > set LogLevel
  • Verify command is tab completed to become set LogLevel
  • Press enter to display current value of LogLevel
LogLevel =>
  • Test tab completion via set -<TAB><TAB>
msf6 payload(windows/x64/meterpreter_reverse_tcp) > set -<TAB><TAB>
set --clear   set --global  set --help    set -c        set -g        set -h
  • Verify you see only -c, --clear, -g, --global, -h, and --help options offered
  • Type an additional -<TAB><TAB> (so that your command now looks like set --<TAB><TAB>)
msf6 payload(windows/x64/meterpreter_reverse_tcp) > set --
set --clear   set --global  set --help
  • Verify you see only --clear, --global, --help options offered
  • Type an additional c<TAB> to tab complete as --clear
  • Verify your command is now set --clear
  • Type an additional
msf6 payload(windows/x64/meterpreter_reverse_tcp) > set --clear
set --clear AutoLoadStdapi               set --clear ENCODER                      set --clear InitialAutoRunScript         set --clear MeterpreterPrompt            set --clear PayloadUUIDTracking          set --clear PromptChar                   set --clear ReverseListenerThreaded      set --clear SessionTlvLogging
set --clear AutoRunScript                set --clear EXITFUNC                     set --clear LHOST                        set --clear MinimumRank                  set --clear PingbackRetries              set --clear PromptTimeFormat             set --clear SessionCommunicationTimeout  set --clear StagerRetryCount
set --clear AutoSystemInfo               set --clear EXTENSIONS                   set --clear LPORT                        set --clear PayloadProcessCommandLine    set --clear PingbackSleep                set --clear ReverseAllowProxy            set --clear SessionExpirationTimeout     set --clear StagerRetryWait
set --clear AutoUnhookProcess            set --clear EXTINIT                      set --clear LogLevel                     set --clear PayloadUUIDName              set --clear PrependMigrate               set --clear ReverseListenerBindAddress   set --clear SessionLogging               set --clear TimestampOutput
set --clear AutoVerifySessionTimeout     set --clear EnableUnicodeEncoding        set --clear MeterpreterDebugBuild        set --clear PayloadUUIDRaw               set --clear PrependMigrateProc           set --clear ReverseListenerBindPort      set --clear SessionRetryTotal            set --clear VERBOSE
set --clear ConsoleLogging               set --clear HandlerSSLCert               set --clear MeterpreterDebugLogging      set --clear PayloadUUIDSeed              set --clear Prompt                       set --clear ReverseListenerComm          set --clear SessionRetryWait             set --clear WORKSPACE
  • Verify you see completion options for ConsoleLogging, LogLevel, MeterpreterPrompt, etc.
  • Type L<TAB>
  • Verify command is tab completed to set --clear LogLevel
msf6 payload(windows/x64/meterpreter_reverse_tcp) > set --clear L
set --clear LHOST     set --clear LOGLEVEL  set --clear LPORT
msf6 payload(windows/x64/meterpreter_reverse_tcp) > set --clear LO<TAB>
msf6 payload(windows/x64/meterpreter_reverse_tcp) > set --clear LOGLEVEL
  • Press enter to clear LogLevel's value
  • Select the exploit multi handler module via use exploit/multi/handler
  • Type set PAY<TAB>
  • Verify it tab completes to set PAYLOAD
  • Type <TAB><TAB>
  • Verify you are prompted to view all the available payloads
  • Type n to not list all PAYLOADS
msf6 exploit(multi/handler) > set PAYLOAD <TAB><TAB>
Display all 1311 possibilities? (y or n) n
  • Clear the command line (i.e. hit backspace a bunch)
  • Type set LH<TAB>
  • Verify it tab completes to set LHOST
  • Press enter to show LHOST's value
  • Type set --clear LH<TAB>
  • Verify it tab completes to set --clear LHOST
msf6 exploit(multi/handler) > set --clear LH<TAB><TAB>
msf6 exploit(multi/handler) > set --clear LHOST

@pbarry25
Copy link
Contributor Author

pbarry25 commented Sep 7, 2023

TYSM for kicking the t[iy]res, @sjanusz-r7! 👋 🙂

@sjanusz-r7 sjanusz-r7 merged commit 740f026 into rapid7:master Sep 8, 2023
34 checks passed
@adfoster-r7 adfoster-r7 added the rn-enhancement release notes enhancement label Sep 8, 2023
@sjanusz-r7
Copy link
Contributor

Release Notes

Improves tab completion for the set and unset commands.

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.

set --clear is missing tab complete support
3 participants