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

Commit

Permalink
Fixed WMI query output formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
byt3bl33d3r committed Nov 15, 2015
1 parent 19ecdf8 commit bff44a5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
6 changes: 1 addition & 5 deletions core/scripts/secretsdump.py
Original file line number Diff line number Diff line change
Expand Up @@ -2058,11 +2058,7 @@ def dump_NTDS(self, method, history, pwdLastSet):
def cleanup(self):
logging.info('Cleaning up... ')
if self.__remoteOps:
try:
self.__remoteOps.finish()
except DCERPCException:
sleep(2)
self.__remoteOps.finish()
self.__remoteOps.finish()
if self.__SAMHashes:
self.__SAMHashes.finish()
if self.__LSASecrets:
Expand Down
21 changes: 9 additions & 12 deletions core/scripts/wmiquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from impacket.dcerpc.v5.dtypes import NULL
from impacket.dcerpc.v5.dcom import wmi
from impacket.dcerpc.v5.dcomrt import DCOMConnection
import core.settings as settings

class WMIQUERY:

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

shell = WMIShell(iWbemServices)
shell = WMIShell(iWbemServices, address)
shell.onecmd(command)

iWbemServices.RemRelease()
dcom.disconnect()

class WMIShell(cmd.Cmd):
def __init__(self, iWbemServices):
def __init__(self, iWbemServices, address):
cmd.Cmd.__init__(self)
self.address = address
self.iWbemServices = iWbemServices

def do_help(self, line):
Expand Down Expand Up @@ -99,16 +101,10 @@ def printReply(self, iEnum):
try:
pEnum = iEnum.Next(0xffffffff,1)[0]
record = pEnum.getProperties()
if printHeader is True:
print '|',
for col in record:
print '%s |' % col,
print
printHeader = False
print '|',
for key in record:
print '%s |' % record[key]['value'],
print
line = []
for rec in record:
line.append('{}: {}'.format(rec, record[rec]['value']))
print_att(' | '.join(line))
except Exception, e:
#import traceback
#print traceback.print_exc()
Expand All @@ -124,6 +120,7 @@ def default(self, line):
line = line[:-1]
try:
iEnumWbemClassObject = self.iWbemServices.ExecQuery(line.strip('\n'))
print_succ('{}:{} Executed specified WMI query:'.format(self.address, settings.args.port))
self.printReply(iEnumWbemClassObject)
iEnumWbemClassObject.RemRelease()
except Exception, e:
Expand Down

0 comments on commit bff44a5

Please sign in to comment.