metasploit-framework icon indicating copy to clipboard operation
metasploit-framework copied to clipboard

Reloading payloads doesn't work

Open adfoster-r7 opened this issue 4 years ago • 2 comments

Steps to reproduce

msf6 payload(python/meterpreter_reverse_http) > reload
[*] Reloading module...
[-] Failed to reload: undefined method `loader' for Object:Class

Version

msf6 payload(python/meterpreter_reverse_http) > version
Framework: 6.1.33-dev-e9393e471c
Console  : 6.1.33-dev-e9393e471c

adfoster-r7 avatar Mar 07 '22 12:03 adfoster-r7

Hi!

This issue has been left open with no activity for a while now.

We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s been at least 30 days since the last update here. If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!

As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request.

github-actions[bot] avatar Apr 06 '22 15:04 github-actions[bot]

I took a look into this. It looks like the error is being caused when payloads reload and hit this line: https://github.com/rapid7/metasploit-framework/blob/fedcdc386b1bf06c7fd46d1f196c2c926630d8a7/lib/msf/core/module_manager/reloading.rb#L24 I did some debugging to find this in the stack trace. Based on what I can tell, it's because the payload module that's being reloaded does not have a parent class, which is why when the loader is accessed, we get a nil value. I'm not exactly certain of the heirarchy of modules/classes to pin it down, but at a first glance I notice this doesn't happen in auxiliary/exploit/etc modules because they all are subclasses of their main category module (e.g. https://github.com/rapid7/metasploit-framework/blob/master/modules/auxiliary/scanner/http/azure_ad_login.rb) whereas the payload modules do not, which would explain them not having a parent class available for the reload (e.g. https://github.com/rapid7/metasploit-framework/blob/master/modules/payloads/singles/python/meterpreter_reverse_http.rb). I'm not entirely sure where to fix this in the lib, but these details might help someone who can

k0pak4 avatar Oct 18 '22 23:10 k0pak4

Thanks for taking a look! I don't frequently need to reload payloads, so I'll mark this as closed for now.

I believe we'd need to make changes to support calling the recalculation of payload sets to reload a payload module; as a payload module could consist of multiple stages from the filesystem - unlike aux/post/etc modules which have a 1:1 mapping of Ruby code to a file sitting on the disk

adfoster-r7 avatar Apr 25 '23 12:04 adfoster-r7

Thanks for your contribution to Metasploit Framework! We've looked at this issue, and unfortunately we do not currently have the bandwidth to prioritize this issue.

We've labeled this as attic and closed it for now. If you believe this issue has been closed in error, or that it should be prioritized, please comment with additional information.

github-actions[bot] avatar Apr 25 '23 12:04 github-actions[bot]

For people trying to develop a payload, you can use msfvenom for dev / test cycles

msfvenom  -p windows/my_windows_payload

tinmarino avatar Sep 28 '23 20:09 tinmarino