Commit Graph

417 Commits

Author SHA1 Message Date
dwelch-r7 bad5ccbc49 Remove msf/base requires 2021-01-05 14:59:46 +00:00
dwelch-r7 1617b3ec9b Use zeitwerk for lib/msf/core folder 2020-12-07 10:31:45 +00:00
gwillcox-r7 2007583c29 Land #13238, Replace exit calls in bind_named_pipe handler with Thread.exit calls 2020-08-11 14:09:39 -05:00
gwillcox-r7 0882b62cf6 Replace return with Thread.exit call and interrupt_wait_for_session 2020-08-11 14:08:26 -05:00
Jeffrey Martin 65039a5091 Merge upstream into 6.x 2020-07-15 09:58:07 -05:00
Spencer McIntyre 26cbfa5d56 Land #13417, SMBv3 integration with Framework 2020-06-24 14:09:11 -04:00
Adam Galway 1a2bf98222 creates standard elog & updates exisiting usages 2020-06-22 12:48:39 +01:00
Christophe De La Fuente a9a1d01419 Update some libraries and modules 2020-06-09 14:18:52 +02:00
OJ 48290ac38a Fix a stupid mistake with core_patch_url
This was not originally ported to an int when it should have been.
2020-06-09 08:58:27 +10:00
Karim Kanso 1e044d5ca1 changed 'exit' to 'return' in bind_named_pipe handler 2020-04-12 19:38:05 +01:00
Spencer McIntyre 059dd59d90 Use the new max_length check elsewhere 2020-03-11 11:56:15 -04:00
Spencer McIntyre db9626153b Minor refactoring for style, whitespace, etc. 2020-03-11 11:56:15 -04:00
Timo Mueller 2283948fcf Fixed description in reverse_http payload, for real 2020-03-11 11:55:18 -04:00
Timo Mueller 364b6c1359 Fixed description in reverse_http payload 2020-03-11 11:55:18 -04:00
Timo Mueller f10f5701dd Added maximum string length check 2020-03-11 11:43:10 -04:00
bwatters-r7 2db93c9051 Land #12002, Feature/reverse ssh
Merge branch 'land-12002' into upstream-master
2020-02-21 09:17:51 -06:00
bwatters-r7 1aa412ccc0 add some of bcoles suggested fixes 2020-02-19 13:52:38 -05:00
L 7f82816065 Add description udp listening information 2020-01-10 14:58:36 +08:00
RageLtMan 21dd5f438d Address some of @bcoles comments 2019-09-15 01:14:04 -04:00
RageLtMan d1eaac9932 Implement native reverse SSH via openssh binary
Implement a reverse SSH shell using nothing but the on-target SSH
client and a fifo in the same manner as used by netcat payloads.
This is not forensically sound as the fifo will be caught by HIDS,
filesystem snapshots, and other defensive measures. However, it
does provide a way out from almost any modern POSIX system as they
nearly all have an SSH client in one form or another.

Convert existing Ruby reverse SSH payloads to use dynamic cached
payload sizing.
2019-06-23 05:48:50 -04:00
RageLtMan c339662fed SshCommandSession and Ruby Payloads
Implement a command-only session type over the HrrRbSsh client
Connection Channels' file descriptors, adjust from base command
session to deal with the separate reader/writer IOs. Technically,
a TTY session works out of the box here as well.

Implement a pair of showcase Ruby payloads using net/ssh to call
back to the handler, create a shell channel, and loop piping I/O
between framework session and client via the Ruby backtick exec.

Next Steps:
  Command payloads need to be written for every major interpreted
language as well as some sort of bashism a la openssl_double if
it comes to that, but preferably single socket implementation.

Testing:
  Very minimal, needs a good run through by the community and R7
2019-06-23 05:20:04 -04:00
RageLtMan f0b24339fe Implement Rex::Proto::Ssh::Server scaffold
Create the Rex::Proto::Ssh namespace and implement hrr_rb_ssh
objects in the Rex namespace with Rex' sockets stack, permissive
default connection options to accept any authentication, ACLs for
port forwarding, and a modified Connection #initialize method for
simplified instantiation.

The actual Rex::Proto::Ssh::Server object follow standard Rex
semantics for services to permit use in handlers, exploits, and
auxiliary modules in the same manner as the Http::Server is used
today.

This work is far from complete - the HrrRbSsh low-level objects
should be decomposed into Rex' pattern as they currently depend
heavily on their own Procs and Threads internally which use the
parent Connection object's attributes to look up which Proc should
be called in response to a Channel or Authentication request. This
is a bit difficult to do piecemeal given the intertwined data and
execution dependency inside of HrrRbSsh.

Next steps:
1. Create handler and reverse_ssh command session payloads
1a. POSIX systems generally have SSH already
1b. Windows Powershell is likely able to hotload SSH libs as a
pre-stager.
1c. Other interpreted runtimes usually have client-ssh libraries
2. Implement options parsing, handling, etc for user-customizable
functionality from the Msf namespace.
3. Use libssh2 to permit mettle use of the SSH transport.
3a. Bother @OJ about doing the same for Windows Meterpreter.
3b. Bother @zeroSteiner to implement SSH transport for PyMeterp.
3c. Ask @timwr and @mihi how viable this is for Android/Java.
3d. See if @OJ will do this for CLR-meterp on a livestream.
4. Write a post module which runs this SSH server from a mettle
session using the compromised hosts's own host keys and passwd
file for "valid" authentication while logging and MITMing the
entire command stream remotely - help folks shake off some of the
complacency around "secure shells."
5. Write a plugin which will permit sharing of the entire console
context, specific acquired sessions, or TCP forwards with the
pugin's SSH clients based on the credentials used to connect.
6. Further decompose the server code into Rex to permit writing
client fuzzers, loggers, and other tooling to test the posture of
SSH client implementations.
7. Work to implement SSH client functionality in HrrRbSsh and
convert the rest of Rex/Msf to use this library instead only.
8. Rewrite and import MetaSsh into Metasploit proper using the
new Rex::Proto::Ssh code.

-----

Huge thanks to @hirura for writing HrrRbSsh. I've spent countless
hours on and off working to implement server-side semantics in
net/ssh years ago and it was becoming a pretty full rewrite due
to the ordering of server/client req/resp messages and who sent
what to whom. This library is a much much cleaner implementation
and provides full, modern SSH servers in pure Ruby.
2019-06-22 20:06:15 -04:00
OJ 5621d200cc Stop error rendering in multi/meterpreter
The reverse_http/s listeners result in awful errors when
multi/meterpreter is set as the payload. Anyone that hits the endpoint
with an invalid or missing UUID will spam the MSF console with
exceptions.

This patch avoids this issue in cases where the UUID isn't specific. We
avoid setting it as a default, which doesn't make sense anyway.
2019-06-11 13:39:52 +10:00
Brent Cook 73c8e803fe Land #11892, Fix parse IPv6 address in reverse_http 2019-05-31 12:41:36 -05:00
ssyy201506 ecda8d864a Fix incorrect parsing of IPv6 uri. 2019-05-28 16:41:34 +09:00
Matt Robinson 26eebb9620 Fix multi handler reverse_http to not care so much about the workspace. 2019-05-25 16:25:06 -04:00
William Vu c9813cf379 Fix comments 2019-05-23 10:39:11 -05:00
William Vu 7eb279e079 Use human_name in reverse_udp handler 2019-05-22 20:25:37 -05:00
Erin Bleiweiss b51d016a93 Store and search payloads with workspace id 2018-09-24 14:11:48 -05:00
Erin Bleiweiss 7e6c3261b6 Update payload count method 2018-09-18 16:36:11 -05:00
Erin Bleiweiss 9b5326994f Add remote data endpoint support for searching payloads 2018-09-18 15:50:55 -05:00
Erin Bleiweiss 8f4e17c277 Replace uuid methods for payload count and url validation 2018-09-13 12:28:04 -05:00
UserExistsError 6181253109 fix multi connect bug 2018-07-26 17:34:11 -06:00
UserExistsError d5ed70417b bind_named_pipe payload for ruby_smb 2018-07-17 17:46:10 -06:00
William Vu c8891206af Add vprint_status back to bind_named_pipe
I thought it was redundant with the improved handler start message, but
it broke consistency with the other print statements. Fixing.
2018-07-13 17:29:52 -05:00
Brent Cook 8680379875 fix logic bug in handler thread for bind_named_pipe 2018-07-05 10:39:20 -05:00
William Vu f0b9b1c113 Add more verbose printing to bind handlers 2018-07-03 19:41:08 -05:00
UserExistsError bbf26c66f6 bind_named_pipe fixed for simpleclient versions param 2018-06-27 16:14:53 -06:00
UserExistsError 948b07166a pipe error checks 2018-03-14 00:09:20 -06:00
UserExistsError e19a071910 add bind_named_pipe x86 2018-02-22 19:03:37 -07:00
UserExistsError b3f26ea55f bind_named_pipe fixes 2018-02-18 10:31:57 -07:00
Brent Cook 38b03fdfff Merge branch 'upstream-master' into land-9539- 2018-02-15 16:22:13 -06:00
Brent Cook 93450b87dd use common retry options for UDP 2018-02-15 14:36:21 -06:00
Jeffrey Martin f5768e7ced gate session reported when using bind udp
While this method here is somewhat noisy on the network it eliminates
a poor user experience when the handler is started but the payload is
not yet running on the target.

When a target is sent a udp packet and it is not rejected push down
an initial "echo syn" command that will respond with output.  This
allows framework to be aware that the payload is what is running on
the server port instead of assuming a non-existent target is a valid
session.
2018-02-13 14:44:57 -06:00
UserExistsError 8ae8a0d94b added bind_named_pipe payload 2018-02-11 18:56:50 -07:00
RageLtMan ef1d4ddb03 Add UDP handlers and payloads (redux)
This is a repackaging effort for the work i originally pushed in
6035. This segment of the PR provides UDP session handlers for
bind and reverse sessions, a Windows Metasm stager (really the
TCP stager with a small change), and a pair of socat payloads for
testing simple UDP shells. Netcat or any scripting language with
a sockets library is sufficient to use these sessions as they are
stateless and simple.

Testing of this PR requires rex/core #1 and rex/socket #2

The SSL testing which was being done on 6035 is backed out, left
for a later time when we can do DTLS properly.
2018-01-23 02:00:55 -05:00
RageLtMan f1a1e1a357 Implement specific dispatch extensions for tunnels
All meterpreter Clients are created equal, and as such they all
include the PacketDispatcher mixin and call its init methods when
a passive dispatcher is needed. However, since tunneling protocols
have different requirements for implementation, the methods which
provide protocol-specific functionality need to be mixed into the
Client before it attempts to initialize the dispatcher.

Provide a dispatch_ext option in the has passed to the client on
init from the session handler which is an Array containing mixin
references which are sent to :extend calls in the :init_meterpreter
method just prior to calling :initialize_passive_dispatcher.

Each handler implementation can thus push chains of mixins to the
client in order to provide middleware specific to the tunnel. Down
the road, this should permit stacking C2 encapsulations or tunnel
protocols/permutators to create unique session transports on the
fly.
2017-12-29 00:56:06 -05:00
Brent Cook bb5ea540ab fix a number of TODO's in the HTTP handler, remove duplication in handlers 2017-12-12 03:12:36 -06:00
Brent Cook f49006222c remove unneeded uri 2017-12-12 03:12:36 -06:00
Brent Cook 8e76c4cb4f handle override at the meterpreter config layer 2017-12-12 03:12:36 -06:00