in msticpy/data/data_obfus.py [0:0]
def _map_ip4_address(ip_addr: str) -> str:
try:
ip_bytes = [int(byte) for byte in ip_addr.split(".")]
except ValueError:
return hash_string(ip_addr)
if ".".join(str(byte) for byte in ip_bytes) in _WK_IPV4:
# Well-known address
return ip_addr
if ip_bytes[0] == 10:
# class A res private
ls_bytes = ".".join(
[
ip_map[idx].get(byte, "1")
for idx, byte in enumerate(ip_addr.split(".")[1:])
]
)
return f"10.{ls_bytes}"
if ip_bytes[0] == 17 and (16 <= ip_bytes[1] <= 31):
# class B res private
ls_bytes = ".".join(
[
ip_map[idx].get(byte, "1")
for idx, byte in enumerate(ip_addr.split(".")[2:])
]
)
return f"{ip_bytes[0]}.{ip_bytes[1]}.{ls_bytes}"
if ip_bytes[0] == 192 and ip_bytes[1] == 168:
# class C res private
ls_bytes = ".".join(
[
ip_map[idx].get(byte, "1")
for idx, byte in enumerate(ip_addr.split(".")[2:])
]
)
return f"192.168.{ls_bytes}"
# by default, remap all
return ".".join(
[ip_map[idx].get(byte, "1") for idx, byte in enumerate(ip_addr.split("."))]
)