Basic Netfilterqueue Python Usage

I want to act as a proxy, I would like to manage the receiving packet from the second level or level 3 if possible, I am struggling with it, with most of the basics, and I cannot get this to work, I tell you that I:

This is my code (proxda.py)

from netfilterqueue import NetfilterQueue

def print_and_accept(pkt):
    print pkt
    pkt.accept()

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

      

The code was taken directly from the python documentation: https://pypi.python.org/pypi/NetfilterQueue/0.3

This is the rule iptable

I'm setting up:

iptables -I INPUT -d 173.16.0.229 -j NFQUEUE --queue-num 1

      

Idea is all traffic sent at 173.16.0.229 to my program

And this is a scenario so simple: I ping 173.16.0.236 to 173.16.0.229 while my proxa.py program is running and I am not committing anything.

Any idea on where I am failing and how to debug / get this working?

Thanks in advance.

+3


source to share


1 answer


I ask myself: the problem was in the rules on iptables, my IP was 173.16.0.236 and I was filtering the incoming traffic to 173.16.0.229. Just by changing:

iptables -I INPUT -d 173.16.0.229 -j NFQUEUE --queue-num 1 

to: iptables -I OUTPUT -d 173.16.0.229 -j NFQUEUE --queue-num 1 

or to :  iptables -I INPUT -d 173.16.0.236 -j NFQUEUE --queue-num 1.

      



Be careful with the last line, because all INPUT traffic to our computer goes to NFQUEUE, in my case a disaster because I am connected via ssh and the connection will decay. For example, I use this rule:

iptables -I OUTPUT -s 173.16.0.236 -p tcp --dport 80 -j NFQUEUE --queue-num 1

      

0


source







All Articles