2012-11-29 60 views
1

我正在嘗試讀取一些flex/amf流量,但缺乏正確的文檔/示例使其非常困​​難。AMF解碼示例

有人請走我通過下面的RTMP/AMF3數據包的解碼:

0x43, 0x00, 0x68, 0xcd, 0x00, 0x01, 0x33, 0x11, 0x00, 0x05, 0x00, 0x40, 0x33, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x11, 0x0a, 0x81, 0x13, 0x4f, 0x66, 0x6c, 0x65, 0x78, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x69, 0x6e, 0x67, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x74, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x0d, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x13, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x0f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x17, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x13, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x49, 0x64, 0x11, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x15, 0x74, 0x69, 0x6d, 0x65, 0x54, 0x6f, 0x4c, 0x69, 0x76, 0x65, 0x13, 0x74, 0x69, 0x6d, 0x65, 0xc3, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x09, 0x62, 0x6f, 0x64, 0x79, 0x01, 0x06, 0x29, 0x6c, 0x69, 0x73, 0x74, 0x41, 0x6c, 0x6c, 0x50, 0x72, 0x61, 0x63, 0x74, 0x69, 0x63, 0x65, 0x47, 0x61, 0x6d, 0x65, 0x73, 0x0a, 0x0b, 0x01, 0x21, 0x44, 0x53, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x04, 0x3c, 0x15, 0x44, 0x53, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x06, 0x11, 0x6d, 0x79, 0x2d, 0x72, 0x74, 0x6d, 0x70, 0x73, 0x09, 0x44, 0x53, 0x49, 0x64, 0x06, 0x49, 0x42, 0x45, 0x32, 0x34, 0x31, 0x32, 0x33, 0x34, 0x2d, 0x31, 0x45, 0x31, 0x39, 0x2d, 0x30, 0x33, 0x43, 0x33, 0x2d, 0x39, 0x30, 0x34, 0x43, 0x2d, 0x32, 0x31, 0x36, 0x33, 0x36, 0x36, 0x30, 0x41, 0x42, 0x34, 0x37, 0x46, 0x01, 0x06, 0x17, 0x67, 0x61, 0x6d, 0x65, 0x53, 0x65, 0xc3, 0x72, 0x76, 0x69, 0x63, 0x65, 0x06, 0x49, 0x31, 0x34, 0x43, 0x30, 0x46, 0x42, 0x38, 0x30, 0x2d, 0x46, 0x37, 0x43, 0x34, 0x2d, 0x42, 0x42, 0x34, 0x42, 0x2d, 0x31, 0x46, 0x32, 0x34, 0x2d, 0x34, 0x39, 0x36, 0x32, 0x38, 0x30, 0x42, 0x38, 0x39, 0x33, 0x42, 0x38, 0x01, 0x04, 0x00, 0x04, 0x00, 0x09, 0x01, 0x01 

我Attemps:

×43 - 0100 0011:[01] - 1型= RTMP頭會7個字節。流ID - 3,將在這個單個字節中。

也設法讀取移位UTF 1位以下來獲得長度:

0x4f:flex.messaging.messages.RemotingMessage

0X0D:源

0×13:操作

爲0x0F:頭

0×17:目的地

0×13:MESSAGEID

爲0x11:客戶端ID

爲0x15:傳輸TimeToLive

這裏我猜停止, 「時間」/ 「郵票」 似乎並沒有工作。當然,我無法理解所有其他字節是如何編碼的(對象/數組等)。

回答

1
0x43, 0x00, 0x68, 0xcd, 0x00, 0x01, 0x33, 0x11 

1字節+ 7個字節RTMP頭數據[0]

0x00, 0x05, 0x00, 0x40, 0x33, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05 

Flex的魔法字節,是與調用版本,ID等AMF3數據

0x11 

啓動

0x0a..... 

AMF3對象,並定期AMF3編碼[1]

備註RTMP,它組塊的AMF數據到最小128個字節,這將在隨後的單個報頭字節(未AMF的一部分),例如0xc3在上述例。

1

我通過閱讀

AMF0

AMF3

一些更多的例子可以在Wikipedia找到啓動。

然後你可能不需要的RTMP Specification

接下來,您可以查看FluorineFX的源代碼。這讓我開始理解事情。 Sources FluorineFX。我所做的是在FluorineFX源代碼中設置斷點,然後通過Flex應用程序進行調用。然後我可以通過FluorineFX源代碼來理解事物(在我旁邊有AMF規範)。

規範很難閱讀,但它們真的是解析字節所需的全部。可能也看看this JavaScript AMF project