n4p1 0 Posted June 26, 2011 Hi, I have problem with parsing packet data using BinaryToString function. Im tryin capture only rtmp links from packet data using _PcapGetPacket($pcap). From reference (http://opensource.grisambre.net/pcapau3/) function return array and third element is a packet data in binary format. When I use BinaryToString there is nothing on output. Did I do something wrong? I would like convert packet to string and do some regex latter (see HttpCapture function) but I cannot get packet data in string. #include <Array.au3> #include <Winpcap.au3> $winpcap=_PcapSetup() ; initialize winpcap $pcap_devices=_PcapGetDeviceList() ; get devices list $pcap=_PcapStartCapture($pcap_devices[1][0],"tcp port 1935",1) Do $packet=_PcapGetPacket($pcap) If IsArray($packet) Then ;HttpCapture($packet[3]) ConsoleWrite(BinaryToString($packet[3])) EndIf Until $packet=-2 ; EOF _PcapStopCapture($pcap) _PcapFree() ; close winpcap Func HttpCapture($data) $links = StringRegExp($data, 'rtmp://(.*?)_definst_', 2) ConsoleWrite(IsArray($links)) EndFunc Share this post Link to post Share on other sites
PsaltyDS 39 Posted June 27, 2011 Try the loop like this to see what you are actually getting: While 1 $packet=_PcapGetPacket($pcap) If $packet=-2 Then ExitLoop ; EOF ElseIf IsArray($packet) Then ConsoleWrite("$packet[3] = " & $packet[3] & @LF) ConsoleWrite(BinaryToString($packet[3]) & @LF & @LF) EndIf WEnd Also, BinaryToString() assumes ANSI unless you tell it otherwise. See help file. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Share this post Link to post Share on other sites