Created
February 3, 2022 01:32
-
-
Save shriphani/f98c212e0f4eb8d63ce3059a28509441 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import fcntl | |
import struct | |
import os | |
import requests | |
from scapy.all import * | |
TUNSETIFF = 0x400454ca | |
TUNSETOWNER = TUNSETIFF + 2 | |
IFF_TAP = 0x0002 | |
IFACE = 'tap1' | |
tun = open('/dev/net/tun', 'r+b', buffering=0) | |
ifr = struct.pack('16sH', bytes(IFACE, 'utf-8'), IFF_TAP) | |
fcntl.ioctl(tun, TUNSETIFF, ifr) | |
fcntl.ioctl(tun, TUNSETOWNER, 1000) | |
while True: | |
packet = os.read(tun.fileno(), 2048) | |
frame = Ether(packet) | |
frame.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment