★ wanayoo — archive 1999 https://github.com/kti/python-netfilterqueue/issues/50Nouvelle recherche | Portail wanayoo
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception ignored in: 'netfilterqueue.global_callback' #50

Open
likiiiiii opened this issue Apr 23, 2019 · 1 comment
Open

Exception ignored in: 'netfilterqueue.global_callback' #50

likiiiiii opened this issue Apr 23, 2019 · 1 comment

Comments

@likiiiiii
Copy link

@likiiiiii likiiiiii commented Apr 23, 2019

from netfilterqueue import NetfilterQueue
from scapy.all import *

def print_and_accept(pkt):
print(pkt)
pl = IP(pkt.get_payload())
print(pl.show())
pl[IP].dst = "172.17.0.3"
del pl[IP].len, pl[IP].chksum, pl[TCP].chksum
print(">>>payload: ",str(pl))
pkt.set_payload(str(pl))
hw = pkt.get_hw()
if hw:
print(":".join("{:02x}".format(c) for c in hw[0:6]))
pkt.accept()

nfqueue = NetfilterQueue()
nfqueue.bind(0, print_and_accept)
try:
nfqueue.run()
except KeyboardInterrupt:
print('')

nfqueue.unbind()

following is the output:

###[ IP ]###
version = 4
ihl = 5
tos = 0x0
len = 52
id = 43486
flags = DF
frag = 0
ttl = 127
proto = tcp
chksum = 0x2028
src = /old?u=https%3A%2F%2Fgithub.com%2Fkti%2Fpython-netfilterqueue%2Fissues%2F192.168.197.1%3Cbr&y=1999> dst = 172.17.0.2
\options
###[ TCP ]###
sport = 10732
dport = http
seq = 3132586654
ack = 0
dataofs = 8
reserved = 0
flags = S
window = 64240
chksum = 0xe2cf
urgptr = 0
options = [('MSS', 1460), ('NOP', None), ('WScale', 8), ('NOP', None), ('NOP', None), ('SAckOK', b'')]

None

payload: b'E\x00\x004\xa9\xde@\x00\x7f\x06 (\xc0\xa8\xc5\x01\xac\x11\x00\x03)\xec\x00P\xba\xb7z\x9e\x00\x00\x00\x00\x80\x02\xfa\xf0\xe2\xcf\x00\x00\x02\x04\x05\xb4\x01\x03\x03\x08\x01\x01\x04\x02'
Exception ignored in: 'netfilterqueue.global_callback'
Traceback (most recent call last):
File "nfq3.py", line 10, in print_and_accept
pkt.set_payload(str(pl))
TypeError: Argument 'payload' has incorrect type (expected bytes, got str)

@strictlymike
Copy link

@strictlymike strictlymike commented Dec 3, 2019

Duplicates #31

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.