0

Hello all this is my code:

#!usr/bin/env python

import scapy.all as scapy
from scapy_http 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):`enter code here`
        if packet.haslayer(Raw)
            print(packet[scapy.Raw].load)

sniff("eth0")

But, every time I run this code, I get the following error:

    if packet.haslayer(Raw)
                          ^
SyntaxError: invalid syntax
Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
  • 2
    It is definitely possible to check for a Raw layer but here you have an unrelated syntax error. Could you please format your code using this [documentation](https://stackoverflow.com/editing-help#syntax-highlighting) so that we can see the error. – qouify Sep 06 '20 at 15:41
  • Not to be rude, but the issue is so obvious it doesn't seem that you researched anything at all, nor tried anything. Answering this wouldn't actually help you solve (future?) issues, but rather let you depend on forums. This isn't the spirit, have a look at https://stackoverflow.com/help/how-to-ask and https://docs.python.org/3/tutorial/ – Cukic0d Sep 07 '20 at 00:03

1 Answers1

0

You are missing a colon on this line:

if packet.haslayer(Raw):

And seeing how you used import scapy.all as scapy and not from scapy.all import *, I think it should also be

if packet.haslayer(scapy.Raw):
Gabriela Catalina
  • 151
  • 1
  • 1
  • 15