Merge pull request #475 from VakarisZ/py3_logging_improvements
Py3 logging improvements
This commit is contained in:
commit
7de03d8db0
|
@ -23,7 +23,6 @@ class BasicTest(object):
|
||||||
self.log_handler = log_handler
|
self.log_handler = log_handler
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
LOGGER.info("Uploading configuration:\n{}".format(json.dumps(self.config_parser.config_json, indent=2)))
|
|
||||||
self.island_client.import_config(self.config_parser.config_raw)
|
self.island_client.import_config(self.config_parser.config_raw)
|
||||||
self.print_test_starting_info()
|
self.print_test_starting_info()
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -47,8 +47,10 @@ class HostExploiter(object, metaclass=ABCMeta):
|
||||||
|
|
||||||
def exploit_host(self):
|
def exploit_host(self):
|
||||||
self.pre_exploit()
|
self.pre_exploit()
|
||||||
result = self._exploit_host()
|
try:
|
||||||
self.post_exploit()
|
result = self._exploit_host()
|
||||||
|
finally:
|
||||||
|
self.post_exploit()
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def pre_exploit(self):
|
def pre_exploit(self):
|
||||||
|
|
|
@ -11,7 +11,7 @@ from infection_monkey.exploit.tools.http_tools import MonkeyHTTPServer
|
||||||
from infection_monkey.exploit.tools.helpers import get_monkey_dest_path, build_monkey_commandline, get_monkey_depth
|
from infection_monkey.exploit.tools.helpers import get_monkey_dest_path, build_monkey_commandline, get_monkey_depth
|
||||||
from infection_monkey.model import DROPPER_ARG
|
from infection_monkey.model import DROPPER_ARG
|
||||||
from infection_monkey.exploit.tools.payload_parsing import LimitedSizePayload
|
from infection_monkey.exploit.tools.payload_parsing import LimitedSizePayload
|
||||||
from infection_monkey.exploit.tools.exceptions import ExploitingVulnerableMachineError
|
from infection_monkey.exploit.tools.exceptions import ExploitingVulnerableMachineError, FailedExploitationError
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ class MSSQLExploiter(HostExploiter):
|
||||||
|
|
||||||
LOG.warning('No user/password combo was able to connect to host: {0}:{1}, '
|
LOG.warning('No user/password combo was able to connect to host: {0}:{1}, '
|
||||||
'aborting brute force'.format(host, port))
|
'aborting brute force'.format(host, port))
|
||||||
raise RuntimeError("Bruteforce process failed on host: {0}".format(self.host.ip_addr))
|
raise FailedExploitationError("Bruteforce process failed on host: {0}".format(self.host.ip_addr))
|
||||||
|
|
||||||
|
|
||||||
class MSSQLLimitedSizePayload(LimitedSizePayload):
|
class MSSQLLimitedSizePayload(LimitedSizePayload):
|
||||||
|
|
|
@ -26,7 +26,7 @@ from infection_monkey.telemetry.tunnel_telem import TunnelTelem
|
||||||
from infection_monkey.windows_upgrader import WindowsUpgrader
|
from infection_monkey.windows_upgrader import WindowsUpgrader
|
||||||
from infection_monkey.post_breach.post_breach_handler import PostBreach
|
from infection_monkey.post_breach.post_breach_handler import PostBreach
|
||||||
from infection_monkey.exploit.tools.helpers import get_interface_to_target
|
from infection_monkey.exploit.tools.helpers import get_interface_to_target
|
||||||
from infection_monkey.exploit.tools.exceptions import ExploitingVulnerableMachineError
|
from infection_monkey.exploit.tools.exceptions import ExploitingVulnerableMachineError, FailedExploitationError
|
||||||
from infection_monkey.telemetry.attack.t1106_telem import T1106Telem
|
from infection_monkey.telemetry.attack.t1106_telem import T1106Telem
|
||||||
from common.utils.attack_utils import ScanStatus, UsageEnum
|
from common.utils.attack_utils import ScanStatus, UsageEnum
|
||||||
|
|
||||||
|
@ -192,7 +192,9 @@ class InfectionMonkey(object):
|
||||||
self._exploiters = sorted(self._exploiters, key=lambda exploiter_: exploiter_.EXPLOIT_TYPE.value)
|
self._exploiters = sorted(self._exploiters, key=lambda exploiter_: exploiter_.EXPLOIT_TYPE.value)
|
||||||
host_exploited = False
|
host_exploited = False
|
||||||
for exploiter in [exploiter(machine) for exploiter in self._exploiters]:
|
for exploiter in [exploiter(machine) for exploiter in self._exploiters]:
|
||||||
|
|
||||||
if self.try_exploiting(machine, exploiter):
|
if self.try_exploiting(machine, exploiter):
|
||||||
|
|
||||||
host_exploited = True
|
host_exploited = True
|
||||||
VictimHostTelem('T1210', ScanStatus.USED, machine=machine).send()
|
VictimHostTelem('T1210', ScanStatus.USED, machine=machine).send()
|
||||||
break
|
break
|
||||||
|
@ -311,6 +313,8 @@ class InfectionMonkey(object):
|
||||||
machine, exploiter.__class__.__name__, exc)
|
machine, exploiter.__class__.__name__, exc)
|
||||||
self.successfully_exploited(machine, exploiter)
|
self.successfully_exploited(machine, exploiter)
|
||||||
return True
|
return True
|
||||||
|
except FailedExploitationError as e:
|
||||||
|
LOG.info("Failed exploiting %r with exploiter %s, %s", machine, exploiter.__class__.__name__, e)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
LOG.exception("Exception while attacking %s using %s: %s",
|
LOG.exception("Exception while attacking %s using %s: %s",
|
||||||
machine, exploiter.__class__.__name__, exc)
|
machine, exploiter.__class__.__name__, exc)
|
||||||
|
|
Loading…
Reference in New Issue