差别
这里会显示出您选择的修订版和当前版本之间的差别。
两侧同时换到之前的修订记录 前一修订版 后一修订版 | 前一修订版 | ||
public:it:freerdp [2022/01/17 09:11] – oakfire | public:it:freerdp [2022/03/01 10:27] (当前版本) – [RDP 协议解析] oakfire | ||
---|---|---|---|
行 5: | 行 5: | ||
* API documentation: | * API documentation: | ||
* Information regarding the Microsoft Open Specifications can be found at: [[https:// | * Information regarding the Microsoft Open Specifications can be found at: [[https:// | ||
- | * [[https:// | + | * [[https:// |
- | * [[https:// | + | * [[https:// |
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | ===== RDP 协议解析 ===== | ||
+ | * 基于TCP连接,标准没有规定服务端端口,默认端口为**3389** | ||
+ | * 消息流里的多字节数据统一使用**小端**字节序(little-endian) | ||
+ | |||
+ | ==== 消息结构 ==== | ||
+ | * 节选了几个有代表性的 | ||
+ | === 静态虚拟通道消息结构 === | ||
+ | * tpktHeader (4 字节): | ||
+ | * x224Data (3 字节): | ||
+ | * mcsPdu (长度可变): | ||
+ | * securityHeade (长度可变): | ||
+ | * channelPduHeader (8 字节) : CHANNEL_PDU_HEADER 结构 | ||
+ | * virtualChannelData (长度可变): | ||
+ | === 基础输出消息结构 === | ||
+ | * The Slow-Path Graphics Update PDU | ||
+ | * tpktHeader (4 字节) | ||
+ | * x224Data (3 字节) | ||
+ | * mcsSDin (长度可变) | ||
+ | * securityHeade (长度可变): | ||
+ | * slowPathGraphicsUpdates: | ||
+ | * shareDataHeader (8 字节) | ||
+ | * updateType (2 字节): UPDATETYPE_ORDERS(0x0000) UPDATETYPE_BITMAP(0x0001) UPDATETYPE_PALETTE(0x0002) UPDATETYPE_SYNCHRONIZE(0x0003) | ||
+ | * updateData (长度可变): | ||
+ | * TS_UPDATE_PALETTE | ||
+ | * TS_UPDATE_BITMAP | ||
+ | * TS_UPDATE_SYNC | ||
+ | * Server Fast-Path Update PDU (TS_FP_UPDATE_PDU): | ||
+ | * fpOutputHeader (1 字节): 1字节8位,各个位的内容如下: | ||
+ | * action (2 位): 识别位。 FASTPATH_OUTPUT_ACTION_FASTPATH(0x0) 表示此PDU为 Fast-Path; | ||
+ | * reserved(4 位): 保留,为0; | ||
+ | * flags (2 位): 描述此PDU的加密 FASTPATH_OUTPUT_SECURE_CHECKSUM(0x1), | ||
+ | * length1 (1 字节) | ||
+ | * length2 (1 字节)(可选) | ||
+ | * fipsInformation (4 字节)(可选) | ||
+ | * dataSignature (8 字节)(可选) | ||
+ | * fpOutputUpdates (可变长度): | ||
+ | * TS_FP_UPDATE 基本结构: | ||
+ | * updateHeader (1 字节) | ||
+ | * updateCode (4 位):类型代码 | ||
+ | * fragmentation (2 位): 消息分段标志位 FASTPATH_FRAGMENT_SINGLE(0x0) FASTPATH_FRAGMENT_LAST(0x1) FASTPATH_FRAGMENT_FIRST(0x2) FASTPATH_FRAGMENT_NEXT(0x3) | ||
+ | * compression (2位): 标志是否使用 compressionFlags , FASTPATH_OUTPUT_COMPRESSION_USED(0x2) | ||
+ | * compressionFlags (1 字节)(可选) | ||
+ | * size (2 字节) | ||
+ | * updateData (长度可变): 比如 TS_UPDATE_BITMAP_DATA | ||
+ | * TS_UPDATE_BITMAP_DATA 结构 | ||
+ | * updateType (2 字节): 16位无符号整型, 此结构固定为值 UPDATETYPE_BITMAP (0x0001). | ||
+ | * numberRectangles (2 字节): 16位无符号整型. 标识下方rectangles 字段所包含的屏幕矩形数量。 | ||
+ | * rectangles (长度可变): | ||
+ | * TS_BITMAP_DATA 的结构: | ||
+ | * destLeft (2 字节): 16位无符号整型. Left bound of the rectangle. | ||
+ | * destTop (2 字节) | ||
+ | * destRight (2 字节) | ||
+ | * destBottom (2 字节) | ||
+ | * width (2 字节): 16位无符号整型. 宽. | ||
+ | * height (2 字节): 16位无符号整型, | ||
+ | * bitsPerPixel (2 字节): 16位无符号整型. 颜色位深 bits-per-pixel. | ||
+ | * flags (2 字节): 16位无符号整型. 标识图像数据压缩 BITMAP_COMPRESSION(0x0001) NO_BITMAP_COMPRESSION_HDR(0x0400) | ||
+ | * bitmapLength (2 字节): | ||
+ | * bitmapComprHdr (8 字节): 可选 | ||
+ | * bitmapDataStream (可变长度): | ||
+ | ==== RDP连接 ==== | ||
+ | * RDP连接示意 | ||
+ | < | ||
+ | @startuml rdpconn | ||
+ | |||
+ | skinparam sequenceMessageAlign center | ||
+ | skinparam shadowing false | ||
+ | |||
+ | header RDP 连接序列说明(无中间网关) V0.1.0 by weiyongjiu | ||
+ | hide footbox | ||
+ | participant RDP客户端 | ||
+ | participant RD会话主机 | ||
+ | autonumber "< | ||
+ | ==初始化连接== | ||
+ | RDP客户端 -> RD会话主机: | ||
+ | rnote right RDP客户端 | ||
+ | **PDU**: | ||
+ | end note | ||
+ | return X.224 Connection Confirm PDU | ||
+ | ==交换基本设置== | ||
+ | RDP客户端 -> RD会话主机: | ||
+ | return MCS Connect Response PDU with \n GCC Conference Create Response | ||
+ | == 通道连接== | ||
+ | RDP客户端 -> RD会话主机: | ||
+ | RDP客户端 -> RD会话主机: | ||
+ | return MCS Attach User Confirm PDU | ||
+ | loop#Yellow 多个频道, | ||
+ | RDP客户端 -> RD会话主机: | ||
+ | return MCS Channel Join Confirm PDU | ||
+ | ||| | ||
+ | end | ||
+ | ==RDP安全起步== | ||
+ | RDP客户端 -> RD会话主机: | ||
+ | ==交换安全设置== | ||
+ | RDP客户端 -> RD会话主机: | ||
+ | ==可选:自动侦测网络质量== | ||
+ | RD会话主机 -> RDP客户端: | ||
+ | return Auto-Detect Response PDU(s) | ||
+ | ==授权许可== | ||
+ | RD会话主机 -> RDP客户端: | ||
+ | ==可选:多通道引导== | ||
+ | RD会话主机 -> RDP客户端: | ||
+ | return Initiate Multitransport Response PDU | ||
+ | ==交换功能== | ||
+ | RD会话主机 -> RDP客户端: | ||
+ | return Confirm Active PDU | ||
+ | ==连接完成== | ||
+ | rnote right RDP客户端 | ||
+ | 连接完成阶段并不是固定的, | ||
+ | 消息流具体详见[MS-RDPBCGR] 章节 1.3.1.1 | ||
+ | end note | ||
+ | RDP客户端 -> RD会话主机: | ||
+ | RDP客户端 -> RD会话主机: | ||
+ | RDP客户端 -> RD会话主机: | ||
+ | RDP客户端 -> RD会话主机: | ||
+ | RDP客户端 -> RD会话主机: | ||
+ | RD会话主机 -> RDP客户端: | ||
+ | RD会话主机 -> RDP客户端: | ||
+ | RD会话主机 -> RDP客户端: | ||
+ | RD会话主机 -> RDP客户端: | ||
+ | ||| | ||
+ | |||
+ | @enduml | ||
+ | </ |