forked from p15670423/monkey
Common: Rename "get_local_ip_addresses" to "get_my_ip_addresses"
This commit is contained in:
parent
6bcf44da69
commit
135da9631d
|
@ -5,7 +5,7 @@ from typing import List, Optional, Sequence, Tuple
|
||||||
from netifaces import AF_INET, ifaddresses, interfaces
|
from netifaces import AF_INET, ifaddresses, interfaces
|
||||||
|
|
||||||
|
|
||||||
def get_local_ip_addresses() -> Sequence[str]:
|
def get_my_ip_addresses() -> Sequence[str]:
|
||||||
ip_list = []
|
ip_list = []
|
||||||
for interface in interfaces():
|
for interface in interfaces():
|
||||||
addresses = ifaddresses(interface).get(AF_INET, [])
|
addresses = ifaddresses(interface).get(AF_INET, [])
|
||||||
|
|
|
@ -7,7 +7,7 @@ import requests
|
||||||
from urllib3 import disable_warnings
|
from urllib3 import disable_warnings
|
||||||
|
|
||||||
from common.common_consts.timeouts import LONG_REQUEST_TIMEOUT, MEDIUM_REQUEST_TIMEOUT
|
from common.common_consts.timeouts import LONG_REQUEST_TIMEOUT, MEDIUM_REQUEST_TIMEOUT
|
||||||
from common.network.network_utils import get_local_ip_addresses
|
from common.network.network_utils import get_my_ip_addresses
|
||||||
from infection_monkey.config import GUID
|
from infection_monkey.config import GUID
|
||||||
from infection_monkey.network.info import get_host_subnets
|
from infection_monkey.network.info import get_host_subnets
|
||||||
from infection_monkey.utils import agent_process
|
from infection_monkey.utils import agent_process
|
||||||
|
@ -39,7 +39,7 @@ class ControlClient:
|
||||||
monkey = {
|
monkey = {
|
||||||
"guid": GUID,
|
"guid": GUID,
|
||||||
"hostname": hostname,
|
"hostname": hostname,
|
||||||
"ip_addresses": get_local_ip_addresses(),
|
"ip_addresses": get_my_ip_addresses(),
|
||||||
"networks": get_host_subnets(),
|
"networks": get_host_subnets(),
|
||||||
"description": " ".join(platform.uname()),
|
"description": " ".join(platform.uname()),
|
||||||
"parent": parent,
|
"parent": parent,
|
||||||
|
|
|
@ -18,7 +18,7 @@ from common.events import CredentialsStolenEvent
|
||||||
from common.network.network_utils import (
|
from common.network.network_utils import (
|
||||||
address_to_ip_port,
|
address_to_ip_port,
|
||||||
get_local_interfaces,
|
get_local_interfaces,
|
||||||
get_local_ip_addresses,
|
get_my_ip_addresses,
|
||||||
)
|
)
|
||||||
from common.utils.argparse_types import positive_int
|
from common.utils.argparse_types import positive_int
|
||||||
from common.utils.attack_utils import ScanStatus, UsageEnum
|
from common.utils.attack_utils import ScanStatus, UsageEnum
|
||||||
|
@ -205,7 +205,7 @@ class InfectionMonkey:
|
||||||
self._cmd_island_port,
|
self._cmd_island_port,
|
||||||
client_disconnect_timeout=config.keep_tunnel_open_time,
|
client_disconnect_timeout=config.keep_tunnel_open_time,
|
||||||
)
|
)
|
||||||
relay_servers = [f"{ip}:{relay_port}" for ip in get_local_ip_addresses()]
|
relay_servers = [f"{ip}:{relay_port}" for ip in get_my_ip_addresses()]
|
||||||
|
|
||||||
if not maximum_depth_reached(config.propagation.maximum_depth, self._current_depth):
|
if not maximum_depth_reached(config.propagation.maximum_depth, self._current_depth):
|
||||||
self._relay.start()
|
self._relay.start()
|
||||||
|
|
|
@ -3,12 +3,12 @@ from typing import Sequence
|
||||||
|
|
||||||
from ring import lru
|
from ring import lru
|
||||||
|
|
||||||
from common.network.network_utils import get_local_interfaces, get_local_ip_addresses
|
from common.network.network_utils import get_local_interfaces, get_my_ip_addresses
|
||||||
|
|
||||||
|
|
||||||
@lru(maxsize=1)
|
@lru(maxsize=1)
|
||||||
def get_cached_local_ip_addresses() -> Sequence[IPv4Address]:
|
def get_cached_local_ip_addresses() -> Sequence[IPv4Address]:
|
||||||
return get_local_ip_addresses()
|
return get_my_ip_addresses()
|
||||||
|
|
||||||
|
|
||||||
# The subnets list should not change often. Therefore, we can cache the result and never call this
|
# The subnets list should not change often. Therefore, we can cache the result and never call this
|
||||||
|
|
Loading…
Reference in New Issue