Python Forum
NetfilterQueue - set_payload()
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
NetfilterQueue - set_payload()
#1
Hi folks,

I have the following code to modify the DNS data of a packet in python3 using netfilterqueue. However, I get the following error AttributeError: 'netfilterqueue' object has no attribute 'set_payload()' when the code finds the following sentence packet.set_payload(bytes(scapy_packet)). I tried to change it for packet.set_payload(str(scapy_packet)) just in case, but same issue. I installed netfilterqueue and also tried with NFQP3 but nothing changed.

def process_packet(packet):
    """
    Whenever a new packet is redirected to the netfilter queue,
    this callback is called.
    """
    # convert netfilter queue packet to scapy packet
    scapy_packet = IP(packet.get_payload())
    if scapy_packet.haslayer(DNSRR):
        # if the packet is a DNS Resource Record (DNS reply)
        # modify the packet
        print("[Before]:", scapy_packet.summary())
        try:
            scapy_packet = modify_packet(scapy_packet)
        except IndexError:
            # not UDP packet, this can be IPerror/UDPerror packets
            pass
        print("[After ]:", scapy_packet.summary())
        # set back as netfilter queue packet
        packet.set_payload(bytes(scapy_packet))
    # accept the packet
    packet.accept()
Any ideas??
Reply


Messages In This Thread
NetfilterQueue - set_payload() - by RGBepit88 - Apr-25-2020, 07:49 AM
RE: NetfilterQueue - set_payload() - by buran - Apr-25-2020, 07:52 AM
RE: NetfilterQueue - set_payload() - by RGBepit88 - Apr-25-2020, 07:59 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020