pythonoutputscapy

Capturing Scapy function show_interfaces() output in Python


i find this link

Capturing Scapy function output in Python

but this help not for me..

show_interfaces() is good working in cmd.

but it is not working in console..

i want to get output string show_interfaces():

from scapy.arch.windows import show_interfaces
show_interfaces()

Solution

  • You can look in the source code of Scapy, and you will find the show_interfaces function.

    def show_interfaces(resolve_mac=True):
        """Print list of available network interfaces"""
        return IFACES.show(resolve_mac)
    

    To get a python dict with the information about the interfaces. I used

    IFACES.data
    

    From here you can convert it to string if you want to.