Commit Graph

20644 Commits

Author SHA1 Message Date
Metasploit ca3c80102a Bump version of framework to 6.1.23 2021-12-30 12:11:12 -06:00
RageLtMan 4874943e7f Implement infrastructure for payload delivery
Per the discussion with @schierlm on GitHub (mihi), the most direct
way to deliver and instantiate our Java payload in the target is
via remote code loading of the JAR using HTTP. This requires a
bootstrap class, a Factory, which instantiates our Payload.class
by calling its main() function on-load from the HTTP endpoint
serving the remote-code-loaded JAR.

Implement a basic PayloadFactory class and include and its sources
in the Metasploit tree.

Using @schierlm's own code from ~10y ago, implement injection of
the PayloadFactory class into our JAR-encoded payloads. Then,
using more of his code from the same module (2011-3544), implement
a secondary service within the exploit module (Rex::ServiceManager
services don't stack well in Msf namespace as they all get assigned
to self.service - faux pas on our end) to serve HTTP requests with
the injected JAR. Finally, generate an appropriate URL target for
the remote code loaded JAR for injection into the LDAP response and
leveraging a final piece of @schierlm's hackery, generate a valid
URI path (updating the datastore is ill advised @ runtime, but its
needed here for the correct service cleanup routines to fire).

Note: during development, i figured out a way to use Rjb for native
Java object serialization to buffers which we can use in Ruby, so i
stashed that away in the Exploit::Java mixin for posterity and left
a reference to it in the module for future endeavors.

Testing:
  Verified that the generated jar is served at the generated URL
  Verified that the generated JAR can be executed at the CLI for
both metasploit.Payload and metasploit.PayloadFactory
  Currently not triggering the remote code load (per wireshark and
our own HTTP service) when delivering the LDAP response, so tuning
that is the next leg of this effort.
2021-12-29 09:10:07 -05:00
Spencer McIntyre d08714d474 Land #15961, Initial Rex LDAP Server 2021-12-28 14:50:03 -05:00
Brenton O'Loughlin e0d0514814 relocate status output 2021-12-24 17:51:04 +07:00
Tim W 5631959eff Fix #12895, fix console.read does not return command output 2021-12-24 07:51:25 +00:00
Tim W b1922c305b Revert "Land #15941, fix command output in rpc console.write"
This reverts commit 8d808d11c0, reversing
changes made to c1f06eace8.
2021-12-24 07:32:29 +00:00
bwatters 6ed8e317f7 Land #15984, fix snmp library to run correct version
Merge branch 'land-15984' into upstream-master
2021-12-23 13:12:49 -06:00
Metasploit 8757971193 Bump version of framework to 6.1.22 2021-12-23 12:10:50 -06:00
RageLtMan 25e2fbd640 Do not redefine constant 2021-12-21 22:36:51 -05:00
Tim W 8d808d11c0 Land #15941, fix command output in rpc console.write 2021-12-21 06:07:29 +00:00
h00die 1931bfab7b fix snmp library to run correct version 2021-12-20 16:28:01 -05:00
3V3RYONE 56b19e5e9b Fix exploit session crashing when unsetting smbuser or smbpass 2021-12-19 19:02:17 +05:30
RageLtMan 60fdf2a7da Rubocop pass on LDAP pieces 2021-12-18 09:03:56 -05:00
RageLtMan 0e90c3e573 Address @adfoster-r7's change requests
Due to how this stack is being broken up into LDAP core, scanner
update, and exploit work, changes requested in #15972 actually
apply in this branch and get rebased to the remaining ones.

Address requests to clean up the textual messages, LDIF file read,
sourcing of LDAP methods from net-ldap, and YARD-related placement
of attr_* annotations.
2021-12-18 07:52:33 -05:00
RageLtMan db8f4ffa6f Native LDAP infrastructure to support log4shell
In order to detect scan callbacks, serve payloads, and otherwise
interact with the LDAP protocol handler in JNDI, Metasploit needs
a native LDAP service properly exposed to various parts of the
Framework and users/consumers.

Implement Rex::Protocol::LDAP::Server with TCP and UDP socket
handlers abstracted to a common access pattern between L4 stacks.
Extend the socket clients to hold a state attibute for LDAP bind
authentication, and use the UDP client abstraction to implement
consistent callback semantics for data receipt from a client and
handling response on the other side. The server utilizes Rex'
native sockets, permitting full pivot and proxy support over the
Switchboard.

Implement the Msf::Exploit::Remote::LDAP::Server mixin to manage
service abstraction and shared methods exposed to Metasploit
modules.
Note: during implementation of this functionality, it was
discovered that the Scanner mixin's :replicant method resulted in
:dup calls to the Rex::ServiceManager service created by this new
mixin (and any others leveraging ServiceManager). As a result,
double-bind attempts created failures in service instantiation from
the duplicated MetasploitModules which also dropped the @service
instance variable reference to the actual running service; leaving
the socket inexorably bound until Framework was halted and Ruby
released the FDs. See https://github.com/rapid7/rex-core/pull/19
and the Issues/Pull Requests sections of R7's MSF GitHub.

Expose the new LDAP infrastructure to users by way of a basic LDAP
server MetasploitModule which consumes a tiny sample LDIF (provided)
and performs queries against it. This is intended to be a template
for future work such as LDAP authentication capture, protocol proxy
for MITM and intercept, and other more specific implementations for
exploits and auxiliary modules.

For feature completeness, provide a Rex::Socket override for
Net::LDAP::Connection until we have a proper, native to Rex, LDAP
client class implemented.

Testing:
  Basic functionality only, this is an early effort which will be
extended for feature-completeness over time
2021-12-16 18:47:52 -05:00
space-r7 184795513f Land #15831, add more ssh session support 2021-12-16 15:39:55 -06:00
Grant Willcox 5c2afd6750 Land #15882, Prevent payloads being used if can't clean up files 2021-12-16 15:05:27 -06:00
bwatters 1642f917ab Land #15964, Fix json packrat module
Merge branch 'land-15964' into upstream-master
2021-12-16 14:19:51 -06:00
Metasploit 5cd5d1449b Bump version of framework to 6.1.21 2021-12-16 12:22:49 -06:00
Grant Willcox 0ee427ddb9 Land #15965, Add tcp uri scheme for setting rhosts 2021-12-16 12:07:37 -06:00
bwatters fd2f27aa94 Land #15958, Log4Shell HTTP Scanner
Merge branch 'land-15958' into upstream-master
2021-12-16 10:45:23 -06:00
Spencer McIntyre e6b7669114 Address PR feedback from module hacking 2021-12-16 11:12:11 -05:00
Grant Willcox 4cbc9113ae Land #15963, Support go 1.17 and remove startup errors for modules 2021-12-15 17:51:31 -06:00
Grant Willcox 2e7e24a833 Land #15779, Add Nil-Check in Auxiliary report for vuln reporting 2021-12-15 11:52:48 -06:00
adfoster-r7 a373450b65 Add tcp uri scheme for setting rhosts 2021-12-15 15:37:05 +00:00
adfoster-r7 c3685641ab Fix json packrat module 2021-12-15 15:07:38 +00:00
adfoster-r7 f1427fd383 Land #15944, Add support and tests for long arguments to Rex Parser 2021-12-15 14:55:44 +00:00
Spencer McIntyre 5e5e73a1d8 Add module metadata and more checks 2021-12-15 08:45:25 -05:00
adfoster-r7 9c94a052bd Support go 1.17 and remove startup errors for modules 2021-12-15 13:45:10 +00:00
Matthew Dunn c6a84c912b Switch to a validation error 2021-12-15 07:13:29 -05:00
Matthew Dunn 608ced1a4b Add raise if vuln is nil instead of a print 2021-12-14 20:31:28 -05:00
Matthew Dunn cb385192b6 Merge branch 'rapid7:master' into nil_check_auxiliary_report 2021-12-14 20:15:13 -05:00
sjanusz 063c3936a9 Add support for long arguments to Rex Parser 2021-12-14 17:45:56 +00:00
Grant Willcox 4600ffa702 Land #15957, Print error when session ID is nil for Kiwi's creds_all 2021-12-14 09:28:08 -06:00
sjanusz 210f704a77 Print error when session id is nil for kiwi creds_all 2021-12-14 10:16:52 +00:00
Tim cfd2d4d114 improve passthrough to capture stderr (#1) 2021-12-14 15:35:25 +11:00
Brenton O'Loughlin bb688e12b8 capture passthrough system command output to output handler 2021-12-14 15:35:25 +11:00
bwatters c4443577d0 Land #15841, Rubocop Packrat mixin, part 2
A commit happened between my checkout and my merge, this incorporates the lost commit

Merge branch 'land-15841' into upstream-master
2021-12-13 15:50:14 -06:00
bwatters 3d2e00f87d Land #15841, Rubocop packrat mixin 2021-12-13 15:42:13 -06:00
adfoster-r7 7f2d2c180b Rubocop Packrat mixin
Add linting exceptions for eval logic

wip
2021-12-13 19:36:26 +00:00
adfoster-r7 48f40077ea Add get processes requirement 2021-12-13 13:46:54 +00:00
adfoster-r7 4c02405ab5 Ignore stdapi_fs_chmod requirement on windows 2021-12-13 13:06:02 +00:00
adfoster-r7 24bf9e5e61 Add Meterpreter compatibility requirements to lib 2021-12-13 11:30:32 +00:00
h00die 950e976f7b Land #15952 fix for ntlm hashes crashing creds -d command 2021-12-13 05:00:51 -05:00
sjanusz acd55ea24f Fix creds crashing when deleting multiple ntlm hashes 2021-12-10 16:08:55 +00:00
Tim W e0d618b8a9 Land #15945, fix stat on inaccessible directory 2021-12-10 06:19:52 +00:00
Metasploit 26cde48c13 Bump version of framework to 6.1.20 2021-12-09 13:24:04 -06:00
Spencer McIntyre ad0dba9385 Display st_mode using 6 octal digits 2021-12-09 13:43:00 -05:00
Spencer McIntyre 82a22ad38c Skip empty stat buffers
This skips empty stat buffers, allowing Meterpreter to return empty ones
for entries that can not be stat'ed and thus maintain the array
alignment.
2021-12-09 13:43:00 -05:00
Tim W 4696418089 Land #15939, Fix #15919, fix unpacking 64-bits stat buffers in meterpreter 2021-12-09 08:40:49 +00:00