Skip to content

How to exit netfilter block? #65

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

Closed
k-zd opened this issue Apr 23, 2021 · 0 comments · Fixed by #77
Closed

How to exit netfilter block? #65

k-zd opened this issue Apr 23, 2021 · 0 comments · Fixed by #77

Comments

@k-zd
Copy link

k-zd commented Apr 23, 2021

I'm running this code:

import os, sys

queue = NetfilterQueue()
QUEUE_NUM1 = 1

def changing_payload(pkt):
    global binary_rep
    if len(binary_rep) == 0:
         raise KeyboardInterrupt
    print(binary_rep)
    binary_rep = binary_rep[1:]
    

binary_rep = "0101000021002220201551051101545"

try:
    os.system("iptables -I OUTPUT -d 10.0.1.0/24 -p udp --dport 7078 -j NFQUEUE --queue-num {}".format(QUEUE_NUM1))
    queue.bind(QUEUE_NUM1, changing_payload)
    queue.run()
except KeyboardInterrupt:
    queue.unbind()
    os.system("iptables --flush")
    print('Message sent..')

and get error message but netfilterqueue que is still running:

Traceback (most recent call last):
  File "/home/nfq.py", line 10, in changing_payload
    raise KeyboardInterrupt("Should stop")
KeyboardInterrupt: Should stop

Any ideas how could I stop netfilterqueue without exiting program? (BTW pressing "CTRL+C" isn't working too)

oremanj added a commit that referenced this issue Jan 13, 2022
Propagate exceptions raised by the user's packet callback -- fixes #31, #50
Warn about exceptions raised by the packet callback during queue unbinding
Raise an error if a packet verdict is set after its parent queue is closed
set_payload() now affects the result of later get_payload() -- fixes #30
Handle signals received when run() is blocked in recv() -- fixes #65
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant