:py:mod:`dissect.target.helpers.regex.ipaddress` ================================================ .. py:module:: dissect.target.helpers.regex.ipaddress Module Contents --------------- Functions ~~~~~~~~~ .. autoapisummary:: :nosignatures: dissect.target.helpers.regex.ipaddress.extract_ips Attributes ~~~~~~~~~~ .. autoapisummary:: dissect.target.helpers.regex.ipaddress.IPV4_SEG dissect.target.helpers.regex.ipaddress.IPV4_ADDR dissect.target.helpers.regex.ipaddress.IPV6_SEG dissect.target.helpers.regex.ipaddress.IPV6_GROUPS dissect.target.helpers.regex.ipaddress.IPV6_ADDR dissect.target.helpers.regex.ipaddress.IP_REGEX .. py:data:: IPV4_SEG :value: '(?:25[0-5]|2[0-4]\\d|[1]\\d\\d|[1-9]?\\d)' .. py:data:: IPV4_ADDR :value: '(?:(?:25[0-5]|2[0-4]\\d|[1]\\d\\d|[1-9]?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|[1]\\d\\d|[1-9]?\\d)(?:\... .. py:data:: IPV6_SEG :value: '(?:(?:[0-9a-fA-F]){1,4})' .. py:data:: IPV6_GROUPS .. py:data:: IPV6_ADDR :value: '' .. py:data:: IP_REGEX .. py:function:: extract_ips(text: str) -> list[str] Extract IPv4 and IPv6 addresses from an input string. Note: ``910.12.34.569`` matches ``10.12.34.56``, so always check your input! Deliberately does not find octal representations of IP addresses (e.g. ``010.010.010.010``) as this is generally discouraged and introduced ambiguity: the address could be interpreted as ``8.8.8.8`` or ``10.10.10.10``. Most indexing services such as Elasticsearch also do not accept octal representations of IP addresses. .. rubric:: References - https://github.com/GCHQ/CyberChef/blob/main/src/core/operations/ExtractIPAddresses.mjs - https://gist.github.com/dfee/6ed3a4b05cfe7a6faf40a2102408d5d8