skelsec / pypykatz

Mimikatz implementation in pure Python
MIT License
2.81k stars 371 forks source link

Fixes a crash when CredmanCredential.password_raw is None #95

Closed themaks closed 2 years ago

themaks commented 2 years ago

For some reason, the password_raw attribute of the CredmanCredential object might be None when the object is printed, which crashes the output when dumping credentials.

Please note that this does not seem to be the case for WDigestCredential.password_raw, for which the value is b'' when the password does not exist, but I didn't dive deep enough into the code to find out why. You are welcome to change this fix if it is not the best way to deal with the bug

Cheers


The original stacktrace :

Traceback (most recent call last):
  File "/usr/local/bin/pypykatz", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/dist-packages/pypykatz/__main__.py", line 84, in main
    helper.execute(args)
  File "/usr/local/lib/python3.9/dist-packages/pypykatz/lsadecryptor/cmdhelper.py", line 52, in execute
    self.run(args)
  File "/usr/local/lib/python3.9/dist-packages/pypykatz/lsadecryptor/cmdhelper.py", line 252, in run
    self.process_results(results, files_with_error, args)
  File "/usr/local/lib/python3.9/dist-packages/pypykatz/lsadecryptor/cmdhelper.py", line 131, in process_results
    print(str(results[result].logon_sessions[luid]))
  File "/usr/local/lib/python3.9/dist-packages/pypykatz/lsadecryptor/packages/msv/decryptor.py", line 191, in __str__
    t+= str(cred)
  File "/usr/local/lib/python3.9/dist-packages/pypykatz/lsadecryptor/packages/msv/decryptor.py", line 78, in __str__
    t += '\t\tpassword (hex)%s\n' % self.password_raw.hex()
AttributeError: 'NoneType' object has no attribute 'hex'
skelsec commented 2 years ago

Thank you for the PR, but this issue will be addressed by setting the default password_raw attribute to b'' in all structures.