import pcap import dpkt pc=pcap.pcap() #×¢£¬²ÎÊý¿ÉΪÍø¿¨Ãû£¬Èçeth0 pc.setfilter('tcp port 80') #ÉèÖüàÌý¹ýÂËÆ÷ for ptime,pdata in pc: #ptimeΪÊÕµ½Ê±¼ä£¬pdataΪÊÕµ½Êý¾Ý print ptime,pdata #...
¶Ô×¥µ½µÄÒÔÌ«ÍøV2Êý¾Ý°ü(raw packet)½øÐнâ°ü
p=dpkt.ethernet.Ethernet(pdata) if p.data.__class__.__name__=='IP': ip='%d.%d.%d.%d'%tuple(map(ord,list(p.data.dst))) if p.data.data.__class__.__name__=='TCP': if data.dport==80: print p.data.data.data # by gashero
ÇëÎÊÏ£¬ÎÒµÄÊÇpython2.5°²×°ÁËPILÄ£¿é£¬È»ºó±àд³ÌÐò´ò¿ª±¾»úÉϵÄÒ»¸öͼƬʱ£¬ÎªÊ²Ã´ÀϳöÏÖ´íÎóÄØ£¬ÀÏÊÇÕÒ²»µ½Í¼Æ¬£¬´íÎóÌáʾÈçÏ£ºFile "C:\Python25\Lib\site-packages\PIL\Image.py", line 1888, in o ......