grdp

module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 24, 2026 License: GPL-3.0

README

Golang Remote Desktop Protocol

grdp is a pure Go client implementation of Microsoft's Remote Desktop Protocol.

Forked from tomatome/grdp, itself forked from icodeface/grdp.

Status

The connection, authentication, rendering and input paths are implemented and have been verified against real servers. The graphics paths that newer servers prefer are not done yet.

Verified against xrdp 0.9.24 and against a real Windows 10 host:

  • Connection, MCS, capability exchange
  • TLS and NLA (CredSSP with NTLMv2, including the version 6 public key binding)
  • Licensing exchange
  • Bitmap updates, RLE, 24 and 32 bpp
  • Pointer position and pointer shape updates
  • Keyboard and mouse input, including modifier keys
  • Clipboard, text, both directions
  • NSCodec and RemoteFX (RFX) bitmap codecs, checked byte for byte against libfreerdp's own decoder
  • Surface commands, drdynvc, RDPGFX command parsing

Not done:

  • EGFX rendering. Windows offers the graphics channel and then stops sending bitmap updates, and the payload is ZGFX compressed, which is not implemented yet. See docs/windows-verification.md. Off by default.
  • Orders and the bitmap cache. xrdp never sends orders, so this path is only needed for Windows' partial updates.
  • Interleaved RLE bitmaps, which the bitmap cache revision 3 needs.
  • H.264 (AVC420 / AVC444) codecs, which EGFX servers may choose.
  • VNC. The RFB subset this fork inherited is unused and unverified.

Using it as a library

s := client.NewSetting()
s.Width, s.Height = 1024, 768
s.Protocol = "nla"           // "tls" or "nla"

c := client.NewClient("host:3389", "user", "password", client.TC_RDP, s)
c.OnBitmap(func(bs []client.Bitmap) { /* paint */ })
c.OnClipboardText(func(text string) { /* paste */ })
if err := c.Login(); err != nil {
    log.Fatal(err)
}
c.KeyDown(0x1c, "")
c.KeyUp(0x1c, "")

Setting.EnableClipboard opens the clipboard channel, and Setting.EnableEGFX opts into the graphics channel described above.

Trying it out

cmd/rdpcli is a headless client that connects, decodes, and writes what it received to a PNG. It is enough to check a server end to end:

go run ./cmd/rdpcli -host 192.0.2.10:3389 -user user -pass secret -proto nla \
    -wait 20s -dump /tmp/screen.png

# drive input and watch it land
go run ./cmd/rdpcli -host 192.0.2.10:3389 -user user -pass secret -proto nla \
    -wait 20s -dump /tmp/after.png -post-input 4s \
    -key click:400,600 -type 'echo hello' -key press:0x1c

Flags worth knowing: -type types a string (handling shift), -key sends raw input events, -clipboard and -set-clipboard exercise the clipboard, -pointer logs pointer updates, -log 0 is a full trace.

Development

scripts/dev-rdp.sh manages a local xrdp target for integration testing: setup (once, makes the rest passwordless), up, down, status, probe, and probe-session, which prepares a session whose X input events are logged so that input can be verified rather than eyeballed.

scripts/gen-codec-vectors.sh regenerates the codec test vectors from libfreerdp's encoders and decoders, so the image codecs are checked against a reference implementation rather than against hand written expectations.

Take ideas from

Directories

Path Synopsis
client.go
client.go
cmd
rdpcli command
Command rdpcli is a small headless RDP client used to verify connectivity against a live server.
Command rdpcli is a small headless RDP client used to verify connectivity against a live server.
Package codec implements the bitmap codecs that RDP servers use to encode bitmap update and surface command payloads.
Package codec implements the bitmap codecs that RDP servers use to encode bitmap update and surface command payloads.
bitmap.go
bitmap.go
drdynvc
Package drdynvc implements the dynamic virtual channel channel (MS-RDPEDYC).
Package drdynvc implements the dynamic virtual channel channel (MS-RDPEDYC).
rail
rail.go
rail.go
rdpgfx
Package rdpgfx implements the RDP Graphics Pipeline Extension channel (MS-RDPEGFX), the modern drawing path where a server composites surfaces and sends them as compressed bitmaps.
Package rdpgfx implements the RDP Graphics Pipeline Extension channel (MS-RDPEGFX), the modern drawing path where a server composites surfaces and sends them as compressed bitmaps.
protocol
lic
nla
pdu
rfb
rfb.go
rfb.go
sec

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL