Commit Graph

20 Commits

Author SHA1 Message Date
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
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 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
alanfoster cebdebb188 Fix kubernetes websocket crash when identifying peer host 2022-03-23 02:28:47 +00: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
Spencer McIntyre 099b47b6d5 Synchronize the WebSocket interface 2021-09-30 16:53:24 -04:00
Spencer McIntyre 556703b181 Pass opts forward through the ws functions 2021-09-30 16:06:49 -04:00
Spencer McIntyre 55edd86810 Synchronize access when reading WebSocket frames 2021-09-29 17:55:05 -04:00
Spencer McIntyre 1aa4bc4f66 Raise exceptions WebSocket connection failure 2021-09-29 17:55:05 -04:00
Spencer McIntyre 2db5764700 Add WebSocket frame and opcode specs, fix bugs 2021-09-29 17:55:05 -04:00
Spencer McIntyre ac319e730b Document the new WebSocket functionality 2021-09-29 17:55:05 -04:00
Spencer McIntyre d230090e0d Add a WebSocket channel 2021-09-29 17:55:05 -04:00
Spencer McIntyre c0635a0532 Add a wsloop that handles frags, pings and closes 2021-09-29 17:55:05 -04:00
Spencer McIntyre 7e8afcdaf6 Add a WebSocket implementation for Rex 2021-09-29 17:55:05 -04:00