I was trying to understand how to make a http sniffer in python scapy here's a code which I'm trying to understand
#!/usr/bin/python
from scapy.all import *
def http_header(packet):
http_packet=str(packet)
if http_packet.find('GET'):
return GET_print(packet)
def GET_print(packet1):
ret = "***************************************GET PACKET****************************************************\n"
ret += "\n".join(packet1.sprintf("{Raw:%Raw.load%}\n").split(r"\r\n"))
ret += "*****************************************************************************************************\n"
return ret
sniff(iface='eth0', prn=http_header, filter="tcp port 80")
But I can't understand what GET_print function exactly do actually I know what join()
and split(r"\r\n")
should do in simple way but I don't know sprintf("{Raw:%Raw.load%}\n")
doing Here and when it come to tie it all together i don't get it
Simply I want a simple clarification of what this line "\n".join(packet1.sprintf("{Raw:%Raw.load%}\n").split(r"\r\n"))
must do
NOTE Here's where I got this code :HTTP GET packet sniffer in Scapy
)` gives you a new string `"a\nb\nc"`.
– viswajithiii Jul 18 '17 at 10:59