Python Sockets: Enabling Promiscuous Mode in Linux

前端 未结 2 1278
轮回少年
轮回少年 2020-12-13 16:07

We know that Python Allows enabling promiscuous mode under Windows through

s.ioctl(socket.SIO_RCVALL, socket.RCVALL_ON)

However, The RCVAL

2条回答
  •  一整个雨季
    2020-12-13 16:30

    There is another way I thought of. Maybe not as elegant but seems to work fine.

    In linux (with root permissions), one can use :

    # ifconfig eth0 promisc
    # ifconfig eth0 -promisc
    

    To enable/ disable promisc mode on your interface (eth0 in this case).

    So, in python (with root permissions) one could use :

    import os
    ret =  os.system("ifconfig eth0 promisc")
    if ret == 0:
         
    

    Comments are welcome on this way of doing it.

提交回复
热议问题