本文整理汇总了Python中nfqueue.queue函数的典型用法代码示例。如果您正苦于以下问题:Python queue函数的具体用法?Python queue怎么用?Python queue使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了queue函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: bind
def bind(self):
self.q = nfqueue.queue()
self.q.open()
self.q.bind(socket.AF_INET)
self.q.set_callback(self.callback)
self.q.create_queue(0)
self.q.try_run()
示例2: out_queue
def out_queue():
"""setup the NF_queue to "rule" the outgoing packets"""
q = nfqueue.queue()
q.open()
# need to be done once
# performed in In.py
#q.unbind(AF_INET6)
#q.bind(AF_INET6)
q.set_callback(callback)
q.create_queue(2)
q.set_queue_maxlen(5000)
# send a Router Solitication to all neighboring routers
# (only at the launch of the program)
if not NDprotector.is_router:
SendRTSol()
return q
示例3: start_dns_queue
def start_dns_queue(self):
self.q = nfqueue.queue()
self.q.set_callback(self.nfqueue_callback)
self.q.fast_open(0, socket.AF_INET)
self.q.set_queue_maxlen(5000)
reactor.addReader(self)
self.q.set_mode(nfqueue.NFQNL_COPY_PACKET)
示例4: fuzzThread
def fuzzThread(self, button, aFilter):
self.log.info(_("Launching fuzzing process with : filter=\"{0}\"").format(aFilter.get_text()))
## Set Netfilter NFQUEUE
# os.popen("sudo iptables -I OUTPUT -p tcp --dport 80 -j NFQUEUE 2>&1 > /dev/null")
# os.popen("sudo iptables -I OUTPUT -p tcp --sport 80 -j NFQUEUE 2>&1 > /dev/null")
q = nfqueue.queue()
q.open()
try:
q.unbind(socket.AF_INET)
except:
pass
q.bind(socket.AF_INET)
q.set_callback(self.nfqueue_cb)
q.create_queue(0)
q.set_queue_maxlen(5000)
try:
## TODO : do it in a dedicated process
q.try_run()
except:
pass
q.unbind(socket.AF_INET)
q.close()
# os.popen("sudo iptables -D OUTPUT -p tcp --dport 80 -j NFQUEUE 2>&1 > /dev/null")
# os.popen("sudo iptables -D OUTPUT -p tcp --sport 80 -j NFQUEUE 2>&1 > /dev/null")
gobject.idle_add(button.set_sensitive, True)
示例5: run
def run(cls, template_path=''):
# check if root
if not os.geteuid() == 0:
exit("\nPlease run as root\n")
os_pattern = get_os_pattern(template_path)
# Flush the IP tables first
flush_tables()
# Configure NFQUEUE target
# Capture incoming packets and put in nfqueue 1
os.system('iptables -A INPUT -j NFQUEUE --queue-num 0')
# creation of a new queue object
q = nfqueue.queue()
q.set_callback(ProcessPKT(os_pattern).callback)
q.fast_open(0, socket.AF_INET)
q.set_queue_maxlen(-1)
# process queue for packet manipulation
try:
workers = list()
for i in range(2):
workers.append(gevent.spawn(cls.worker, q))
gevent.joinall(workers)
except KeyboardInterrupt:
# on exit clean up
q.unbind(socket.AF_INET)
q.close()
flush_tables()
print 'Exiting...'
示例6: run
def run(self):
q = nfqueue.queue()
if self.verbose:
print "NFQ: open"
q.open()
if self.verbose:
print "NFQ: bind"
q.bind(AF_INET)
if self.verbose:
print "NFQ: setting callback"
q.set_callback(self.cb)
if self.verbose:
print "NFQ: creating queue"
q.create_queue(self.queue)
q.set_queue_maxlen(50000)
if self.verbose:
print "NFQ: trying to run"
try:
q.try_run()
except KeyboardInterrupt, e:
print "NFQ: interrupted"
示例7: go
def go(self):
self.q = nfqueue.queue()
self.q.open()
self.q.bind(socket.AF_INET)
self.q.set_callback(self.filter_pkt)
self.q.create_queue(0)
self.q.try_run()
示例8: __init__
def __init__(self, callback, nqueue=0, family=socket.AF_INET, maxlen=5000, map=None):
self.queue = nfqueue.queue()
self.queue.set_callback(callback)
self.queue.fast_open(nqueue, family)
self.queue.set_queue_maxlen(maxlen)
self.fd = self.queue.get_fd()
asyncore.file_dispatcher.__init__(self,self.fd,map)
self.queue.set_mode(nfqueue.NFQNL_COPY_PACKET)
示例9: __init__
def __init__(self):
self.q = nfqueue.queue()
self.q.set_callback(queue_cb)
self.q.fast_open(0, socket.AF_INET)
self.q.set_queue_maxlen(5000)
reactor.addReader(self)
self.q.set_mode(nfqueue.NFQNL_COPY_PACKET)
print '[*] Waiting for data'
示例10: nfq_setup
def nfq_setup(self, queueno):
q = nfqueue.queue()
q.set_callback(self.cb)
try:
q.fast_open(queueno, AF_INET)
except RuntimeError, e:
log.error("cannot bind to nf_queue %d: %s. Already in use or not root?" % (queueno, e))
return False
示例11: __init__
def __init__(self):
self.q = nfqueue.queue()
self.q.set_callback(Parser().start)
self.q.fast_open(0, socket.AF_INET)
self.q.set_queue_maxlen(5000)
reactor.addReader(self)
self.q.set_mode(nfqueue.NFQNL_COPY_PACKET)
print '[*] Flushed firewall and forwarded traffic to the queue; waiting for data'
示例12: __init__
def __init__(self, cb, nqueue=0, family=AF_INET6, maxlen=5000, map=None):
self._q = queue()
self._q.set_callback(cb)
self._q.fast_open(nqueue, family)
self._q.set_queue_maxlen(maxlen)
self.fd = self._q.get_fd()
asyncore.file_dispatcher.__init__(self, self.fd, map)
self._q.set_mode(NFQNL_COPY_PACKET)
示例13: __init__
def __init__(self, args):
self.q = nfqueue.queue()
self.q.set_callback(Parser(args).start)
self.q.fast_open(0, socket.AF_INET)
self.q.set_queue_maxlen(5000)
reactor.addReader(self)
self.q.set_mode(nfqueue.NFQNL_COPY_PACKET)
print '[*] Flushed 防火墙 和转发流量 到队列 ; 等待数据 '
示例14: __init__
def __init__(self):
self.q = nfqueue.queue()
self.q.set_callback(cb)
self.q.fast_open(0, socket.AF_INET)
self.q.set_queue_maxlen(5000)
reactor.addReader(self)
self.q.set_mode(nfqueue.NFQNL_COPY_PACKET)
print '[info] spoofing dns packets'
示例15: setup_nfqueue
def setup_nfqueue(fct, num):
q = nfqueue.queue()
q.open()
q.unbind(socket.AF_INET)
q.bind(socket.AF_INET)
q.set_callback(fct)
q.create_queue(num)
return q