From b42ff98f9f987ac5d7308c778595a37147a9aca4 Mon Sep 17 00:00:00 2001 From: VakarisZ Date: Mon, 12 Nov 2018 16:17:12 +0200 Subject: [PATCH] Converts utf to ascii and fixes the problem of rdp grinder not being able to handle utf encoded credentials --- monkey/infection_monkey/exploit/rdpgrinder.py | 5 +++++ monkey/infection_monkey/utils.py | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/monkey/infection_monkey/exploit/rdpgrinder.py b/monkey/infection_monkey/exploit/rdpgrinder.py index 3873a8ce3..a67a812f6 100644 --- a/monkey/infection_monkey/exploit/rdpgrinder.py +++ b/monkey/infection_monkey/exploit/rdpgrinder.py @@ -15,6 +15,7 @@ from infection_monkey.exploit.tools import get_target_monkey from infection_monkey.model import RDP_CMDLINE_HTTP_BITS, RDP_CMDLINE_HTTP_VBS from infection_monkey.network.tools import check_tcp_port from infection_monkey.exploit.tools import build_monkey_commandline +from infection_monkey.utils import utf_to_ascii __author__ = 'hoffer' @@ -298,6 +299,10 @@ class RdpExploiter(HostExploiter): LOG.info("RDP connected to %r", self.host) + user = utf_to_ascii(user) + password = utf_to_ascii(password) + command = utf_to_ascii(command) + client_factory = CMDClientFactory(user, password, "", command) reactor.callFromThread(reactor.connectTCP, self.host.ip_addr, RDP_PORT, client_factory) diff --git a/monkey/infection_monkey/utils.py b/monkey/infection_monkey/utils.py index 3f04ed9fb..d138f85ed 100644 --- a/monkey/infection_monkey/utils.py +++ b/monkey/infection_monkey/utils.py @@ -30,3 +30,7 @@ def is_64bit_python(): def is_windows_os(): return sys.platform.startswith("win") + +def utf_to_ascii(string): + udata = string.decode("utf-8") + return udata.encode("ascii", "ignore") \ No newline at end of file