pwnlib.util.net — Networking interfaces

pwnlib.util.net.getifaddrs() → dict list[source]

A wrapper for libc’s getifaddrs.

Returns:list of dictionaries each representing a struct ifaddrs. The dictionaries have the fields name, flags, family, addr and netmask. Refer to getifaddrs(3) for details. The fields addr and netmask are themselves dictionaries. Their structure depend on family. If family is not socket.AF_INET or socket.AF_INET6 they will be empty.
pwnlib.util.net.interfaces(all = False) → dict[source]
Parameters:
  • all (bool) – Whether to include interfaces with not associated address.
  • DefaultFalse.
Returns:

A dictionary mapping each of the hosts interfaces to a list of it’s addresses. Each entry in the list is a tuple (family, addr), and family is either socket.AF_INET or socket.AF_INET6.

pwnlib.util.net.interfaces4(all = False) → dict[source]

As interfaces() but only includes IPv4 addresses and the lists in the dictionary only contains the addresses not the family.

Parameters:
  • all (bool) – Whether to include interfaces with not associated address.
  • DefaultFalse.
Returns:

A dictionary mapping each of the hosts interfaces to a list of it’s IPv4 addresses.

pwnlib.util.net.interfaces6(all = False) → dict[source]

As interfaces() but only includes IPv6 addresses and the lists in the dictionary only contains the addresses not the family.

Parameters:
  • all (bool) – Whether to include interfaces with not associated address.
  • DefaultFalse.
Returns:

A dictionary mapping each of the hosts interfaces to a list of it’s IPv6 addresses.