Module p4lantir.mitm.mitm_utils
Module content
- p4lantir.mitm.mitm_utils.arp_spoof(logger: Logger, interface: str, ip_addr_1: str, ip_addr_2: str) Popen[source]
Enable ARP Spoofing between IPs ip_addr_1 and ip_addr_2 on the interface interface
- Parameters:
interface (str) – The interface to start the ARP spoofing
ip_addr_1 (str) – The IP to send the ARP spoofing packets
ip_addr_2 (str) – The IP to spoof
- Returns:
The arpspoof process
- Return type:
subprocess.Popen
- p4lantir.mitm.mitm_utils.setup_forwarding(logger: Logger, interface: str, in_port: int, proxy_port: int, ip_forward: bool) None[source]
Enable IP forwarding and port redirection to forward incoming packets to the internal TCP sever
- Parameters:
interface (str) – The interface on which the port redirection will be enabled
in_port (int) – The port from which the TCP flow should arrive
proxy_port (int) – The internal TCP server port
ip_forward (bool) – Enable or not the IP forwarding
- p4lantir.mitm.mitm_utils.get_ip_forwarding_status(logger: Logger) bool[source]
Detect if the IP forwarding is already activated on the computer
- Returns:
True if IP forwarding is enabled, False otherwise
- Return type:
bool
- p4lantir.mitm.mitm_utils.stop_forwarding(logger: Logger, interface: str, in_port: int, proxy_port: int, ip_forward: bool) None[source]
Deactivate IP forwarding if ip_forward is True and stop port redirection.
- Parameters:
interface (str) – The interface on wich disable the port redirection
in_port (int) – The port on which the incoming TCP flow arrive
proxy_port (int) – The internal TCP server port
ip_forward (bool) – Disable or not IP forwarding
- p4lantir.mitm.mitm_utils.get_iface_ip(interface: str) str[source]
Retrieve the interface’s IP from its name.
- Parameters:
interface (str) – the interface name
- Returns:
the interface’s IP
- Return type:
str
- p4lantir.mitm.mitm_utils.get_free_port(logger: Logger, interface_ip: str, start: int = 1025) None | int[source]
Get the first bindable port starting from start.
- Parameters:
logger (logging.Logger) – the logger to display debug information
interface_ip (str) – the IP to bind the port
start (int) – the first port to test if bindable
- Returns:
a bindable port > start
- Return type:
int