Python/Eth Hacking: packet sniffer (Extracting data from a specific layer)

Hi Zaid

I have my code the same as yours and I’m getting the following error when executing python packet_sniffer.py - Hope you can help.

ERROR
Traceback (most recent call last):
File “packet_sniffer.py”, line 15, in
sniff(“eth0”)
File “packet_sniffer.py”, line 8, in sniff
scapy.sniff(iface=interface, store=False, prn=process_sniffed_packet)
File “/usr/lib/python2.7/dist-packages/scapy/sendrecv.py”, line 780, in sniff
r = prn§
File “packet_sniffer.py”, line 12, in process_sniffed_packet
if packet.haslayer(http.HTTPrequest):
AttributeError: ‘module’ object has no attribute ‘HTTPrequest’

Code
#!/usr/bin/env python

import scapy.all as scapy
from scapy.layers import http

def sniff(interface):
scapy.sniff(iface=interface, store=False, prn=process_sniffed_packet)

def process_sniffed_packet(packet):
if packet.haslayer(http.HTTPrequest):
print(packet.show())

sniff(“eth0”)

I have kali running on a NAT network and eth0 is connected and working. I also did pip install scapy_http successfully in the previous lecture.

Thanks

Literally just figured it out 5 minutes after posting this… uhh :man_facepalming:

I made a typo in the line:

missed the capital “r” in (HTTPRequest): :wink: