scapy.data

Global variables and functions for handling external data sets.

This module lazily loads the following files or their platform equivalents:

  • /etc/protocols: IP protocol names (IP_PROTOS).

  • /etc/services: TCP, UDP, and SCTP service names (TCP_SERVICES, UDP_SERVICES, and SCTP_SERVICES).

  • /etc/ethertypes: Ethernet protocol names (ETHER_TYPES).

  • Wireshark’s share/wireshark/manuf: MAC manufacturers (MANUFDB).

EtherTypes and manufacturers fall back to copies bundled with Scapy. Bluetooth company identifiers (BLUETOOTH_CORE_COMPANY_IDENTIFIERS) are also loaded lazily from bundled data. EtherTypes, services, manufacturers, and Bluetooth identifiers use an on-disk pickle cache when available.

class scapy.data.EtherDA(_name: str = 'DADict', lazy_load: Callable[[], DADict[_K, _V] | Dict[_K, _V]] | None = None, **kargs: Any)[source]

Bases: DADict[int, str]

class scapy.data.KnowledgeBase(filename: Any | None)[source]

Bases: object

get_base() → str | List[Tuple[str, Dict[str, Dict[str, str]]]][source]
lazy_init() → None[source]
reload(filename: Any | None = None) → None[source]
class scapy.data.ManufDA(_name: str = 'DADict', lazy_load: Callable[[], DADict[_K, _V] | Dict[_K, _V]] | None = None, **kargs: Any)[source]

Bases: DADict[str, Tuple[str, str]]

ident(v: Any) → str[source]
lookup(mac: str) → Tuple[str, str][source]

Find OUI name matching to a MAC

reverse_lookup(name: str, case_sensitive: bool = False) → Dict[str, str][source]

Find all MACs registered to a OUI

Parameters:
  • name – the OUI name

  • case_sensitive – default to False

Returns:

a dict of mac:tuples (Name, Extended Name)

scapy.data.load_bluetoothids(filename: str | None = None) → DADict[int, str][source]

Load Bluetooth company IDs and return values as a dictionary.

scapy.data.load_ethertypes(filename: str | None = None) → EtherDA[source]

Load EtherTypes from a file or the copy bundled with Scapy.

scapy.data.load_manuf(filename: str | None = None) → ManufDA[source]

Load Wireshark manufacturer names and return values as a dictionary.

scapy.data.load_protocols(filename: str | None = None, _fallback: Callable[[], Iterator[str]] | None = None, _integer_base: int = 10, _cls: type = scapy.dadict.DADict[int, str]) → DADict[int, str][source]

Parse /etc/protocols and return values as a dictionary.

scapy.data.load_services(filename: str | None = None) → Tuple[DADict[int, str], DADict[int, str], DADict[int, str]][source]

Parse /etc/services and return TCP, UDP, and SCTP dictionaries.

scapy.data.scapy_data_cache(name: str) → Callable[[DecoratorCallable], DecoratorCallable][source]

This decorator caches the loading of ‘data’ dictionaries, in order to reduce loading times.

scapy.data.select_path(directories: List[str], filename: str) → str | None[source]

Find filename among several directories