networking, updated

RDP

The Remote Desktop Protocol gives a full graphical session on a remote Windows machine. Admins use it every day, and so do attackers: exposed RDP is one of the most common ways into a network.

OSI layer
7 Application
Carried in
TCP (UDP for the graphics transport)
Ports
3389/tcp, 3389/udp
Specs
MS-RDPBCGR, MS-CSSP
Wireshark filter
rdp || tpkt
Encrypted
yes

Packet structure

After the first two packets everything is inside TLS, so the connection request is the one packet you can always read:

RDP connection request (TPKT + X.224 + RDP negotiation)19 bytes + variable

Select a field to see what it does.

MS-RDPBCGR 2.2.1.1. The first packet a client sends, still in clear text. TPKT and X.224 are big-endian, the RDP negotiation request is little-endian.

The server answers with an X.224 Connection Confirm that carries the selected protocol (or a failure code, e.g. “HYBRID required” when the client cannot do NLA).

How it works

sequenceDiagram
    participant C as Client
    participant S as Server :3389
    C->>S: X.224 Connection Request (mstshash cookie, requested protocols)
    S->>C: X.224 Connection Confirm (selected: HYBRID)
    C->>S: TLS handshake
    S->>C: TLS handshake (server certificate, often self-signed)
    Note over C,S: Encrypted from here
    C->>S: CredSSP: NTLM or Kerberos login (NLA)
    C->>S: MCS Connect, capabilities, licensing
    S->>C: Desktop graphics (TCP and UDP 3389)
    C->>S: Keyboard and mouse input, clipboard, drive and printer redirection
  1. Negotiation in clear text: the client names itself (cookie with the user name) and lists the security protocols it supports.
  2. TLS with the server’s certificate. On domain machines it can come from AD CS; most servers use a self-signed certificate named after the host, which leaks the computer name.
  3. Network Level Authentication (NLA): with HYBRID the user logs in through CredSSP (NTLM or Kerberos) before the server builds a session or shows a login screen. Without NLA, anyone who connects gets a Windows login screen.
  4. Session: MCS channels carry graphics, input and virtual channels (clipboard, drives, printers, audio, smart cards). A UDP transport on 3389 speeds up graphics.

In Wireshark

FilterShows
tcp.port == 3389All RDP over TCP
rdp.rt_cookieConnection requests with the user name in clear text
rdp.negReq.requestedProtocols == 0Clients asking for Standard RDP Security only (old tools)
rdp.negReq.selectedProtocolProtocol the server chose
rdp.negFailure.failureCodeRefused negotiations
tls.handshake.type == 11 && tcp.port == 3389Server certificates (host names)
ntlmssp && tcp.port == 3389NTLM inside CredSSP (only if not encrypted further)
udp.port == 3389RDP UDP transport
tcp.port == 3389 && tcp.flags.syn == 1 && tcp.flags.ack == 0Connection attempts (brute force when many)

What normal looks like: admins connect from jump hosts or admin workstations to servers, with NLA, inside the network or through an RD Gateway (HTTPS 443). RDP from the internet straight to 3389, RDP from ordinary workstations to each other, or long sessions at odd hours are suspicious. Many short connections with different or empty mstshash names are scanning or brute force.

Security notes

References

§ home
~/knubertus/home/
1,1 Top