scapy.layers.tuntap
Implementation of TUN/TAP interfaces.
These allow Scapy to act as the remote side of a virtual network interface.
- class scapy.layers.tuntap.DarwinUtunIfReq(_pkt, /, *, ctl_id=0, ctl_name=b'com.apple.net.utun_control')[source]
Bases:
PacketStructure for issuing Darwin ioctl commands (
struct ctl_info).See net/if_utun.h and sys/kern_control.h for reference.
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | CTL ID | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | CTL NAME | + + | | + + | | + + | | + + | | + + | | + + | | + + | | + + | | + + | | + + | | + + | | + + | | + + | | + + | | + + | | + + | | + + | | + + | | + + | | + + | | + + | | + + | | + + | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. DarwinUtunIfReqDarwinUtunIfReq fields ctl_id
BitField(32 bits)0ctl_name
b'com.apple.net.utun_control'
- class scapy.layers.tuntap.DarwinUtunPacketInfo(_pkt, /, *, addr_family=AddressFamily.AF_INET)[source]
Bases:
Packet- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ADDR FAMILY | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. DarwinUtunPacketInfoDarwinUtunPacketInfo fields addr_family
<AddressFamily.AF_INET: 2>
- class scapy.layers.tuntap.LinuxTunIfReq(_pkt, /, *, ifrn_name=b'', ifru_flags=0)[source]
Bases:
PacketStructure to request a specific device name for a tun/tap Linux
struct ifreq.See linux/if.h (struct ifreq) and tuntap.txt for reference.
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | IFRN NAME | + + | | + + | | + + | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | IFRU FLAGS | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. LinuxTunIfReqLinuxTunIfReq fields ifrn_name
b''ifru_flags
0
- class scapy.layers.tuntap.LinuxTunPacketInfo(_pkt, /, *, flags=<Flag 0 ()>, type=36864)[source]
Bases:
TunPacketInfoBase for TUN packets.
See linux/if_tun.h (struct tun_pi) for reference.
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | FLAGS | TYPE | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. LinuxTunPacketInfoLinuxTunPacketInfo fields flags
<Flag 0 ()>type
36864
- class scapy.layers.tuntap.TunTapInterface(iface=None, mode_tun=None, default_read_size=65535, strip_packet_info=True, *args, **kwargs)[source]
Bases:
SimpleSocketA socket to act as the host’s peer of a tun / tap interface.
This implements kernel interfaces for tun and tap devices.
- Parameters:
iface – The name of the interface to use, eg: ‘tun0’
mode_tun (bool) – If True, create as TUN interface (layer 3). If False, creates a TAP interface (layer 2). If not supplied, attempts to detect from the
ifacename.strip_packet_info (bool) – If True (default), strips any TunPacketInfo from the packet. If False, leaves it in tact. Some operating systems and tunnel types don’t include this sort of data.
FreeBSD references:
tap(4): https://www.freebsd.org/cgi/man.cgi?query=tap&sektion=4
tun(4): https://www.freebsd.org/cgi/man.cgi?query=tun&sektion=4
Linux references:
- desc = "Act as the host's peer of a tun / tap interface"