Jump to content
Sign in to follow this  
beardos

Network Packet Parser...

Recommended Posts

salam, warga Putera....

saya ahli baru, ingin bertanyakan pasal pcap related topic.. diminta tunjuk ajar... :)
saya ada buat python script/function mengenai cara nk parsing data dari network packet file...
melalui google, sya dapati cara nk parsing data tu adalah dgn menggunakan DPKT library...
link nie pula terangkan macam mana nk gunakan DPKT tu...

[url="http://jon.oberheide.org/blog/2008/10/15/dpkt-tutorial-2-parsing-a-pcap-file/"]http://jon.oberheide...ng-a-pcap-file/[/url]

masalah nya adalah, result yg saya dpt dari data parsing tu len dari link ini...
ini adalah script yg saya tulis :

[quote]pcap = dpkt.pcap.Reader(f)
i =1

for ts, buf in pcap:
try:
eth = dpkt.ethernet.Ethernet(buf)
ip = eth.data
tcp = ip.data
srcIp = socket.inet_ntoa(ip.src)
dstIp = socket.inet_ntoa(ip.dst)
sIp = int(ip.src.encode('hex'),16)
dIp = int(ip.dst.encode('hex'),16)
tcpSport = tcp.sport
tcpDport = tcp.dport
#masa = time.localtime(ts)
lTime = time.strftime("%I:%M:%S %p",time.localtime(ts))

print "=======================================================\nPacket ", i," :"
print "\nSource IP : ", srcIp
print "Destination IP : ", dstIp
print "Source IP (Encoded) :", sIp
print "Destination IP (Encoded) :", dIp
print "Source Port :", tcpSport
print "Destination Port :", tcpDport
print "Data :", eth
print "Time : ", lTime[/quote]


dan ini adalah result yg keluar dari salah satu packet itu...

[quote]Packet 22 :

Source IP : 10.0.5.168
Destination IP : 209.85.175.83
Source IP (Encoded) : 167773608
Destination IP (Encoded) : 3512053587
Source Port : 44548
Destination Port : 443
Data :
�%d�E4�D@@�.
��U�S��Ϩ������w
?yZ�L�
Time : 01:11:42 PM[/quote]

Data (eth) xsama sperti yg ditunjukan dlm link sebelum ni....
diharap boleh bantu saya.... Edited by beardos

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Similar Content

    • By amirulfaiz
      macam mana nk identify website tu dia pakai server-side scripting language dan client-side scripting language .
       
      TQ
×
×
  • Create New...