diff --git a/examples/wmiexec.py b/examples/wmiexec.py index 52411b55da..0fb30137cf 100755 --- a/examples/wmiexec.py +++ b/examples/wmiexec.py @@ -43,7 +43,6 @@ from impacket.dcerpc.v5.dcom import wmi from impacket.dcerpc.v5.dtypes import NULL from impacket.krb5.keytab import Keytab -from six import PY2 OUTPUT_FILENAME = '__' + str(time.time()) CODEC = sys.stdout.encoding @@ -226,10 +225,7 @@ def do_cd(self, s): print(self.__outputBuffer) self.__outputBuffer = '' else: - if PY2: - self.__pwd = ntpath.normpath(ntpath.join(self.__pwd, s.decode(sys.stdin.encoding))) - else: - self.__pwd = ntpath.normpath(ntpath.join(self.__pwd, s)) + self.__pwd = ntpath.normpath(ntpath.join(self.__pwd, s)) self.execute_remote('cd ') self.__pwd = self.__outputBuffer.strip('\r\n') self.prompt = (self.__pwd + '>') @@ -296,11 +292,11 @@ def execute_remote(self, data, shell_type='cmd'): if self.__noOutput is False: command += ' 1> ' + '\\\\127.0.0.1\\%s' % self.__share + self.__output + ' 2>&1' - if PY2: - self.__win32Process.Create(command.decode(sys.stdin.encoding), self.__pwd, None) + response = self.__win32Process.Create(command, self.__pwd, None) + if self.__noOutput is False: + self.get_output() else: - self.__win32Process.Create(command, self.__pwd, None) - self.get_output() + response.printInformation() # print ProcessId and ReturnValue def send_data(self, data): self.execute_remote(data, self.__shell_type)