{"id":15,"date":"2005-02-16T19:53:26","date_gmt":"2005-02-17T03:53:26","guid":{"rendered":"http:\/\/outflux.net\/blog\/archives\/2005\/02\/16\/hitchhikers-guide-to-reverse-engineering\/"},"modified":"2005-08-29T20:05:43","modified_gmt":"2005-08-30T03:05:43","slug":"hitchhikers-guide-to-reverse-engineering","status":"publish","type":"post","link":"https:\/\/outflux.net\/blog\/archives\/2005\/02\/16\/hitchhikers-guide-to-reverse-engineering\/","title":{"rendered":"Hitchhiker&#8217;s Guide to Reverse Engineering"},"content":{"rendered":"<p>Well, I got annoyed that I couldn&#8217;t watch the SWF-based HitchHiker&#8217;s trailer on the <a href=\"http:\/\/amazon.com\/\">Amazon.com<\/a> main page.  <code>swf_play<\/code> failed miserably.  Most of the crap Apple pulls for their movie trailer stream-hiding is simple enough to work around.  Generally I just keep downloading the MOVs, running <code>strings<\/code> on them until I find the actual MOV with the movie trailer in it, but Amazon&#8217;s wasn&#8217;t so easy.  I found the base <a href=\"rtmp:\/\/fcs.amazon.speedera.net\/vod\/fcs.amazon\/\">URL to the video<\/a> easily enough in the XML parameters file.  The hard part was figuring out what the hell &#8220;rtmp&#8221; is.  <a href=\"http:\/\/www.mplayerhq.hu\/\">mplayer<\/a> didn&#8217;t recognize it, and after a quick <a href=\"http:\/\/www.insecure.org\/nmap\/\">nmap<\/a> of the media server, I just got more confused.  nmap listed a port 1935 called &#8220;rmtp&#8221;.  Digging around a little it became <a href=\"http:\/\/www.macromedia.com\/cfusion\/knowledgebase\/index.cfm?id=tn_16631\">very obvious<\/a> that nmap&#8217;s services entry was just a typo.  So I sent in a quick patch, and Fyodor accepted it within minutes.  Pretty cool.<\/p>\n<p>Anyway, on to the protocol dissection.  I set up tcpdump to record everything sent to <code>fcs.amazon.speedera.net<\/code>, and took a look at it in <a href=\"http:\/\/ethereal.org\/\">Ethereal<\/a>.  Seeing that it was mostly binary, I looked around for something that would dump the data portion of a packet stream, but ended up empty handed.  I&#8217;ve repeatedly wanted this, so I finally broke down and read up on coding with <a href=\"http:\/\/www.tcpdump.org\/\">libpcap<\/a>.  It&#8217;s easy enough to use, but I floundered with the packet headers for a while.  Eventually I managed to find the data portion of the packets, and was able to dump the client stream and the server stream separately.  I wish there was a button on Ethereal&#8217;s &#8220;Follow TCP Stream&#8221; window that would just let me save the data.  My tool doesn&#8217;t at all track sequence numbers or retransmissions, etc, so I worry that in some situations I won&#8217;t get a &#8220;true&#8221; stream dump.  I suspect Ethereal handles that correctly, but I couldn&#8217;t tell you for sure.<\/p>\n<p>After looking at this protocol dump, it seems like it ends up turning into some kind of SOAP-like communication, with function call literals like <code>getStreamLength<\/code>, <code>createStream<\/code>, <code>play<\/code>, and <code>closeStream<\/code>.  There&#8217;s even a <code>_result<\/code> variable mentioned.  The Flash coding docs I&#8217;ve found that talk about stream display don&#8217;t seem to mention this stuff at all, but maybe I didn&#8217;t dig far enough.<\/p>\n<p>Since RTMP appears to be capable of streams, etc, I think the next step is to figure out how it reacts to things like &#8220;Pause&#8221; and &#8220;Stop&#8221; during playback.  Clearly there is a stream-identification system in the headers, and there must be stream length indicators.  I&#8217;m so annoyed that there is absolutely no discussion of RTMP anyway.  I should go look at the <code>swf_play<\/code> source before I go much further.<\/p>\n<p style='text-align:left'>&copy; 2005, <a href=\"https:\/\/outflux.net\/blog\/\">Kees Cook<\/a>. This work is licensed under a <a rel=\"license\" href=\"http:\/\/creativecommons.org\/licenses\/by-sa\/4.0\/\">Creative Commons Attribution-ShareAlike 4.0 License<\/a>.<br \/><a rel=\"license\" href=\"http:\/\/creativecommons.org\/licenses\/by-sa\/4.0\/\"><img decoding=\"async\" alt=\"CC BY-SA 4.0\" style=\"border-width:0\" src=\"https:\/\/i.creativecommons.org\/l\/by-sa\/4.0\/88x31.png\" \/><\/a> <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Well, I got annoyed that I couldn&#8217;t watch the SWF-based HitchHiker&#8217;s trailer on the Amazon.com main page. swf_play failed miserably. Most of the crap Apple pulls for their movie trailer stream-hiding is simple enough to work around. Generally I just keep downloading the MOVs, running strings on them until I find the actual MOV with [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,10],"tags":[],"_links":{"self":[{"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/posts\/15"}],"collection":[{"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/comments?post=15"}],"version-history":[{"count":0,"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/posts\/15\/revisions"}],"wp:attachment":[{"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/media?parent=15"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/categories?post=15"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/tags?post=15"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}