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.
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??