Skip to content

Commit ead516a

Browse files
authored
Display created ProcessId using wmiexec.py (fortra#1814)
* drop python2 support in wmiexec.py * display ProcessId to user
1 parent 6315ebd commit ead516a

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

examples/wmiexec.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
from impacket.dcerpc.v5.dcom import wmi
4444
from impacket.dcerpc.v5.dtypes import NULL
4545
from impacket.krb5.keytab import Keytab
46-
from six import PY2
4746

4847
OUTPUT_FILENAME = '__' + str(time.time())
4948
CODEC = sys.stdout.encoding
@@ -226,10 +225,7 @@ def do_cd(self, s):
226225
print(self.__outputBuffer)
227226
self.__outputBuffer = ''
228227
else:
229-
if PY2:
230-
self.__pwd = ntpath.normpath(ntpath.join(self.__pwd, s.decode(sys.stdin.encoding)))
231-
else:
232-
self.__pwd = ntpath.normpath(ntpath.join(self.__pwd, s))
228+
self.__pwd = ntpath.normpath(ntpath.join(self.__pwd, s))
233229
self.execute_remote('cd ')
234230
self.__pwd = self.__outputBuffer.strip('\r\n')
235231
self.prompt = (self.__pwd + '>')
@@ -296,11 +292,11 @@ def execute_remote(self, data, shell_type='cmd'):
296292

297293
if self.__noOutput is False:
298294
command += ' 1> ' + '\\\\127.0.0.1\\%s' % self.__share + self.__output + ' 2>&1'
299-
if PY2:
300-
self.__win32Process.Create(command.decode(sys.stdin.encoding), self.__pwd, None)
295+
response = self.__win32Process.Create(command, self.__pwd, None)
296+
if self.__noOutput is False:
297+
self.get_output()
301298
else:
302-
self.__win32Process.Create(command, self.__pwd, None)
303-
self.get_output()
299+
response.printInformation() # print ProcessId and ReturnValue
304300

305301
def send_data(self, data):
306302
self.execute_remote(data, self.__shell_type)

0 commit comments

Comments
 (0)