Skip to content

Commit

Permalink
add wmi ObjectFlags to improve human-readability
Browse files Browse the repository at this point in the history
  • Loading branch information
NtAlexio2 committed Sep 3, 2024
1 parent 83876d6 commit b8e09f6
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions impacket/dcerpc/v5/dcom/wmi.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,12 @@ def __str__( self ):
WBEM_FLAVOR_ORIGIN_SYSTEM = 0x40
WBEM_FLAVOR_AMENDED = 0x80


# 2.2.6 ObjectFlags
OBJECT_FLAGS = 'B=0'
CIM_CLASS = 0x01
CIM_INSTANCE = 0x02
CIM_DECORATION = 0x04

#2.2.77 Signature
SIGNATURE = '<L=0x12345678'
Expand Down Expand Up @@ -900,7 +904,7 @@ def __init__(self, data = None, alignment = 0):
self.data = None

def isInstance(self):
if self['ObjectFlags'] & 0x01:
if self['ObjectFlags'] & CIM_CLASS:
return False
return True

Expand Down Expand Up @@ -984,7 +988,7 @@ def parseClass(self, pClass, cInstance = None):
return classDict

def parseObject(self):
if (self['ObjectFlags'] & 0x01) == 0:
if (self['ObjectFlags'] & CIM_CLASS) == 0:
# instance
ctCurrent = self['InstanceType']['CurrentClass']
currentName = ctCurrent.getClassName()
Expand All @@ -1005,7 +1009,7 @@ def parseObject(self):

def printInformation(self):
# First off, do we have a class?
if (self['ObjectFlags'] & 0x01) == 0:
if (self['ObjectFlags'] & CIM_CLASS) == 0:
# instance
ctCurrent = self['InstanceType']['CurrentClass']
currentName = ctCurrent.getClassName()
Expand Down Expand Up @@ -2516,7 +2520,7 @@ def SpawnInstance(self):
instanceData = OBJECT_BLOCK()
instanceData.structure += OBJECT_BLOCK.decoration
instanceData.structure += OBJECT_BLOCK.instanceType
instanceData['ObjectFlags'] = 6
instanceData['ObjectFlags'] = CIM_INSTANCE | CIM_DECORATION
instanceData['Decoration'] = self.encodingUnit['ObjectBlock']['Decoration'].getData()

instanceType = INSTANCE_TYPE()
Expand Down Expand Up @@ -2664,7 +2668,7 @@ def innerMethod(staticArgs, *args):

inParams = OBJECT_BLOCK()
inParams.structure += OBJECT_BLOCK.instanceType
inParams['ObjectFlags'] = 2
inParams['ObjectFlags'] = CIM_CLASS
inParams['Decoration'] = b''

instanceType = INSTANCE_TYPE()
Expand Down Expand Up @@ -2809,7 +2813,7 @@ def innerMethod(staticArgs, *args):

outParams = OBJECT_BLOCK()
outParams.structure += OBJECT_BLOCK.instanceType
outParams['ObjectFlags'] = 2
outParams['ObjectFlags'] = CIM_CLASS
outParams['Decoration'] = b''

instanceType = INSTANCE_TYPE()
Expand Down

0 comments on commit b8e09f6

Please sign in to comment.