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

Build and ship debug builds for windows meterpreter #553

Merged

Conversation

dwelch-r7
Copy link
Contributor

@dwelch-r7 dwelch-r7 commented Mar 9, 2022

Builds and packages the debug versions of Windows Meterpreter into the metasploit-payloads gem

The debug versions of the build will have the suffix .debug.dll instead of just .dll and there will be an accompanying framework PR rapid7/metasploit-framework#16320 to add a datastore option for specifying the debug version

Side note: Spent some time trying to get the debug builds working with CMake on linux too, was able to build them all but not gain a stable session, it's not currently used by any automation so might come back to it at some point later

@@ -39,7 +37,8 @@ def self.readable_path(gem_path, *extra_paths)
#
# Get the path to a meterpreter binary by full name.
#
def self.meterpreter_path(name, binary_suffix)
def self.meterpreter_path(name, binary_suffix, debug: false)
binary_suffix&.gsub!(/dll$/, 'debug.dll') if debug
Copy link
Contributor

@adfoster-r7 adfoster-r7 Mar 9, 2022

Choose a reason for hiding this comment

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

It's best to avoid mutating strings that aren't owned by this function, otherwise weird bugs can occur.

Suggested change
binary_suffix&.gsub!(/dll$/, 'debug.dll') if debug
binary_suffix = debug ? "debug.#{binary_suffix}" : binary_suffix

@@ -39,7 +37,8 @@ def self.readable_path(gem_path, *extra_paths)
#
# Get the path to a meterpreter binary by full name.
#
def self.meterpreter_path(name, binary_suffix)
def self.meterpreter_path(name, binary_suffix, debug: false)
binary_suffix&.gsub!(/dll$/, 'debug.dll') if debug
Copy link
Contributor

Choose a reason for hiding this comment

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

It's best to avoid mutating strings that aren't owned by this function, otherwise weird bugs can occur.

Suggested change
binary_suffix&.gsub!(/dll$/, 'debug.dll') if debug
binary_suffix = debug ? "debug.#{binary_suffix}" : binary_suffix if debug

@sjanusz-r7
Copy link
Contributor

I built the debug and release libraries in Visual Studio 2022, version 17.1.0. I did have to install C++ Windows XP Support for VS 2017 (v141) tools [Deprecated] as an individual component as retargeting the projects/solution to use the latest version that VS2022 comes with did not seem to work on my end.

When getting a payload/windows/x64/meterpreter/reverse_tcp or payload/windows/x64/meterpreter_reverse_tcp shell with set DEBUG true, I see debug output being logged to DebugView.

Example Debug Output

image

With set DEBUG false, no log output is being output to DebugView.

@sempervictus
Copy link

🤦‍♂️ of course just after i finish an ungodly meterpreter debug procedure do i find this little gem. Thanks for wiring this up

@adfoster-r7 adfoster-r7 merged commit cf5ab07 into rapid7:master Apr 1, 2022
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.

4 participants