Commit Graph

13785 Commits

Author SHA1 Message Date
usiegl00 0259e586a9 Update smb_shadow module and rename MitmDispatcher
The MitmDispatcher is now the ShadowMitmDispatcher to help prevent name
confusion. Updated the ShadowMitmDispatcher to use native rex lib calls
to decode binary fields.
2022-01-28 08:39:07 +09:00
Grant Willcox 397e3aa1c6 Land #16090 - Add in user_data_directory function 2022-01-26 09:31:52 -06:00
Spencer McIntyre 12431d8479 Add a client reader for SSH server channels 2022-01-24 14:41:59 -05:00
Spencer McIntyre dd2d512851 Support session -1 for ListenerComm options 2022-01-24 11:42:39 -05:00
audibleblink e445a39719 adds user_data_directory 2022-01-23 10:29:01 -05:00
usiegl00 5cc716fa0d Add MitmDispatcher to the smb_shadow module
The MitmDispatcher reduces code repetition and enables the use of
standard RubySMB syntax. I have noticed increased power draw when using
the new dispatcher compared to the previous (less stateful) approach.
2022-01-21 14:57:07 +09:00
bwatters 4cf3ae352c Land #16050, Log4Shell: vCenter RCE
Merge branch 'land-16050' into upstream-master
2022-01-19 16:30:33 -06:00
Grant Willcox a7bb8d0480 Land #16029, Fix OptPath options with empty strings 2022-01-19 13:08:34 -06:00
sjanusz 158a0aa30c Change custom parser to Rex, add custom opt, add tabcomplete 2022-01-19 13:01:33 +00:00
space-r7 383ada6ae2 Land #16016, fix RHOSTS in dcerpc scanner 2022-01-13 13:15:24 -06:00
Spencer McIntyre 7b1398f0ae Allow overriding check module datastore options 2022-01-13 11:51:39 -05:00
Spencer McIntyre 62a814fa59 Refactor Log4shell exploit code into reusable bits 2022-01-13 09:45:02 -05:00
Spencer McIntyre e093154865 Refactor the BeanFactory gadget code 2022-01-12 16:58:31 -05:00
Spencer McIntyre e873907d13 Initial vCenter exploit via Log4Shell 2022-01-12 15:34:45 -05:00
space-r7 199eae5e99 Land #16012, add pi-hole aux module and lib 2022-01-12 09:21:11 -06:00
Spencer McIntyre 877bab6f2a Land #15969, Log4j2 HTTP Header Injection Exploit 2022-01-11 16:52:08 -05:00
Spencer McIntyre f56f328c8d Use an enum for the YSoSerial payload option 2022-01-07 17:30:39 -05:00
Christophe De La Fuente 59de13be43 Do not call File.expand_path() with empty strings 2022-01-07 13:09:47 +01:00
bwatters f17d460a7a Remove now unused deregister_tcp_options method 2022-01-06 15:48:24 -06:00
Spencer McIntyre 41b2bc4fac Fix the generate command's tab completion 2022-01-06 15:15:49 -05:00
space-r7 27ad15d040 Land #16015, fix tab completion for RHOSTS 2022-01-06 10:44:33 -06:00
Spencer McIntyre 4b37076bd4 Unify completion for OptAddressRange and OptRhosts 2022-01-05 14:11:43 -05:00
Spencer McIntyre 1e0d9af9d8 Fix tab completion for RHOSTS 2022-01-05 13:43:34 -05:00
Christophe De La Fuente f3f6f93e23 Fix sanity check failing on specific Ubuntu versions 2022-01-05 18:26:19 +01:00
Christophe De La Fuente ae2e4d723b Add NTDS technique 2022-01-03 21:39:33 +01:00
h00die 990e4a1e7a pihole new module and lib 2022-01-02 11:48:41 -05:00
h00die c3e0f455ec some cleanup for rubocop 2021-12-30 15:35:22 -05: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
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
Tim W 8d808d11c0 Land #15941, fix command output in rpc console.write 2021-12-21 06:07:29 +00:00
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
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