Agent: Remove disused list_object() function

This commit is contained in:
Mike Salvatore 2022-03-25 07:57:01 -04:00
parent 344530281a
commit f3773ddbaa
1 changed files with 0 additions and 45 deletions

View File

@ -3,7 +3,6 @@ import threading
from functools import wraps
from impacket.dcerpc.v5.dcom import wmi
from impacket.dcerpc.v5.dcom.wmi import DCERPCSessionError
from impacket.dcerpc.v5.dcomrt import DCOMConnection
from impacket.dcerpc.v5.dtypes import NULL
@ -129,47 +128,3 @@ class WmiTools(object):
assert wmi_connection.connected, "WmiConnection isn't connected"
return wmi_connection._iWbemServices.GetObject(object_name)[0]
@staticmethod
def list_object(wmi_connection, object_name, fields=None, where=None):
assert isinstance(wmi_connection, WmiTools.WmiConnection)
assert wmi_connection.connected, "WmiConnection isn't connected"
if fields:
fields_query = ",".join(fields)
else:
fields_query = "*"
wql_query = "SELECT %s FROM %s" % (fields_query, object_name)
if where:
wql_query += " WHERE %s" % (where,)
logger.debug("Execution WQL query: %r", wql_query)
iEnumWbemClassObject = wmi_connection._iWbemServices.ExecQuery(wql_query)
query = []
try:
while True:
try:
next_item = iEnumWbemClassObject.Next(0xFFFFFFFF, 1)[0]
record = next_item.getProperties()
if not fields:
fields = list(record.keys())
query_record = {}
for key in fields:
query_record[key] = record[key]["value"]
query.append(query_record)
except DCERPCSessionError as exc:
if 1 == exc.error_code:
break
raise
finally:
iEnumWbemClassObject.RemRelease()
return query