There is code that works great for python 2 here: https://gist.github.com/glacjay/585369, but running that same code on python3 (3.4 and 3.5 tested) the open call fails with:
tun = open('/dev/net/tun', 'r+b')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
io.UnsupportedOperation: File or stream is not seekable.
I found suggestions to add buffering=0 to the open call. The open call succeeded when I did that, but when I tried to read the tap device I got nothing.
I'm using a similar code to implement TUN/TAP interfaces support in Scapy, and for what it's worth, using buffering=0 worked fine in this case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With