Skip to content
This repository was archived by the owner on Dec 6, 2023. It is now read-only.

Commit bff44a5

Browse files
author
byt3bl33d3r
committed
Fixed WMI query output formatting
1 parent 19ecdf8 commit bff44a5

File tree

2 files changed

+10
-17
lines changed

2 files changed

+10
-17
lines changed

core/scripts/secretsdump.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2058,11 +2058,7 @@ def dump_NTDS(self, method, history, pwdLastSet):
20582058
def cleanup(self):
20592059
logging.info('Cleaning up... ')
20602060
if self.__remoteOps:
2061-
try:
2062-
self.__remoteOps.finish()
2063-
except DCERPCException:
2064-
sleep(2)
2065-
self.__remoteOps.finish()
2061+
self.__remoteOps.finish()
20662062
if self.__SAMHashes:
20672063
self.__SAMHashes.finish()
20682064
if self.__LSASecrets:

core/scripts/wmiquery.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from impacket.dcerpc.v5.dtypes import NULL
2828
from impacket.dcerpc.v5.dcom import wmi
2929
from impacket.dcerpc.v5.dcomrt import DCOMConnection
30+
import core.settings as settings
3031

3132
class WMIQUERY:
3233

@@ -52,15 +53,16 @@ def run(self, command, address, namespace):
5253
iWbemServices= iWbemLevel1Login.NTLMLogin(namespace, NULL, NULL)
5354
iWbemLevel1Login.RemRelease()
5455

55-
shell = WMIShell(iWbemServices)
56+
shell = WMIShell(iWbemServices, address)
5657
shell.onecmd(command)
5758

5859
iWbemServices.RemRelease()
5960
dcom.disconnect()
6061

6162
class WMIShell(cmd.Cmd):
62-
def __init__(self, iWbemServices):
63+
def __init__(self, iWbemServices, address):
6364
cmd.Cmd.__init__(self)
65+
self.address = address
6466
self.iWbemServices = iWbemServices
6567

6668
def do_help(self, line):
@@ -99,16 +101,10 @@ def printReply(self, iEnum):
99101
try:
100102
pEnum = iEnum.Next(0xffffffff,1)[0]
101103
record = pEnum.getProperties()
102-
if printHeader is True:
103-
print '|',
104-
for col in record:
105-
print '%s |' % col,
106-
print
107-
printHeader = False
108-
print '|',
109-
for key in record:
110-
print '%s |' % record[key]['value'],
111-
print
104+
line = []
105+
for rec in record:
106+
line.append('{}: {}'.format(rec, record[rec]['value']))
107+
print_att(' | '.join(line))
112108
except Exception, e:
113109
#import traceback
114110
#print traceback.print_exc()
@@ -124,6 +120,7 @@ def default(self, line):
124120
line = line[:-1]
125121
try:
126122
iEnumWbemClassObject = self.iWbemServices.ExecQuery(line.strip('\n'))
123+
print_succ('{}:{} Executed specified WMI query:'.format(self.address, settings.args.port))
127124
self.printReply(iEnumWbemClassObject)
128125
iEnumWbemClassObject.RemRelease()
129126
except Exception, e:

0 commit comments

Comments
 (0)