-
Notifications
You must be signed in to change notification settings - Fork 14k
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
Show errors on inaccessible payload files #18405
Show errors on inaccessible payload files #18405
Conversation
d601648
to
8efc6ca
Compare
8efc6ca
to
618bd08
Compare
618bd08
to
e70f356
Compare
@@ -58,7 +58,7 @@ def generate_jar(opts={}) | |||
jar = Rex::Zip::Jar.new | |||
jar.add_sub("metasploit") if opts[:random] | |||
jar.add_file("metasploit.dat", stager_config(opts)) | |||
jar.add_files(paths, MetasploitPayloads.path('java')) | |||
jar.add_files(paths, ::MetasploitPayloads.path('java')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For context: Without this change, the tests were failing with:
2) modules/payloads java/shell_reverse_tcp it should behave like payload cached size is consistent java/shell_reverse_tcp has a valid cached_size
Failure/Error: generate_jar(opts).pack
NameError:
uninitialized constant Msf::Modules::Payload__Singles__Java__Shell_reverse_tcp::MetasploitModule::MetasploitPayloads
Shared Example Group: "payload cached size is consistent" called from ./spec/modules/payloads_spec.rb:1555
# ./modules/payloads/singles/java/shell_reverse_tcp.rb:39:in `block in generate_jar'
# ./modules/payloads/singles/java/shell_reverse_tcp.rb:32:in `each'
# ./modules/payloads/singles/java/shell_reverse_tcp.rb:32:in `generate_jar'
# ./lib/msf/core/payload/java.rb:35:in `generate'
begin | ||
path = MetasploitPayloads.meterpreter_path(modname, suffix, debug: client.debug_build) | ||
rescue ::StandardError => e | ||
elog(e) | ||
path = nil | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without this change, some tests were failing with:
1.31) Failure/Error: expect(test_result).to include(acceptable_failure.value)
expected "[-] Post failed: MetasploitPayloads::NotFoundError Meterpreter path D:/a/metasploit-framework/metasp...work/metasploit-framework/lib/msf/core/post.rb:28:in `setup'\r\n[*] Post module execution completed" to include "[-] [should raise a runtime exception if services doesnt exist] FAILED: should raise a runtime exception if services doesnt exist"
Diff:
@@ -1,11 +1,21 @@
-[-] [should raise a runtime exception if services doesnt exist] FAILED: should raise a runtime exception if services doesnt exist
+[-] Post failed: MetasploitPayloads::NotFoundError Meterpreter path D:/a/metasploit-framework/metasploit-framework/vendor/bundle/ruby/3.0.0/gems/metasploit-payloads-2.0.154/data/meterpreter/ext_server_extapi.jar not found. Ensure antivirus is not enabled, or reinstall Metasploit.
+[-] Call stack:
+[-] D:/a/metasploit-framework/metasploit-framework/vendor/bundle/ruby/3.0.0/gems/metasploit-payloads-2.0.154/lib/metasploit-payloads.rb:112:in `meterpreter_path'
+[-] D:/a/metasploit-framework/metasploit-framework/lib/rex/post/meterpreter/client_core.rb:366:in `use'
+[-] D:/a/metasploit-framework/metasploit-framework/lib/msf/core/post_mixin.rb:321:in `block in meterpreter_session_incompatibility_reasons'
+[-] D:/a/metasploit-framework/metasploit-framework/lib/msf/core/post_mixin.rb:316:in `each'
+[-] D:/a/metasploit-framework/metasploit-framework/lib/msf/core/post_mixin.rb:316:in `meterpreter_session_incompatibility_reasons'
+[-] D:/a/metasploit-framework/metasploit-framework/lib/msf/core/post_mixin.rb:226:in `session_incompatibility_reasons'
+[-] D:/a/metasploit-framework/metasploit-framework/lib/msf/core/post_mixin.rb:58:in `setup'
+[-] D:/a/metasploit-framework/metasploit-framework/lib/msf/core/post.rb:28:in `setup'
+[*] Post module execution completed
# ./spec/acceptance/meterpreter_spec.rb:426:in `block (11 levels) in <top (required)>'
# ./spec/acceptance/meterpreter_spec.rb:422:in `each'
# ./spec/acceptance/meterpreter_spec.rb:422:in `block (10 levels) in <top (required)>'
I now get warnings that I have custom meterpreter dlls:
Booting console then deleting the payload works:
Using a stager when meterpreter dll isn't present:
Verifying that local DLLs can still be used, even if the gem data was removed
|
Release NotesUpdates msfconsole to detect and warn users when Metasploit payloads may have been deleted by antivirus or similar. This functionality is currently behind a feature flag, which can be enabled with |
This PR requires rapid7/metasploit-payloads#673
It allows for outputting error messages on startup if any Metasploit Payload files defined in the manifest file are missing or the user does not have read permissions for.
This PR also adds error messages when calling
to_handler
on a stageless payload, as well as when a payload reaches out for a stage that is not accessible.Java Payload Sizes
The Java payload sizes are slightly different due Java compiler changes. Prior to this release we used
The changes are minimal; Small change in the try/if logic:
And some changes in the constant pool, verified with:
Diff:
Verification
msfconsole
payload/python/meterpreter/reverse_tcp
normallydata/meterpreter/meterpreter.py
tometerpreter.py2
msfconsole
meterpreter.py
use payload/python/meterpreter/reverse_tcp
worksto_handler
Meterpreter path meterpreter/meterpreter.py not found.
use payload/python/meterpreter_reverse_tcp
(inline)to_handler
results inMeterpreter path meterpreter/meterpreter.py not found.
log
meterpreter.py2
file back tometerpreter.py
meterpreter.py
file with an additional empty linemsfconsole
meterpreter.py
Example Output
Staged
When the file is inaccessible, this is expected to fail when a payload reaches back to MSF Console for a stage.
Stageless
When the file is inaccessible, this is expected to fail when calling
to_handler
.