From e10efcec7d79b855bb57e2a82622a3d286a78b72 Mon Sep 17 00:00:00 2001 From: Thus0 Date: Fri, 28 Jan 2022 22:26:10 +0100 Subject: [PATCH] change bpf filter "ip proto UDP" to "ip proto 17" tested in docker container with alpine:latest image --- src/proxy.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/proxy.py b/src/proxy.py index ae939d2..0cb4cb9 100644 --- a/src/proxy.py +++ b/src/proxy.py @@ -26,7 +26,7 @@ def _sniff_in_from_client(self, src_ip, dst_ip, dst_port, interf, interf_mac, ne self._logger.debug("Created a new sniffer to sniff incoming client packets. Process id: " f"{os.getpid()}, Parent id: {os.getppid()}") while True: - sniff(filter=f"ip proto UDP and not ether src {interf_mac} and ip dst host {dst_ip} and" + sniff(filter=f"ip proto 17 and not ether src {interf_mac} and ip dst host {dst_ip} and" f" ip src host {src_ip} and ((dst port {dst_port}) or (((ip[6:2] > 0) or " "(ip[7] > 0)) and (not ip[6] = 64)))", iface=interf, @@ -39,7 +39,7 @@ def _sniff_out_to_client(self, src_ip, src_port, interf, new_src_ip, new_src_por self._logger.debug("Created a new sniffer to sniff outgoing client packets. Process id: " f"{os.getpid()}, Parent id: {os.getppid()}") while True: - sniff(filter=f"ip proto UDP and ip src host {src_ip} and src port {src_port}", + sniff(filter=f"ip proto 17 and ip src host {src_ip} and src port {src_port}", iface=interf, prn=func(new_src_ip, new_src_port, new_dst_ip, new_dst_port)) @@ -49,7 +49,7 @@ def _sniff_in_from_server(self, src_ip, src_port, dst_ip, interf, interf_mac, ne self._logger.debug("Created a new sniffer to sniff incoming server packets. Process id: " f"{os.getpid()}, Parent id: {os.getppid()}") while True: - sniff(filter=f"ip proto UDP and not ether src {interf_mac} and ip dst host {dst_ip} and" + sniff(filter=f"ip proto 17 and not ether src {interf_mac} and ip dst host {dst_ip} and" f" ip src host {src_ip} and ((src port {src_port}) or (((ip[6:2] > 0) or " "(ip[7] > 0)) and (not ip[6] = 64)))", iface=interf, @@ -62,7 +62,7 @@ def _sniff_out_to_server(self, src_ip, dst_port, interf, new_src_ip, new_src_por self._logger.debug("Created a new sniffer to sniff outgoing server packets. Process id: " f"{os.getpid()}, Parent id: {os.getppid()}") while True: - sniff(filter=f"ip proto UDP and ip src host {src_ip} and dst port {dst_port}", + sniff(filter=f"ip proto 17 and ip src host {src_ip} and dst port {dst_port}", iface=interf, prn=func(new_src_ip, new_src_port, new_dst_ip, new_dst_port))