oremanj / python-netfilterqueue

Python bindings for libnetfilter_queue
MIT License
248 stars 96 forks source link

When I drop the packet I get an exception that the verdict has already being given for the packet how can I overcome this #57

Closed masind closed 2 years ago

masind commented 4 years ago

import scapy.all as scapy import socket from colorama import Fore,init from dns import reversename,resolver import re init() def process_packet(packet): scapy.packet=scapy.IP(packet.get_payload()) if scapy.packet.haslayer(scapy.Raw): if scapy.packet[scapy.TCP].dport==443: tcppayload=scapy.packet[scapy.Raw].load if re.search('\x16\x03',str(tcppayload),flags=0): print("mull")
packet.drop()

    elif scapy.packet[scapy.TCP].sport==443:
        #print(Fore.GREEN+"[+]HTTP RESPONSE")
        ann=scapy.packet[scapy.IP].src
        #print(str(ann))

packet.accept()

queue=netfilterqueue.NetfilterQueue() queue.bind(0,process_packet) queue.run()

jllorente commented 3 years ago

Hi @masind , can you please paste your code inside a code-block ? The indentation is messed up :)

oremanj commented 2 years ago

It's hard to tell from the indentation, but it looks like you're calling accept() unconditionally, even though you've already called drop() in some cases. Only the first verdict (of accept, drop, repeat) that you issue will have any effect, so netfilterqueue makes issuing a second verdict for the same packet an error.