FreeRDS and its X friends

38
FreeRDS and its X friends David “Hardening” FORT [email protected] XDC 2014

Transcript of FreeRDS and its X friends

Page 1: FreeRDS and its X friends

FreeRDSand its

X friends

David “Hardening” [email protected]

XDC 2014

Page 2: FreeRDS and its X friends

XDC2014 - David FORT – [email protected] 2

• A linux and OSS addict since 1994.

• Doing security software most of my career. Now

independent consultant - http://www.hardening-consulting.com/.

• Active FreeRDP and FreeRDS developer.

• The author of the « famous » wayland RDP

compositor.

About the author

Page 3: FreeRDS and its X friends

XDC2014 - David FORT – [email protected] 3

Sponsors

Technologies GmbH

Page 4: FreeRDS and its X friends

XDC2014 - David FORT – [email protected] 4

• FreeRDS architecture overview

• Xrds

• Wayland FreeRDS compositor

Agenda

Page 5: FreeRDS and its X friends

XDC2014 - David FORT – [email protected] 5

FreeRDS

Page 6: FreeRDS and its X friends

XDC2014 - David FORT – [email protected] 6

• Quite old and 90s tainted protocol

– slow/fast path

– weird ROP

– funny bits saving

• Almost all specs are « public »

FreeRDS > RDP protocol (1/2)

Page 7: FreeRDS and its X friends

XDC2014 - David FORT – [email protected] 7

• Security used to be an option

• Vector operations in the past, codecs now

• Channels : printing, bi-directionnal sound, serial port redirection, drive sharing, remote coffee ?

FreeRDS > RDP protocol (2/2)

Page 8: FreeRDS and its X friends

XDC2014 - David FORT – [email protected] 8

• An OSS RDP server (Apache2 licence)

• To be (fully) published soon

• Inspired by Xrdp but based on FreeRDP

• Young (2013)

FreeRDS > the project

Page 9: FreeRDS and its X friends

XDC2014 - David FORT – [email protected] 9

• Security : RDP4, TLS, NLA

• Encoding : raw bitmap, planar codec, remoteFx

• External channel handling

• Session reconnection

• Session shadowing

FreeRDS > features

Page 10: FreeRDS and its X friends

XDC2014 - David FORT – [email protected] 10

FreeRDS > entities

Page 11: FreeRDS and its X friends

XDC2014 - David FORT – [email protected] 11

• Written in C (FreeRDS) and C++ (sessionManager), CMake

• Based on FreeRDP

• Linux for now but targets multi-platform

• Protobuf, thrift and D-Bus

• A library to help building content providers

FreeRDS > in pratice

Page 12: FreeRDS and its X friends

XDC2014 - David FORT – [email protected] 12

• Unix socket as a control channel

– Signaling messages

– Mouse moves

– Key presses

• Shared memory

– Framebuffer

– Damaged regions

FreeRDS > under the hood (1/3)

Page 13: FreeRDS and its X friends

XDC2014 - David FORT – [email protected] 13

• At connection, FreeRDS sends

– Version

– Screen depth / size

– Keyboard layout

• Content provider answers

– Byte / bits per pixel

– Scanline

– Size

FreeRDS > under the hood (2/3)

Page 14: FreeRDS and its X friends

XDC2014 - David FORT – [email protected] 14

FreeRDS > under the hood (3/3)

Page 15: FreeRDS and its X friends

XDC2014 - David FORT – [email protected] 15

• FreeRDS does RDP

• Content provider creates the visible content

FreeRDS > key points

Page 16: FreeRDS and its X friends

XDC2014 - David FORT – [email protected] 16

Xrds

Page 17: FreeRDS and its X friends

XDC2014 - David FORT – [email protected] 17

• X11 content provider

• A headless X server like x11vnc

• FreeRDS DDX, (currently) based on Xorg 1.15

• Links against the content provider helper library

Xrds > about

Page 18: FreeRDS and its X friends

XDC2014 - David FORT – [email protected] 18

• One mouse (client side pointer)

• One keyboard : a xkb layout for the remote RDP keyboard layout

• Functional xrandr

• External program (channel) for clipboard

• Supports reconnection

Xrds > features

Page 19: FreeRDS and its X friends

XDC2014 - David FORT – [email protected] 19

So...

Page 20: FreeRDS and its X friends

XDC2014 - David FORT – [email protected] 20

I love it when a plan comes together

Page 21: FreeRDS and its X friends

XDC2014 - David FORT – [email protected] 21

• Fake modelines, timing, EDID block

• Use the right unit

• Race conditions

• Shut up the Desktop Environment

Xrds > xrandr m'a tuer...

Page 22: FreeRDS and its X friends

XDC2014 - David FORT – [email protected] 22

• Problem : application updating pointers at a mad rate

• Solution : check pointer changed (pointer cache)

Xrds > crazy pointer update

Page 23: FreeRDS and its X friends

XDC2014 - David FORT – [email protected] 23

• Problem : old flash player constantly updates the whole screen when the video is paused

• Solution : frame comparison

– Split damage in 32x32 tiles

– Compute the real damage

• Nice gains even with a fullscreen video

Xrds > damage is not damaged

Page 24: FreeRDS and its X friends

XDC2014 - David FORT – [email protected] 24

• Full X11 environment under FreeRDS

• Gains for other content providers

Xrds > key points

Page 25: FreeRDS and its X friends

XDC2014 - David FORT – [email protected] 25

FreeRDS compositor

Page 26: FreeRDS and its X friends

XDC2014 - David FORT – [email protected] 26

• A FreeRDS backend for weston

• An advanced prototype

• Your remote desktop running weston

FreeRDS compositor > about

Page 27: FreeRDS and its X friends

XDC2014 - David FORT – [email protected] 27

• Uses the pixman renderer

• 1 seat (except with shadowing)

• Maps the RDP layout to a XKB layout

FreeRDS compositor > features

Page 28: FreeRDS and its X friends

XDC2014 - David FORT – [email protected] 28

• Works

• Give it a try !

FreeRDS compositor > key points

Page 29: FreeRDS and its X friends

XDC2014 - David FORT – [email protected] 29

Next...

Page 30: FreeRDS and its X friends

XDC2014 - David FORT – [email protected] 30

• Add support for extended RDP input to weston / Xrds

(multitouch)

• RDP clipboard in weston

• Graphics with the egfx channel

Future work

Page 31: FreeRDS and its X friends

XDC2014 - David FORT – [email protected] 31

Questions ?

Me: [email protected]

Sponsors: [email protected]

FreeRDP: http://github.com/FreeRDP/FreeRDP

FreeRDS: http://github.com/FreeRDS/FreeRDS

Weston backend: http://github.com/hardening/weston

Page 32: FreeRDS and its X friends

XDC2014 - David FORT – [email protected] 32

Extra slides

Page 33: FreeRDS and its X friends

XDC2014 - David FORT – [email protected] 33

• $ ./rdp-server

• bash: ./rdp-server: No such file or directory

• $

Steps for an RDP server – should compile ...

Page 34: FreeRDS and its X friends

XDC2014 - David FORT – [email protected] 34

• $ xfreerdp /v:<my host>

• freerdp_set_last_error 0x2000C

• Error: protocol security negotiation or connection failure

• $

Steps for an RDP server – listener not listening

Page 35: FreeRDS and its X friends

XDC2014 - David FORT – [email protected] 35

Steps for an RDP server – black screen

Page 36: FreeRDS and its X friends

XDC2014 - David FORT – [email protected] 36

Steps for an RDP server – fireworks

Page 37: FreeRDS and its X friends

XDC2014 - David FORT – [email protected] 37

Steps for an RDP server – artifacts

Page 38: FreeRDS and its X friends

XDC2014 - David FORT – [email protected] 38

Steps for an RDP server – go for a beer