pwnlib.util.net — 网络接口

pwnlib.util.net.getifaddrs() → dict list[源代码]

A wrapper for libc’s getifaddrs.

参数:None
返回: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[源代码]
参数:
  • all (bool) – Whether to include interfaces with not associated address.
  • DefaultFalse.
返回:

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[源代码]

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

参数:
  • all (bool) – Whether to include interfaces with not associated address.
  • DefaultFalse.
返回:

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

pwnlib.util.net.interfaces6(all = False) → dict[源代码]

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

参数:
  • all (bool) – Whether to include interfaces with not associated address.
  • DefaultFalse.
返回:

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

pwnlib.util.net.sockaddr(host, port, network = 'ipv4') -> (data, length, family)[源代码]

Creates a sockaddr_in or sockaddr_in6 memory buffer for use in shellcode.

参数:
  • host (str) – Either an IP address or a hostname to be looked up.
  • port (int) – TCP/UDP port.
  • network (str) – Either ‘ipv4’ or ‘ipv6’.
返回:

A tuple containing the sockaddr buffer, length, and the address family.