Skip to content

How to exit netfilter block? #65

Closed

Description

@k-zd

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)

Activity

  1. added a commit that references this issue on Jan 13, 2022
    0187c89
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