Skip to content

Instantly share code, notes, and snippets.

@narbehaj
Last active June 16, 2022 08:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save narbehaj/de492b4eaaff4b6a02818d2e5b6542c1 to your computer and use it in GitHub Desktop.
Save narbehaj/de492b4eaaff4b6a02818d2e5b6542c1 to your computer and use it in GitHub Desktop.
Python scapy to sniff HTTP
from scapy.all import *
def packet_callback(packet):
if packet[TCP].payload:
if packet[IP].dport == 80:
print("\n{} ----HTTP----> {}:{}:\n{}".format(packet[IP].src,
packet[IP].dst,
packet[IP].dport,
str(bytes(packet[TCP].payload))))
sniff(filter='tcp', prn=packet_callback, store=0, count=0)
@vigack
Copy link

vigack commented Sep 27, 2018

oneline:

sniff(lfilter= lambda pkt:TCP in pkt and (pkt[TCP].dport==80 or pkt[TCP].sport==80), prn=lambda x:x.sprintf("{IP:%IP.src% -> %IP.dst%\n}{Raw:%Raw.load%\n}"))

@vipcks
Copy link

vipcks commented Jun 16, 2022

http response body is unknow_code :

'(\x00\x00\x00\xaa\x00\x00\x000\x08\x04"\x95\x01\x08\x9b\x80\xa5\xa9\x06\x10\xff\r\x18\x94\n

this why?please!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment