Sign up here and you can log into the forum!

AMF Raw Response

youtube/live365/pandora/flickr replacements & other web services

AMF Raw Response   

Postby Gui » Thu Dec 20, 2012 12:14 pm

Hey all

Contextualization:
While making some previous tests for a plugin development ( Front Army TV ) i realized that the videos are hosted by brightcove.com
But the video url's don't appear in the player parameters. Ex: http://www.frontarmy.com/front-tv/
After some digging i realize that they come from a response to an AMF POST.
So i start investigating Action Message Format ( http://en.wikipedia.org/wiki/Action_Message_Format ) and ways to parse it .
There are a lot of support even for php and some py scripts from other plugins but i'm thinking in something different.

Objective:
Since i just want to access the POST response in Raw i though that i could create a proxy POST that fakes the headers and parameters and file_get_contents its response.

Problem:
I'm somewhere failing because all i get is the same funny response as if you open the AMF link directly. Ex: http://c.brightcove.com/services/messagebroker/amf?playerId=1708677711001

Code: Select all
<?php

$postdata = http_build_query(
    array(
        'playerId' => '1708677711001',
    )
);

$opts = array(
    'http' => array(
        'method' => "POST /services/messagebroker/amf?playerId=1708677711001 HTTP/1.1",
            'header' => "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11",
            "Accept: */*",
            "Accept-Language: en-US,en;q=0.8",
            "Accept-Encoding: gzip,deflate,sdch",
         "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3",
            "Connection: keep-alive",
            "Content-Type: application/x-amf",
            "Host: c.brightcove.com".
         "Origin: http://admin.brightcove.com".
         "Referer: http://admin.brightcove.com/viewer/us20121218.1107/federatedVideoUI/BrightcovePlayer.swf?uid=1356025331840".
            "Content-Length: 150",
        'content' => $postdata
  )
);

$context = stream_context_create($opts);
$encontext = urlencode($context);
$result = file_get_contents('http://c.brightcove.com/services/messagebroker/amf?playerId=1708677711001', false, $encontext);
print_r($result);


Data:

Headers:
Code: Select all
Request Headers

POST http://c.brightcove.com/services/messagebroker/amf?playerId=1708677711001 HTTP/1.1

CLIENT:
Accept: */*
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11

Entity:
Content-Length: 150
Content-Type: application/x-amf

Miscellaneous:
Origin: http://admin.brightcove.com
Referer: http://admin.brightcove.com/viewer/us20121218.1107/federatedVideoUI/BrightcovePlayer.swf?uid=1356025331840

Transport:
Host: c.brightcove.com
Connection: keep-alive

.......Mcom.brightcove.experience.ExperienceRuntimeFacade.getProgrammingForExperience../1...9
.......(7a726d8ad306054bdcf01374df1988871fc09f59.BxÝR.I..


-----------------------------------------------------\\----------------------------------------------------------------------------------

Response Headers

HTTP/1.1 200 OK

Cache:
Date: Thu, 20 Dec 2012 17:42:25 GMT
Vary: Accept-Encoding

Entity:
Content-Type: application/x-amf

Miscellaneous:
X-BC-Client-IP: XX.XXX.XX.XXX
X-BC-Connecting-IP: XX.XXX.XX.XXX
Server: brightcove


Raw Response Example:
Code: Select all
����� /1/onResult���3Ù   videoList
skcom.brightcove.player.programming.ProgrammedLineupDTOidcomponentRefIdplayerId%mediaCollectionDTO   typelineupIdversionBxÁt•
��
‚Ucom.brightcove.catalog.trimmed.PlaylistDTOmediaIdsvideoDTOsfilteredCountvideoIdsmediaDTOsvideoCount!currentPageIndexreferenceIdrecordsPerPagemediaCountthumbnailisSubmitted!shortDescriptionlongDescriptiondisplayName      9
‰Ocom.brightcove.catalog.trimmed.VideoDTOdateFiltered+FLVFullLengthStreamed/SWFVerificationRequiredendDateFLVFullCodeclinkTextcaptionspreviewLengthgeoRestrictedFLVPreviewSize.thumbnailURLFLVPreBumperURLpurchaseAmountvideoStillURLsharedByyearProducedcuePointssubmitted#customFieldValuesratingEnumIOSRenditionsfilterStartDate,
awardsrentalAmountFLVFullSizedrmMetadataURLeconomicspublishedDatelanguage!FLVFullLengthURLstartDatelogoOverlayforceAdsFLVPreviewURL*publisherName
adKeys
lengthrentalPeriod)sharedByExternalAcctadCategories%FLVPreviewStreamed+allowViralSyndication)FLVPreBumperStreamed   tagssharedSourceIdpublisherId!allowedCountriescontrollerTypeencodingRatemonthlyAmountcustomFieldsfilterEndDateFLVPreviewCodec"WMVFullAssetIdnumberOfPlays)sharedToExternalAcct5FLVPreBumperControllerTypecreationDate-excludeListedCountries colorrenditionslinkURLcategories0!WMVFullLengthURL����������������‚   http://brightcove.vo.llnwd.net/d21/unsecured/media/626978504/626978504_2007831156001_901868133-156-1354550392055.jpg?pubId=626978504‚   http://brightcove.vo.llnwd.net/d21/unsecured/media/626978504/626978504_2007831157001_901868133-156-1354550392290.jpg?pubId=626978504   !FRONT TV: NicoleAA2\����Bs¶( à�‚
http://brightcove.vo.llnwd.net/d21/unsecured/media/626978504/626978504_2007932711001_FRONT-TV---Issue176-nicole-feature-1-1280x720.mp4B}7ñ€\�Sonic TV@ðmÀ����      
#;com.brightcove.catalog.TagDTO   name image
nicole

Nicole Neal

front magazine

 frontA¯wd���   �†D�@ÝP������Bs¶( à�   
acom.brightcove.catalog.trimmed.RenditionAssetDTOdefaultURLframeWidth#mediaDeliveryTypevideoContainervideoCodecaudioOnlyframeHeight   size‚
http://brightcove.vo.llnwd.net/d21/unsecured/media/626978504/626978504_2007936635001_FRONT-TV---Issue176-nicole-feature-1-1280x720.mp4€ÁÖ6…��   H264‚hAq���
:†Dƒ`�`‚ AA2\����
‚


Help? :D
User avatar
Gui
Developer
 
Posts: 161
Joined: Wed Jan 11, 2012 4:19 pm
Location: Hellgarve

Re: AMF Raw Response   

Postby Gui » Sun Dec 23, 2012 11:24 am

Solution:

Code: Select all
<?php

         $req = "\x00\x03\x00\x00\x00\x01\x00\x4D\x63\x6F\x6D\x2E\x62\x72\x69\x67\x68\x74\x63\x6F\x76\x65\x2E\x65\x78\x70\x65\x72\x69\x65\x6E\x63\x65\x2E\x45\x78\x70\x65\x72\x69\x65\x6E\x63\x65\x52\x75\x6E\x74\x69\x6D\x65\x46\x61\x63\x61\x64\x65\x2E\x67\x65\x74\x50\x72\x6F\x67\x72\x61\x6D\x6D\x69\x6E\x67\x46\x6F\x72\x45\x78\x70\x65\x72\x69\x65\x6E\x63\x65\x00\x02\x2F\x31\x00\x00\x00\x39\x0A\x00\x00\x00\x02\x02\x00\x28\x37\x61\x37\x32\x36\x64\x38\x61\x64\x33\x30\x36\x30\x35\x34\x62\x64\x63\x66\x30\x31\x33\x37\x34\x64\x66\x31\x39\x38\x38\x38\x37\x31\x66\x63\x30\x39\x66\x35\x39\x00\x42\x78\xDD\x52\x0C\x49\x90\x00";

            $out = "POST /services/messagebroker/amf?playerId=1708677711001 HTTP/1.1\r\n" .
                   "Host: c.brightcove.com\r\n" .
                   "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1\r\n" .
                   "Referer: http://admin.brightcove.com/viewer/us20121218.1107/federatedVideoUI/BrightcovePlayer.swf?uid=1356025331840\r\n" .
                   "Content-type: application/x-amf\r\n" .
                   "Content-length: 150\r\n" .
                   "Connection: close\r\n\r\n" .
                   $req;
            $fp = fsockopen(gethostbyname("c.brightcove.com"), 80, $errno, $errstr, 5);
            fwrite($fp, $out);
            $in = "";
            while (!feof($fp)) {
                $s = fgets($fp, 1024);
                $in .= $s;
            }
            fclose($fp);
            $content = $in;
         print_r($content);


:D
User avatar
Gui
Developer
 
Posts: 161
Joined: Wed Jan 11, 2012 4:19 pm
Location: Hellgarve

Re: AMF Raw Response   

Postby b-rad.cc » Sun Dec 23, 2012 10:10 pm

nice research gui :geek:
PM's are for private matters only, please post public matters on the forum to help others who might have the same issue.
:mrgreen:
User avatar
b-rad.cc
WDLXTV Team
 
Posts: 3003
Joined: Sat Apr 03, 2010 9:35 am
Location: New York


Return to WDTVL Proxy Project

Who is online

Users browsing this forum: No registered users and 2 guests