forked from p15670423/monkey
Agent: Refactor puppet and tools to use CONNECTION_TIMEOUT
This commit is contained in:
parent
1ec5be908d
commit
299a261387
|
@ -1,3 +1,4 @@
|
||||||
SHORT_REQUEST_TIMEOUT = 2.5 # Seconds. Use where we expect timeout.
|
SHORT_REQUEST_TIMEOUT = 2.5 # Seconds. Use where we expect timeout and for small data transactions.
|
||||||
MEDIUM_REQUEST_TIMEOUT = 5 # Seconds. Use where we don't expect timeout.
|
MEDIUM_REQUEST_TIMEOUT = 5 # Seconds. Use where we don't expect timeout.
|
||||||
LONG_REQUEST_TIMEOUT = 15 # Seconds. Use where we don't expect timeout and operate heavy data.
|
LONG_REQUEST_TIMEOUT = 15 # Seconds. Use where we don't expect timeout and operate heavy data.
|
||||||
|
CONNECTION_TIMEOUT = 3 # Seconds. Use for TCP, SSH and other connections that shouldn't take long.
|
||||||
|
|
|
@ -4,9 +4,10 @@ import socket
|
||||||
import struct
|
import struct
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from common.common_consts.timeouts import CONNECTION_TIMEOUT
|
||||||
from infection_monkey.network.info import get_routes
|
from infection_monkey.network.info import get_routes
|
||||||
|
|
||||||
DEFAULT_TIMEOUT = 10
|
DEFAULT_TIMEOUT = CONNECTION_TIMEOUT
|
||||||
BANNER_READ = 1024
|
BANNER_READ = 1024
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
|
@ -2,6 +2,7 @@ import logging
|
||||||
import threading
|
import threading
|
||||||
from typing import Dict, List, Sequence
|
from typing import Dict, List, Sequence
|
||||||
|
|
||||||
|
from common.common_consts.timeouts import CONNECTION_TIMEOUT
|
||||||
from infection_monkey import network_scanning
|
from infection_monkey import network_scanning
|
||||||
from infection_monkey.i_puppet import (
|
from infection_monkey.i_puppet import (
|
||||||
Credentials,
|
Credentials,
|
||||||
|
@ -38,11 +39,11 @@ class Puppet(IPuppet):
|
||||||
def run_pba(self, name: str, options: Dict) -> PostBreachData:
|
def run_pba(self, name: str, options: Dict) -> PostBreachData:
|
||||||
return self._mock_puppet.run_pba(name, options)
|
return self._mock_puppet.run_pba(name, options)
|
||||||
|
|
||||||
def ping(self, host: str, timeout: float = 1) -> PingScanData:
|
def ping(self, host: str, timeout: float = CONNECTION_TIMEOUT) -> PingScanData:
|
||||||
return network_scanning.ping(host, timeout)
|
return network_scanning.ping(host, timeout)
|
||||||
|
|
||||||
def scan_tcp_ports(
|
def scan_tcp_ports(
|
||||||
self, host: str, ports: List[int], timeout: float = 3
|
self, host: str, ports: List[int], timeout: float = CONNECTION_TIMEOUT
|
||||||
) -> Dict[int, PortScanData]:
|
) -> Dict[int, PortScanData]:
|
||||||
return network_scanning.scan_tcp_ports(host, ports, timeout)
|
return network_scanning.scan_tcp_ports(host, ports, timeout)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue