Skip to content

Instantly share code, notes, and snippets.

@fqrouter
Last active December 11, 2015 05:58
Show Gist options
  • Select an option

  • Save fqrouter/4556032 to your computer and use it in GitHub Desktop.

Select an option

Save fqrouter/4556032 to your computer and use it in GitHub Desktop.
it is not working, is internet support ip options at all? http://www.eecs.berkeley.edu/Pubs/TechRpts/2005/EECS-2005-24.pdf
from netfilterqueue import NetfilterQueue
import traceback
import subprocess
import signal
import dpkt
import socket
raw_socket = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.htons(3))
raw_socket.setsockopt(socket.SOL_SOCKET, socket.SO_SNDBUF, 2**30)
def split_ip_packet_to_overlapped_fragments(nfqueue_element):
try:
ip_packet = dpkt.ip.IP(nfqueue_element.get_payload())
ip_packet.hl = 6
ip_packet.opts = '\x01\x00\x00\x00'
ip_packet.sum = 0
ip_packet.len = len(ip_packet)
raw_socket.sendto(str(ip_packet), ('pppoe-wan', 2048))
nfqueue_element.drop()
except:
traceback.print_exc()
nfqueue_element.accept()
nfqueue = NetfilterQueue()
nfqueue.bind(0, split_ip_packet_to_overlapped_fragments)
def clean_up(*args):
subprocess.call('iptables -D OUTPUT -m owner --uid-owner stowaway -j QUEUE', shell=True)
signal.signal(signal.SIGINT, clean_up)
try:
subprocess.call('iptables -I OUTPUT -m owner --uid-owner stowaway -j QUEUE', shell=True)
print('running..')
nfqueue.run()
except KeyboardInterrupt:
print('bye')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment