Skip to content

Exception ignored in: 'netfilterqueue.global_callback' #50

Closed

Description

@jieyoujun

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 = 192.168.197.1
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)

Activity

  1. strictlymike commented on Dec 3, 2019

    @strictlymike

    Duplicates #31

  2. added a commit that references this issue on Jan 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions