pwnlib.util.net
— Networking interfaces
- pwnlib.util.net.getifaddrs() dict list [source]
A wrapper for libc’s
getifaddrs
.- Parameters
None –
- 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
orsocket.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.
Default –
False
.
- 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 eithersocket.AF_INET
orsocket.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.
Default –
False
.
- Returns
A dictionary mapping each of the hosts interfaces to a list of it’s IPv4 addresses.
Examples
>>> interfaces4(all=True) {...'127.0.0.1'...}
- 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.
Default –
False
.
- Returns
A dictionary mapping each of the hosts interfaces to a list of it’s IPv6 addresses.
Examples
>>> interfaces6() {...'::1'...}