From de289b467b2e30ca6a64dfe52782d5f0843d99e7 Mon Sep 17 00:00:00 2001 From: gabrielg5 Date: Thu, 28 Nov 2024 06:51:58 -0500 Subject: [PATCH 1/2] Checking for 'value' != None before creating IWbemClass properties --- impacket/dcerpc/v5/dcom/wmi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/impacket/dcerpc/v5/dcom/wmi.py b/impacket/dcerpc/v5/dcom/wmi.py index 79a1fb1afc..3f24facf1f 100644 --- a/impacket/dcerpc/v5/dcom/wmi.py +++ b/impacket/dcerpc/v5/dcom/wmi.py @@ -2613,7 +2613,7 @@ def SpawnInstance(self): def createProperties(self, properties): for property in properties: # Do we have an object property? - if properties[property]['type'] == CIM_TYPE_ENUM.CIM_TYPE_OBJECT.value: + if properties[property]['type'] == CIM_TYPE_ENUM.CIM_TYPE_OBJECT.value and properties[property]['value'] != None: # Yes.. let's create an Object for it too objRef = OBJREF_CUSTOM() objRef['iid'] = self._iid From 15560aba7910abb456294991ff5aa8b94bd5eabd Mon Sep 17 00:00:00 2001 From: gabrielg5 Date: Thu, 28 Nov 2024 12:48:54 -0500 Subject: [PATCH 2/2] wmiquery - printing exception stack trace only if error is not 'S_FALSE' --- examples/wmiquery.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/wmiquery.py b/examples/wmiquery.py index 433d7fc669..34527f5391 100755 --- a/examples/wmiquery.py +++ b/examples/wmiquery.py @@ -101,10 +101,10 @@ def printReply(self, iEnum): print('%s |' % record[key]['value'], end=' ') print() except Exception as e: - if logging.getLogger().level == logging.DEBUG: - import traceback - traceback.print_exc() if str(e).find('S_FALSE') < 0: + if logging.getLogger().level == logging.DEBUG: + import traceback + traceback.print_exc() raise else: break