Last active
February 21, 2020 19:41
-
-
Save byt3bl33d3r/4d7a803c69d6491ce641 to your computer and use it in GitHub Desktop.
Simple packet manipulation with fqrouter's fork of python-netfilterqueue (https://github.com/fqrouter/python-netfilterqueue)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python2.7 | |
from scapy.all import * | |
from netfilterqueue import NetfilterQueue | |
def modify(packet): | |
pkt = IP(packet.get_payload()) #converts the raw packet to a scapy compatible string | |
#modify the packet all you want here | |
packet.set_payload(str(pkt)) #set the packet content to our modified version | |
packet.accept() #accept the packet | |
nfqueue = NetfilterQueue() | |
#1 is the iptabels rule queue number, modify is the callback function | |
nfqueue.bind(1, modify) | |
try: | |
print "[*] waiting for data" | |
nfqueue.run() | |
except KeyboardInterrupt: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment