Commit Graph

355 Commits

Author SHA1 Message Date
h00die 6a851855a8 spelling fixes for lib folder 2024-01-06 15:54:49 -05:00
Spencer McIntyre e9d6bab975 Move the ServerClient code into a dedicated file 2023-11-22 13:34:18 -05:00
Spencer McIntyre 120dc877ad Pr/collab/17430 (#41)
* Prevent using post modules with the session

It doesn't work reliably because of winpty and how the output is
mangled.

* Set the limit correctly

* Fix Linux PTY downgrade issues

* Remove filtering

The filtering implementation is incomplete and unnecessary.

Filtering is unnecessary because Linux sessions execute a stub on
session start up that uses a combiantion of stty and a fifo to emulate a
PTY-less session. Windows sessions do not need filtering because they
have been explictly marked as being incompatible with the Post API which
is confused by the extra characters.

The filtering implementation is incomplete because it does not account for
echo fragments that are split across lines. It also does not account for
all of the ANSI escape codes.

* Add module docs for enum_ssm
2023-05-22 17:11:16 -04:00
RageLtMan 713ec6ae76 Merge branch 'master' into feature/aws_ssm_sessions 2023-05-16 14:39:37 -04:00
Spencer McIntyre d8dd9bbe79 Move the publish timeout logic (#40)
This makes it accessible from enum_ssm so Linux sessions can be opened.
2023-05-11 09:58:16 -04:00
Spencer McIntyre e92695149d Fix linux tests, remove Windows support (#39)
* Revert "shell_command_token_base get 0th output index"

This reverts commit 3a4cb3560f.

* Correct the order of arguments to #set_term_size

* Fix paths for directory checks

The path C:\ ends with a trailing backslash which will cause bash to
wait for another line if input. This places the shell in an undesirable
state.

* Fix post module tests for Linux

* Remove the command document

This hasn't been tested and it's unclear under what conditions this
would be used.

* Fix Windows SSM sessions

---------

Co-authored-by: Spencer McIntyre <zeroSteiner@gmail.com>
2023-05-10 17:48:53 -04:00
RageLtMan 867902e7d0 SSM start/stop publication 2023-04-28 09:00:37 -04:00
3V3RYONE 9c8bc4e124 added yard docs 2023-04-27 16:56:49 +05:30
RageLtMan d797e5ec2c Simplify SSM shell output filtering 2023-04-22 17:18:21 -04:00
RageLtMan 5132302363 Filter control bytes from SSM output 2023-04-22 15:22:18 -04:00
Spencer McIntyre 59b3c0e945 Set the platform in enum_ssm
Update the enum_ssm module to use the correct session type with the
appropriate platform. Also set the session information to the same
string which also removes the eye sore that is the shell banner.
2023-04-19 18:05:50 -04:00
Spencer McIntyre a7d8bc6757 Fix sessions opening over and over again
Also make some code cleanups
2023-04-19 18:05:50 -04:00
3V3RYONE 9c20d0f84b Implemented HTTP-Trace for login scanners via HttpLoggerSubscriber API 2023-03-15 00:57:33 +05:30
adfoster-r7 b2cc84228f Fix module spec test failing on local machine 2023-02-23 14:27:44 +00:00
Spencer McIntyre 61c2726620 Fix NoMethodError for #opcode 2023-02-01 18:19:46 -05:00
RageLtMan 453baca109 Drop mask_write, tweak logging 2023-01-21 08:29:28 -05:00
RageLtMan 3e54ae6e69 Resolve crashes noted by @smcintyre-r7, simplify
Bail out of console resize operation if ::IO.console doesn't exist
Enforce REGION datastore option and remove the multi-region enum
code by Aaron - users can write resource scripts if they need
automation.
2023-01-20 22:33:51 -05:00
adfoster-r7 eddac9321c Merge 6.2.36 master into kerberos feature branch 2023-01-13 17:31:02 +00:00
RageLtMan 274bf6dcb7 Make SSM keepalive optional 2023-01-13 09:54:34 -05:00
Grant Willcox 8b102afd71 Rubocop fixes and some documentation additions 2023-01-10 10:07:51 -06:00
Ashley Donaldson f8b253dae1 Fix state machine for HEAD requests 2023-01-10 10:57:13 +11:00
RageLtMan 955fb2ef3e SSM WebSocket session keep-alive
The SSM session socket times out without data being sent at the
upper (SSM) WS layer. Implement keep-alive in a separate thread
which simply writes nothing into the channel at irregular intervals
to simulate user activity.

Testing:
  Sessions established with this code running have not timed-out
in over 15m despite being completely unused
2023-01-03 21:20:07 -05:00
RageLtMan 46c030a08b Finalize SSM Shell via WebSocket
Implement terminal resizing to WebSocket shell
Reorganize code to ease later extension
Implement peerinfo in channel context from AWS EC2 SSM information
gathered during session validation
Implement echo-filtering for session inputs (hacky, but works)

Testing:
  Verified console resizing, color/reset/etc
  Verified peerinfo and interaction
  Verified common session operations

Notes:
  SSM WebSocket sessions time out pretty quickly, implementing
dedicated SSM session types which support suspend/resume to match
backgrounding/foregrounding operations in the console should help
to resolve this. Alternatively, a keep-alive using empty frames
may be implemented in the SsmChannel itself on a separate thread.
2023-01-03 15:10:31 -05:00
RageLtMan 43d746c404 Implement SSM WebSocket Sessions
Alter WebSocket::Interface::Channel to accept a mask_write flag to
set the Channel behavior for outgoing data (since the on_data_write
handler can only deal with the buffer provided, not how the wsframe
containing it is written to the "wire"). Set the flag to false for
SSM's WebSocket operations.

Extract Rex::Proto::Http::WebSocket::AmazonSsm from the handler to
permit reuse by other framework elements.

Implement SSM-specific UUID handling.
Create sane SsmFrame constructor to permit convenient operations.

Implement Http::WebSocket::AmazonSsm::Inteface::SsmChannel from
Http::WebSocket::Inferface::Channel with message-type handling and
output processing. Acknowledge incoming messages, process incoming
acknowledgements, increment sequence IDs appropriately, and handle
basic logging.

This new session type removes the 2500 char output restriction and
stateless peer cwd.

Testing:
  Execution of handler now provides stateful interactive shells

Next steps:
  More testing, preferably by other people with upstream framework.
  Peerinfo and presentation updates for the session channel
  Misc cleanup

Future work:
  Implement new SSM session type with support for multi-console,
port-forwarding/socket routing, and custom SSM documents.
  Implement FSM handlers for session suspension and resumption in
Http::WebSocket::AmazonSsm::Interface::SsmChannel
2023-01-03 09:34:14 -05:00
Ashley Donaldson b05db8b82d Keep signature of the read_response function as it was before, and add the original request as an opt 2023-01-03 09:46:43 +11:00
Ashley Donaldson 891ab225cc Ignore Content-Length header for the purpose of HEAD requests 2022-12-15 11:22:48 +11:00
adfoster-r7 5d345e6689 Merge branch 'upstream-master' into feature-kerberos-authentication 2022-09-29 16:42:58 +01:00
Jake Baines f3efc84a1f Use start_with instead of starts_with 2022-09-02 06:34:18 -07:00
Christophe De La Fuente 1b5338da06 Land #16701, Rewrite of Cisco ASA Clientless VPN Brute-force 2022-08-25 16:04:48 +02:00
Jake Baines 2242272ef4 Added CSRF token support. Fixed an issue with HTTP Keep-Alive 👀 2022-08-19 10:51:33 -07:00
bcoles 39f288bfe3 Rex::Proto::Http: Add evasion options to shuffle GET / POST parameters 2022-07-11 01:37:41 +10:00
Ashley Donaldson 39f90d95b1 Create sessions for winrm_login successes.
Reuses the connection, so that authentication doesn't need to happen again
2022-07-08 16:57:09 +10:00
Ashley Donaldson d3e7152954 Changes from code review 2022-07-08 11:47:54 +10:00
Ashley Donaldson b2eb348d94 Added WinRM using Kerberos, including encryption 2022-07-07 13:17:09 +10:00
adfoster-r7 739c0fcad1 Specify peer hostname for ssl connections 2022-05-13 13:55:43 +01:00
adfoster-r7 e4f42d7eaa Update more modules to use the vars_form_data api 2022-05-11 18:18:21 +01:00
adfoster-r7 94e1ad3fe5 Update form data api defaults 2022-05-10 14:12:17 +01:00
adfoster-r7 0ce36f318e Move logic into client_request for consistency 2022-05-09 16:51:15 +01:00
sjanusz 2e59f17439 Rename files to form_data 2022-05-06 16:41:19 +01:00
sjanusz 4ec4b89d00 Add upload of files to HttpClient & update a module to use it 2022-04-25 14:55:37 +01:00
Spencer McIntyre cec44f0cab Land #16371, Fix websocket crash 2022-03-24 13:07:34 -04:00
alanfoster cebdebb188 Fix kubernetes websocket crash when identifying peer host 2022-03-23 02:28:47 +00:00
Ashley Donaldson 4652605458 Respect communication channel when selecting existing service within ServiceManager (resolves #16314) 2022-03-09 10:22:11 +11:00
Ashley Donaldson cab04d33f5 Use existing Rex::UserAgent class; keep UA string consistent across an MSF session 2021-11-10 10:05:45 +11:00
Ashley Donaldson 839722720a Updated the default metasploit user agent string to be more modern
Selected from a set of currently-modern browser UA strings
2021-11-09 18:20:41 +11:00
Spencer McIntyre bdb497ddd4 Dedent the websocket module 2021-11-05 10:41:07 -04:00
Spencer McIntyre a85cd3d5f6 Add logging to get_wsframe 2021-11-03 11:26:31 -04:00
Spencer McIntyre 3d2fd9bc90 Don't process partial WS frames 2021-11-02 17:13:26 -04:00
Spencer McIntyre 6930200422 Fix partial bindata reads within web sockets 2021-11-02 17:13:13 -04:00
adfoster-r7 63da82d1f9 Fix iis internal ip module crash 2021-10-26 12:52:26 +01:00