Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TDP Shared Directory Announce and Acknowledge #12405

Merged
merged 86 commits into from
Jun 14, 2022

Conversation

ibeckermayer
Copy link
Contributor

This PR creates a feature branch directory_sharing and merges in the Shared Directory Announce and Shared Directory Acknowledge functionality.

Shared Directory Announce is handled by a Rust function called from Go named handle_tdp_sd_announce.
Shared Directory Acknowledge is sent via a Go function called from Rust named tdp_sd_acknowledge.

I've also broken what was formerly rdpdr.rs down into a multi file module, with the main chunk being in rdpdr/mod.rs. This prevents rdpdr.rs from becoming cluttered with large bitflags and constants structures. Right now its primarily struct representations of RDP messages and the client itself. Note that many of the RDP messages are as of now unused.

There is a webapps branch named isaiah/stub-directory-sharing which this can be tested against. It gives you a big crazy looking "Share Fake Directory" button on the far right of the top bar:

Screen Shot 2022-05-03 at 19 34 04

When you click that, expect the session to fail and you should see in the logs something like

[2022-05-03T23:37:58Z DEBUG rdp_client::rdpdr] sending new drive for redirection: ClientDeviceListAnnounceRequest { device_count: 1, device_list: [DeviceAnnounceHeader { device_type: RDPDR_DTYP_FILESYSTEM, device_id: 2, preferred_dos_name: "testing123", device_data_length: 11, device_data: [116, 101, 115, 116, 105, 110, 103, 49, 50, 51, 0] }] }
[2022-05-03T23:37:58Z DEBUG rdp_client::rdpdr] got ServerDeviceAnnounceResponse: ServerDeviceAnnounceResponse { device_id: 2, result_code: 0 }
[2022-05-03T23:37:58Z DEBUG rdp_client::rdpdr] ServerDeviceAnnounceResponse was valid
2022-05-03T19:37:58-04:00 WARN [WINDOWS_D] Failed reading RDP output frame: RDP read failed: RdpError(RdpError { kind: InvalidData, message: "got unsupported major_function in DeviceIoRequest: IRP_MJ_CREATE" }) client-ip:::1 desktop-addr:172.16.97.186:3389 desktop-name:WIN-JR2L4P7KN15-teleport-dev rdp-addr:172.16.97.186:3389 rdpclient/client.go:250

and the browser logs should log an object

{
    directoryId: 2
    err: 0
}

This is indicative that the tdp Shared Directory Announce was translated into an RDP ClientDeviceListAnnounceRequest (handle_tdp_sd_announce), then the server's RDP ServerDeviceAnnounceResponse was translated into a TDP Shared Directory Acknowledge (at which point the RDP server sent an IRP_MJ_CREATE request which is not yet supported, causing the session to fail).

Apologies for this relatively large PR. A big chunk of it is RDP messages that we will need, but don't use in the code yet, and are straightforward implementations from the RDP spec. This is a feature that can really only show anything that works once its implemented end to end. My plan from here is to create a PR for each MajorFunction, starting with IRP_MJ_CREATE, and implementing the logic as described in the RFD (open to feedback on this approach).

Isaiah Becker-Mayer added 30 commits March 31, 2022 15:35
…and cliprdr::Client's have the vchan::Client as a field.
…o trigger it by right-clicking, however it isn't working. One reason is that the vchannel PDU header isn't being added (see rdpdr::encode_message for how that's added to other messages). Noticing that made me notice that there is another cliprdr function for breaking outgoing messages into chunks that should be refactored into vchan to do that work + add the necessary vchan headers. This is a checkpoint commit while I go attend to that.
…lient parses the DeviceCreateRequest that's immediately sent back
…ugh in most cases, no need to neurotically add every bit of the documentation text to the code itself
@ibeckermayer ibeckermayer enabled auto-merge (squash) June 1, 2022 14:35
@ibeckermayer ibeckermayer merged commit c018cd7 into master Jun 14, 2022
ibeckermayer pushed a commit that referenced this pull request Jun 17, 2022
Co-authored-by: Zac Bergquist <zmb3@users.noreply.github.com>
@ibeckermayer
Copy link
Contributor Author

v10 backport #13628

ibeckermayer pushed a commit that referenced this pull request Jun 21, 2022
* TDP Shared Directory Announce and Acknowledge (#12405)

* RDP <--> TDP Translation Architecture (#12615)
ibeckermayer pushed a commit that referenced this pull request Jun 30, 2022
Co-authored-by: Zac Bergquist <zmb3@users.noreply.github.com>
ibeckermayer pushed a commit that referenced this pull request Jul 11, 2022
* Restructure `rdpdr.rs` into a multi file module (#12530)

* Adds go build flags for directory sharing and some basic scaffolding for handling them (#12531)

* TDP Shared Directory Announce and Acknowledge (#12405)

* RDP <--> TDP Translation Architecture (#12615)

* RBAC for directory sharing (#12684)
@webvictim webvictim mentioned this pull request Jul 12, 2022
@zmb3 zmb3 deleted the isaiah/tdp-sd-announce-ack branch April 26, 2023 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants