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

Reloading payloads doesn't work

Open adfoster-r7 opened this issue 2 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