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

Allows set PAYLOAD parameters to begin with /, payload/, & /payload/ #12946

Merged
merged 6 commits into from
Feb 19, 2020

Conversation

agalway-r7
Copy link
Contributor

@agalway-r7 agalway-r7 commented Feb 18, 2020

When setting a module PAYLOAD value, you are currently unable to set a payload if it's path begins with /, payload/, & /payload/. This is a pain when copy pasting full paths into set PAYLOAD commands.

This PR adds a regex statement to catch and remove the above three path beginnings to the command_dispatcher/core.rb, allowing the underlying code to retrieve the payload correctly without the user having to change their input.

Verification

List the steps needed to make sure this thing works

  • Start msfconsole
  • use crosschex
  • set PAYLOAD /payload/windows/x64/vncinject/reverse_winhttps
  • set PAYLOAD payload/windows/x64/vncinject/reverse_winhttps
  • set PAYLOAD /windows/x64/vncinject/reverse_winhttps
  • set PAYLOAD windows/x64/vncinject/reverse_winhttps
  • Verify all four of the above inputs return PAYLOAD => windows/x64/vncinject/reverse_winhttps

@agalway-r7 agalway-r7 changed the title Allows set PAYLOAD parameters to begin with \, payload\, & \payload\ Allows set PAYLOAD parameters to begin with /, payload/, & /payload/ Feb 18, 2020
@wvu
Copy link
Contributor

wvu commented Feb 18, 2020

Somewhat related tickets: #7734 and #8882.

# Ensure we have a reference name and not a path
if mod_name.start_with?('./', 'modules/')
mod_name.sub!(%r{^(?:\./)?modules/}, '')
end
if mod_name.end_with?('.rb')
mod_name.sub!(/\.rb$/, '')
end

Copy link
Contributor

@wvu wvu left a comment

Choose a reason for hiding this comment

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

I don't think rn-no-release-notes is warranted here. This is a significant change to core code.

@agalway-r7 agalway-r7 added rn-enhancement release notes enhancement and removed rn-no-release-notes no release notes labels Feb 18, 2020
Copy link
Contributor

@wvu wvu left a comment

Choose a reason for hiding this comment

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

Perhaps using a single shared code between cmd_set and cmd_use in lib/msf/ui/console/command_dispatcher/common.rb is best.

@wvu wvu self-assigned this Feb 18, 2020
@wvu
Copy link
Contributor

wvu commented Feb 19, 2020

msf5 exploit(windows/misc/crosschex_device_bof) > set PAYLOAD /payload/windows/x64/vncinject/reverse_winhttps
PAYLOAD => windows/x64/vncinject/reverse_winhttps
msf5 exploit(windows/misc/crosschex_device_bof) > set PAYLOAD payload/windows/x64/vncinject/reverse_winhttps
PAYLOAD => windows/x64/vncinject/reverse_winhttps
msf5 exploit(windows/misc/crosschex_device_bof) > set PAYLOAD /windows/x64/vncinject/reverse_winhttps
PAYLOAD => windows/x64/vncinject/reverse_winhttps
msf5 exploit(windows/misc/crosschex_device_bof) > set PAYLOAD windows/x64/vncinject/reverse_winhttps
PAYLOAD => windows/x64/vncinject/reverse_winhttps
msf5 exploit(windows/misc/crosschex_device_bof) >

Excellent enhancement.

@wvu
Copy link
Contributor

wvu commented Feb 19, 2020

Btw, the verification steps use an x64 payload, which is not supported by the module, but setting it works fine.

@wvu
Copy link
Contributor

wvu commented Feb 19, 2020

msf5 exploit(windows/misc/crosschex_device_bof) > show payloads

Compatible Payloads
===================

   #    Name                                                Disclosure Date  Rank    Check  Description
   -    ----                                                ---------------  ----    -----  -----------
[snip]
   166  windows/vncinject/reverse_winhttp                                    normal  No     VNC Server (Reflective Injection), Windows Reverse HTTP Stager (winhttp)

msf5 exploit(windows/misc/crosschex_device_bof) > set payload 166
payload => windows/vncinject/reverse_winhttp
msf5 exploit(windows/misc/crosschex_device_bof) >

Setting the payload by index still works. 👍

wvu added a commit that referenced this pull request Feb 19, 2020
@wvu wvu merged commit e25cf99 into rapid7:master Feb 19, 2020
@wvu
Copy link
Contributor

wvu commented Feb 19, 2020

Thanks for this! Quotes cleaned up in c591704.

@wvu
Copy link
Contributor

wvu commented Feb 19, 2020

Release Notes

This enhances the set PAYLOAD command to strip path-like prefixes from its value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants