Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>you can use a tun/tap device, can simply read it from python, for example:</p> <p>tunnel.py</p> <pre><code>import os from fcntl import ioctl from select import select import struct import subprocess TUNSETIFF = 0x400454ca TUNMODE = 0x0001 tunFile = os.open("/dev/net/tun", os.O_RDWR) ifs = ioctl(f, TUNSETIFF, struct.pack("16sH", "tun%d", TUNMODE)) ifname = ifs[:16].strip("\x00") print "Allocated interface %s. Configure it and use it" % ifname subprocess.call("ifconfig %s 192.168.13.1" % ifname,shell=True) # Reading def read(): r = select([tunFile], [], [])[0][0] if r == tunFile: return os.read(tunFile, 1600) return None # Writing def write(buf): os.write(tunFile, buf) </code></pre> <p>the full example can be found <a href="http://www.secdev.org/projects/tuntap_udp/" rel="nofollow">here</a></p> <p>and route your packets to interface "tun0" or printed inetrface name.</p> <p>linux distributions does not require to install anything but if you are on windows use <a href="http://www.varsanofiev.com/inside/using_tuntap_under_windows.htm" rel="nofollow">this</a>, and for mac os use <a href="http://tuntaposx.sourceforge.net/" rel="nofollow">this</a></p> <p>EDIT 1 Note from <a href="http://backreference.org/2010/03/26/tuntap-interface-tutorial/" rel="nofollow">here</a>:</p> <blockquote> <p>The difference between a tap interface and a tun interface is that a tap interface outputs (and must be given) full ethernet frames, while a tun interface outputs (and must be given) raw IP packets (and no ethernet headers are added by the kernel). Whether an interface functions like a tun interface or like a tap interface is specified with a flag when the interface is created.</p> </blockquote> <p>for finding packet header information(like src, dst &amp; etc ...) you may use <a href="http://code.google.com/p/dpkt/" rel="nofollow">dpkt</a></p> <pre><code>from dpkt import ip from tunnel import read,write # tunnel.py while 1: data = read() if data: ipObj = ip.IP(data[4:]) print ipObj.src, ipObj.dst </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload