简体   繁体   English

AMF解码示例

[英]AMF decoding example

i am trying to read some flex/amf traffic, but the lack of proper documentation / examples making it really hard. 我正在尝试阅读一些flex / amf流量,但是缺少适当的文档/示例,这真的很困难。

Can someone please walk me through the decoding of the following rtmp/amf3 packet: 有人可以引导我完成以下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

My Attemps: 我的尝试:

0x43 - 0100 0011 : [01] - type 1 = rtmp header will be 7 bytes. 0x43-0100 0011:[01]-类型1 = rtmp标头为7个字节。 Stream ID - 3, will be in this single byte. 流ID-3将在此单个字节中。

Also managed to read the following with shifting the UTF 1 bit to get the length: 通过将UTF移位1位以获取长度,还设法读取了以下内容:

0x4f: flex.messaging.messages.RemotingMessage 0x4f:flex.messaging.messages.RemotingMessage

0x0d: source 0x0d:来源

0x13: operation 0x13:操作

0x0f: headers 0x0f:标头

0x17: destination 0x17:目的地

0x13: messageId 0x13:messageId

0x11: clientId 0x11:clientId

0x15: timeToLive 0x15:timeToLive

Here my guessing stops, "time" / "stamp" does not seem to work. 在这里,我的猜测停止了,“时间” /“戳记”似乎不起作用。 Of course i am failing to understand how all the other bytes are encoded (objects / arrays etc); 当然,我无法理解所有其他字节的编码方式(对象/数组等);

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

1byte+7bytes RTMP header data [ 0 ] 1byte + 7bytes RTMP标头数据[ 0 ]

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

Flex magic bytes, something to do with invoke version, id, etc Flex魔术字节,与调用版本,ID等有关

0x11

start of AMF3 data AMF3数据的开始

0x0a.....

AMF3 object, and regular AMF3 encoding [ 1 ] AMF3对象和常规AMF3编码[ 1 ]

Note about RTMP, it chunks the AMF data to minimum 128 bytes, which will be followed by a single header byte (not part of AMF), eg 0xc3 in above example. 关于RTMP,请注意,它将AMF数据分块为最少128个字节,然后是单个标头字节(不是AMF的一部分),例如上述示例中的0xc3。

I'd start by reading 我将从阅读开始

AMF0 AMF0

AMF3 AMF3

Some more examples can be found on Wikipedia . 可以在Wikipedia上找到更多示例。

And then the RTMP Specification which you probably won't need. 然后,您可能不需要的RTMP规范

Next, you could look into the source code of FluorineFX. 接下来,您可以查看FluorineFX的源代码。 That got me started to understand things. 那使我开始了解事物。 Sources FluorineFX . 来源FluorineFX What I did was setting breakpoints in the FluorineFX source code and then making a call from a Flex application. 我所做的是在FluorineFX源代码中设置断点,然后从Flex应用程序进行调用。 Then I could step throught the FluorineFX source code to understand things (with next to me the AMF specifications). 然后,我可以逐步浏览FluorineFX源代码以了解内容(旁边是AMF规范)。

The specifications are hard to read, but they are really all you need to parse the bytes. 规范很难阅读,但实际上它们是解析字节所需的全部。

Maybe also have a look at this JavaScript AMF project . 也许也看看这个JavaScript AMF项目

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM