impacket icon indicating copy to clipboard operation
impacket copied to clipboard

Circular import when using keytab.py

Open ThePirateWhoSmellsOfSunflowers opened this issue 1 year ago • 0 comments

Configuration

impacket version: 33058eb2fde6976ea62e04bc7d6b629d64d44712

Debug Output With Command String

I want to parse a keytab with the built-in script (impacket/krb5/keytab.py):

(venv) user@desktop:~/impacket (master) $ python ./impacket/krb5/keytab.py ~/loot/test/krb5.keytab
Traceback (most recent call last):
  File "./impacket/krb5/keytab.py", line 20, in <module>
    from enum import Enum
  File "/usr/lib/python3.8/enum.py", line 2, in <module>
    from types import MappingProxyType, DynamicClassAttribute
  File "~/impacket/impacket/krb5/types.py", line 38, in <module>
    import socket
  File "/usr/lib/python3.8/socket.py", line 53, in <module>
    from enum import IntEnum, IntFlag
ImportError: cannot import name 'IntEnum' from partially initialized module 'enum' (most likely due to a circular import) (/usr/lib/python3.8/enum.py)

Calling the function through python cli works:

>>> from impacket.krb5 import keytab
>>> keytab = keytab.Keytab.loadFile("~/loot/test/krb5.keytab")
>>> keytab.prettyPrint()
Keytab Entries:
[0]
	Principal: b'[email protected]'
	Timestamp: 2023-10-26T12:52:53	KVNO: 78
	Key: (AES256)b'6[...]b4'
[...]

Additional context

Seems trivial to fix but I don't know how to do this the pythonic way.