Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

find function #159

Closed
prrsvxt opened this issue Jul 31, 2023 · 4 comments
Closed

find function #159

prrsvxt opened this issue Jul 31, 2023 · 4 comments

Comments

@prrsvxt
Copy link

prrsvxt commented Jul 31, 2023

I have an issue when starting certipy find, it looks like this

AttributeError: module 'enum' has no attribute '_decompose'

@prrsvxt
Copy link
Author

prrsvxt commented Jul 31, 2023

the full error here:
[-] Got error: module 'enum' has no attribute '_decompose'
Traceback (most recent call last):
File "/home/cyber-myth/.local/lib/python3.11/site-packages/certipy/commands/find.py", line 782, in security_to_bloodhound_aces
standard_rights = list(rights["rights"])
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/enum.py", line 1482, in iter
yield from self.iter_member(self.value)
File "/usr/lib/python3.11/enum.py", line 1369, in iter_member_by_def
yield from sorted(
^^^^^^^
File "/usr/lib/python3.11/enum.py", line 1371, in
key=lambda m: m.sort_order,
^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'sort_order'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/cyber-myth/.local/lib/python3.11/site-packages/certipy/entry.py", line 60, in main
actionsoptions.action
File "/home/cyber-myth/.local/lib/python3.11/site-packages/certipy/commands/parsers/find.py", line 12, in entry
find.entry(options)
File "/home/cyber-myth/.local/lib/python3.11/site-packages/certipy/commands/find.py", line 1185, in entry
find.find()
File "/home/cyber-myth/.local/lib/python3.11/site-packages/certipy/commands/find.py", line 455, in find
self.output_bloodhound_data(prefix, templates, cas)
File "/home/cyber-myth/.local/lib/python3.11/site-packages/certipy/commands/find.py", line 578, in output_bloodhound_data
aces = self.security_to_bloodhound_aces(security)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/cyber-myth/.local/lib/python3.11/site-packages/certipy/commands/find.py", line 784, in security_to_bloodhound_aces
standard_rights = rights["rights"].to_list()
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/cyber-myth/.local/lib/python3.11/site-packages/certipy/lib/constants.py", line 265, in to_list
members, _ = enum._decompose(cls, self.value)
^^^^^^^^^^^^^^^
AttributeError: module 'enum' has no attribute '_decompose'

@Cyb3rC3lt
Copy link

Cyb3rC3lt commented Aug 3, 2023

Just to add that it looks like I have that error too. Python 3.11.4 and certipy added via pipx.

Update: Just spotted it is being tracked here so maybe this duplicate can be closed: #154

@vaibhav200225
Copy link

Add the below code in /usr/lib/python3.11/enum.py which will solve your problem.

def _decompose(flag, value):
"""
Extract all members from the value.
"""
# _decompose is only called if the value is not named
not_covered = value
negative = value < 0
members = []
for member in flag:
member_value = member.value
if member_value and member_value & value == member_value:
members.append(member)
not_covered &= ~member_value
if not negative:
tmp = not_covered
while tmp:
flag_value = 2 ** _high_bit(tmp)
if flag_value in flag.value2member_map:
members.append(flag.value2member_map[flag_value])
not_covered &= ~flag_value
tmp &= ~flag_value
if not members and value in flag.value2member_map:
members.append(flag.value2member_map[value])
members.sort(key=lambda m: m.value, reverse=True)
if len(members) > 1 and members[0].value == value:
# we have the breakdown, don't need the value member itself
members.pop(0)
return members, not_covered

@ly4k
Copy link
Owner

ly4k commented Sep 19, 2023

Fixed in version 4.8.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants