From 656a44b4e719b4fa1ac5b3e1ea5398a6e38aa1f1 Mon Sep 17 00:00:00 2001 From: LaserEyess Date: Sun, 28 Jul 2024 12:54:52 -0400 Subject: [PATCH] Fix IP address printing This commit will check if we have an ipv6 vs ipv4 and print out the address formatted correctly. This includes handling ipv4 embedded ipv6 addresses. --- tarpyt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tarpyt b/tarpyt index 3d0d3a5..53ef5b5 100755 --- a/tarpyt +++ b/tarpyt @@ -25,6 +25,7 @@ from argparse import ArgumentParser, Namespace import asyncio import ctypes import enum +import ipaddress as ip import logging from logging.handlers import SysLogHandler import random @@ -88,7 +89,11 @@ class Handler(): if host is None: raise ValueError("what the fuck?") - hostname = host[0] + hostname = ip.ip_address(host[0]) + + # check if we got an embedded ipv4 + if (hostname.version) == 6 and (addr := hostname.ipv4_mapped): + hostname = addr try: self.counter += 1