ADExplorerSnapshot.py icon indicating copy to clipboard operation
ADExplorerSnapshot.py copied to clipboard

Unable to Pickle wchar[]

Open t94j0 opened this issue 1 year ago • 4 comments
trafficstars

Traceback (most recent call last):
  File "/home/USER/Downloads/ADExplorerSnapshot.py/ADExplorerSnapshot.py", line 2, in <module>
    adexpsnapshot.main()
  File "/home/USER/Downloads/ADExplorerSnapshot.py/adexpsnapshot/__init__.py", line 1133, in main
    ades.outputBloodHound()
  File "/home/USER/Downloads/ADExplorerSnapshot.py/adexpsnapshot/__init__.py", line 129, in outputBloodHound
    self.preprocessCached()
  File "/home/USER/Downloads/ADExplorerSnapshot.py/adexpsnapshot/__init__.py", line 178, in preprocessCached
    Pickler(open(cachePath, "wb")).dump(dico)
_pickle.PicklingError: Can't pickle <class 'types.wchar[]'>: attribute lookup wchar[] on types failed

Temporary solution was: init.py

@@ -126,7 +126,8 @@ class ADExplorerSnapshot(object):
             self.log.success(f"Output written to {outputfile}")
 
     def outputBloodHound(self):
-        self.preprocessCached()
+        # self.preprocessCached()
+        self.preprocess()
 
         self.numUsers = 0
         self.numGroups = 0

t94j0 avatar Jul 05 '24 14:07 t94j0

this fix worked for me, just logged in to comment and thank @t94j0

benburkhart avatar Jul 19 '24 14:07 benburkhart

This issue rises since one of the dependencies got updated, since it works for with an older version. The code crashes on line 178, since the dict we're trying to pickle has a few sub-dicts, which have keys that are of type "wchar[]" instead of "str" (as it was in the older version) Fixed it by turning each wchar[] back to 'str', hopefully it didn't break anything important: File __init__.py, line 194:

objectSid = ADUtils.get_entry_property(obj, 'objectSid')
objectSid = str(objectSid)

line 199:

distinguishedName = ADUtils.get_entry_property(obj, 'distinguishedName')
distinguishedName = str(distinguishedName)

line 215:

ncname = ADUtils.get_entry_property(obj, 'nCName')
ncname = str(ncname)

line 221:

dnshostname = ADUtils.get_entry_property(obj, 'dNSHostname')
dnshostname = str(dnshostname)

lines 226-231:

if 'pkienrollmentservice' in obj.classes:
  name = ADUtils.get_entry_property(obj, 'name')
  name = str(name)
  if ADUtils.get_entry_property(obj, 'certificateTemplates'):
      templates = ADUtils.get_entry_property(obj, 'certificateTemplates')\
      templates = str(templates)
      for template in templates:
          self.certtemplates[template].add(name)

YairCyeSec avatar Jul 22 '24 12:07 YairCyeSec

@YairCyeSec worked, thanks!

Flangvik avatar Aug 20 '24 12:08 Flangvik

@YairCyeSec thx!

nemu1k5ma avatar Aug 26 '24 07:08 nemu1k5ma

my bad for not pinning versions 💛

c3c avatar Sep 02 '24 19:09 c3c