Commit Graph

35981 Commits

Author SHA1 Message Date
bwatters 809dc1754d Fix the bug 2022-01-05 16:57:17 -06:00
lap1nou c9cc6d85ac Refactored code by using Zabbix HTTP API, should work with 2.x, 3.x, 4.x, 5.x 2022-01-05 13:35:40 -08:00
Spencer McIntyre d0417f60bd Land #15924, Updates to Windows Secrets Dump 2022-01-05 13:25:59 -05:00
space-r7 3ef9afb0fc Land #15988, add wp catch themes file upload 2022-01-04 14:44:06 -06:00
space-r7 e26eb2b193 display full path in print_status() 2022-01-04 14:43:04 -06:00
h00die c6372ecdf1 more wp catch themes doc and error handling 2022-01-04 04:34:42 -05:00
lap1nou 6aa289f3dc Merged both module, stil WIP 2022-01-03 16:20:16 -08:00
Christophe De La Fuente 86acad0034 Update Gemfile to pull the new ruby_smb gem and add progress indicator 2022-01-03 21:39:54 +01:00
Christophe De La Fuente bb333df3e5 Update Gemfile.lock to pull new ruby_smb updates & fix some issues with Ruby 3 2022-01-03 21:39:54 +01:00
Christophe De La Fuente ae2e4d723b Add NTDS technique 2022-01-03 21:39:33 +01:00
Christophe De La Fuente da88388e01 Add actions 2022-01-03 21:39:33 +01:00
h00die 990e4a1e7a pihole new module and lib 2022-01-02 11:48:41 -05:00
lapinou 18834f673c Add files via upload 2022-01-02 00:29:36 +01:00
h00die c3e0f455ec some cleanup for rubocop 2021-12-30 15:35:22 -05:00
RageLtMan 5eb2c3233d Authors cleanup 2021-12-29 10:56:44 -05:00
RageLtMan 4f8448c3ba Implement infrastructure for ysoserial payload
Pull in the ysoserial mixin and create target configurations to
permit ysoserial payload generation. Setup datastore options and
execution flow to manage the remote code loading workflow vs the
deserialization approach.

The buffer produced by ysoserial still needs to be marshalled into
a valid Java String or Stream of some sort, and verified functional
against the PoC target container using public ysoserial libraries.
2021-12-29 09:10:07 -05:00
RageLtMan ec03b57f6f Rubocop: dont suppress exception 2021-12-29 09:10:07 -05:00
RageLtMan bcdaf53fa1 Rubocop pass on exploit module 2021-12-29 09:10:07 -05:00
RageLtMan 4f07a2fbea First "working" 2021-44228 exploit module state
Clean up the Java code for PayloadFactory - the `main()` function
is actually not required, the error seen on initial attempts to
compile was some sort of PEBKAC or weird things in classpaths.

Update the module to start the HTTP server before issuing the HTTP
request starting the call chain which eventually executes the Java
PayloadFactory - that chain is quick and races with the service's
startup time to get the JAR containing the Payload and its factory.

Minor misc cleanup.
Give credit where due: we stand on the shoulders of giants.

Testing:
  LDAP request is serviced with response containing our JAR URL and
trigger parameters for the factory to instantiate Payload.class and
call its `main()` function.
  HTTP request is serviced to deliver the JAR.
  Payload handler on MSF-side is tripped with incoming connection.
2021-12-29 09:10:07 -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
RageLtMan feed54b3ae Cleanup 2021-12-29 09:10:07 -05:00
RageLtMan aa6c977423 Leverage Rjb to serialize payload "natively"
After evaluating a Rex::Java::Serialization::Model::Stream.decode
of a StringIO containing a natively-produced byteArray serialized
Java class, it looks to be quite time consuming to produce a native
construct from the JARs we currently generate - this requires some
lower-level intervention in the payload generation process and a
considerable amount of data & reference organization.

Since time is limited, and such a construct is devilishly difficult
to proof when bulding out-of-band (in a different language), this
commit takes a different direction: attempting to leverage the Ruby
Java Bridge gem to implore Java itself to construct the serialized
data structure and marshal it back into Ruby for our disposition.

Split the :serialized_payload method to build the actual byteArray
payload in :byte_array_payload which encapsulates the Rjb interface
and produces a valid output to the LDAP packet crafting routine in
:serialized_payload (as read on the wire and by the JVM on the
target container).

Unfortunately, another problem exists here - the metasploit.Payload
class raises: #<NotSerializableException: metasploit.Payload>.
This will likely need to be addressed in the payloads repository.
Once the metasploit.Payload can be successfully serialized by Rjb,
the wire format should accept it verbatim for delivery on-target.
2021-12-29 09:10:07 -05:00
RageLtMan 642c79f633 Shim test hardness with pre-serialized b64 payload
Using Java:
1. Build a test class which prints to the console on init
and ctor
2. Build a serializer for the test class which writes the byteArray
representation of the serialized class to a file
3. Build, run, produce the serialized output and b64 encode it
4. Embed the serialized data into our exploit during development to
avoid construction problems for the Rex encoder of those structures
and my lack of experience using them.
5. TODO: use the embedded Java-produced serialized data to tweak
native structure composition from the raw Java class output.

This is still not working, as just natively writing out the Java
byte array produces an ASN.1 decoding error on the exploitation
target whereas the curent implementation producing EOF errors from
the target system. Wireshark is complaining, so its likely to be
an LDAP structuring issue: the protocol should be using tag 4 which
represents an octet string but the wire data has tag 2 since i was
encoding each byte to BER. Adding octal encoding to the byte array
and encoding each char of that to BER makes the LDAP packet legal
but still results in a `javax.naming.NamingException [Root
exception is java.io.EOFException]`

Leaving this here for folks to hack on while i execute work tasks.
2021-12-29 09:10:07 -05:00
RageLtMan 30d564f8cb Attempt to serialize the Java payload class
Delivery of the raw payload class bytes and ber-encoded payload do
not produce actionable results. Java-based PoCs appear to pass a
byteArray to their LDAP crafting scheme, although the subsequent
BER encoding appears to be opaque or not exist.

Rex::Java::Serialization appears to provide a mechanism by which to
build a Java byteArray in native Rex.
Implement naive NewArray construction, and encode the bytes of that
array per LDAP protocol specification as otherwise the server will
throw an ASN.1 decoding error.

This is still not producing a session, but may be closer to the
solution. So far not even the simple class built as suggested by
@schierlm is executing correctly in the target Docker container,
meaning that the decoded LDAP response packet is not being loaded
or not referencing something correctly.
2021-12-29 09:10:07 -05:00
RageLtMan 9e3e9fd0e2 Implement LDAP attributes or Java payload
Per @shierlm's suggestion, implement the LDAP JNDI hooks required
for an LDAP response to trigger code load.

Payload serialization is wrong however, and my `rex-java` is not
great. It looks like there is a serializer in there containing a
`new_class` method - looks promising, but quick greps through Msf
modules aren't giving me a clear path to encode a generated payload
class this way.

Testing: wireshark says the packet is legal
2021-12-29 09:10:07 -05:00
RageLtMan 074120a2d3 Scaffold HTTP Header Injection Exploit
Using the infrastructure developped for use in the log4shell HTTP
scanner, implement a basic HTTP exploit module which performs the
same action as the scanner does per-host on a specific target; but
instead of logging the vulnerability, return a crafted LDAP search
response containing the payload encoded within the search response.

The crux of this effort lies in payload generation, specifically in
crafting the legal LDAP response packet out of the request data and
generated JAR-format payload. The payload selection is based on an
offline discussion with @Mihi during which he indicated JNDI's
ability to load JARs in the same way as raw Java classes. This
assumption/interpretation on my part may be incorrect.

At present, the delivered LDAP search response appears to be valid
in WireShark, and the vulnerable test docker is showing internal
values in its console output a la:
```
Received a request for API version com.sun.jndi.ldap.LdapCtx@3575a
```
which shows that it is processing the response on its end, just
not in the way we would prefer, yet.

This may be a result of how the MSF payload is being shuffled and
mutated by the packet construction method, or a mistake in the way
i pass in the queried base DN or execute the LDAP search response
transaction.

Testing: fails currently for aforementioned reason

TODO:
  figure out how to encode the payload/LDAP response correctly
  continue testing until verified and upstreamed
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
Spencer McIntyre d82b9ecb47 Add module docs for the ldap server module 2021-12-28 13:52:12 -05:00
Jeffrey Martin 90df765fe2 Land #15986, bash_profile_persistence: Add notes 2021-12-28 08:23:58 -06:00
usiegl00 204da6a0b4 Use packet filter anchor for pfctl in smb_shadow
The packet filter anchor will prevent the flushing of previous packet
filter rules. Using an anchor also allows us to remove the rule, instead
of disabling the filter.
2021-12-28 20:13:32 +09:00
h00die d8255978ac Wordpress Plugin Catch Themes Demo Import cve-2021-39352 2021-12-24 11:56:51 -05:00
Brendan Coles 5d010fcd25 bash_profile_persistence: Add notes and resolve rubocop violations 2021-12-24 03:06:37 +00:00
William Vu 4cd83b5e72 Add ManageEngine ServiceDesk Plus CVE-2021-44077 2021-12-23 12:27:57 -06:00
h00die 4e0fc5a4e5 Wordpress Plugin Catch Themes Demo Import cve-2021-39352 2021-12-21 20:04:09 -05:00
bwatters 1619083834 Land #15955, BYOVD to Enable/Disable Windows Memory Protection
Merge branch 'land-15955' into upstream-master
2021-12-21 15:21:23 -06:00
bwatters 6727c1b344 Land #15954, Add Grafana file read (CVE-2021-43798)
Merge branch 'land-15954' into upstream-master
2021-12-20 09:54:15 -06:00
bwatters 2705d6ae94 Land #15948, Wordpress wp_popular_posts rce
Merge branch 'land-15948' into upstream-master
2021-12-20 09:28:23 -06:00
h00die cb348f06c4 move grafana plugins out to data 2021-12-19 16:18:05 -05:00
h00die eb723098ce report which plugin was successful 2021-12-19 15:56:30 -05:00
Jake Baines e7810acb1e Pulled offsets out of dll into module. Auto-find lsass.exe when pid is 0 2021-12-18 10:56:46 -08: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
Spencer McIntyre 60de839b60 Update Log4Shell references and VCenter URI 2021-12-17 15:55:02 -05:00
Jake Baines 78cae04db6 Merge branch 'rapid7:master' into dell_protect 2021-12-17 12:29:32 -08:00
RageLtMan 0cb381e35d Address the easy parts of @zeroSteiner's review 2021-12-16 19:32:04 -05:00
RageLtMan f8902321ba Update log4shell scanner with native LDAP service
Implement the new Rex::Protocol::LDAP::Server to handle log4shell
callbacks from vulnerable hosts.
2021-12-16 19:20:03 -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
Spencer McIntyre 9ade6c22a4 Land #15970, Update log4shell docs and option 2021-12-16 12:59:22 -05:00
Spencer McIntyre a2624f9309 Appease rubocop 2021-12-16 12:59:12 -05:00