Skip to content

fix(ssh2john): correct bcrypt rounds assignment and update exception …#5975

Open
dejanazul wants to merge 1 commit intoopenwall:bleeding-jumbofrom
dejanazul:fix-ssh2john-python3-and-logic
Open

fix(ssh2john): correct bcrypt rounds assignment and update exception …#5975
dejanazul wants to merge 1 commit intoopenwall:bleeding-jumbofrom
dejanazul:fix-ssh2john-python3-and-logic

Conversation

@dejanazul
Copy link
Copy Markdown

…handling

This commit addresses two issues in the OpenSSH private key extraction process:

  1. Exception Handling: Updated the decoding try-except block to catch binascii.Error directly, ensuring decode failures are handled gracefully in Python 3 environments.
  2. Logic Bug: Fixed a fallback assignment issue for OpenSSH bcrypt_pbkdf keys. Replaced an incorrect equality check (rounds == 16) with an assignment (rounds = 16) so that the iteration count defaults correctly when initially read as 0.

…handling

This commit addresses two issues in the OpenSSH private key extraction process:
1. Exception Handling: Updated the decoding try-except block to catch `binascii.Error` directly, ensuring decode failures are handled gracefully in Python 3 environments.
2. Logic Bug: Fixed a fallback assignment issue for OpenSSH `bcrypt_pbkdf` keys. Replaced an incorrect equality check (`rounds == 16`) with an assignment (`rounds = 16`) so that the iteration count defaults correctly when initially read as 0.
Copy link
Copy Markdown
Author

@dejanazul dejanazul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙌

Comment thread run/ssh2john.py
data = ''.join(lines[start:end]).encode()
data = base64.b64decode(data)
except base64.binascii.Error:
except binascii.Error:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this was maybe a Python 2 vs. 3 modules thing? I think we had this script try to work with either version, as indicated by the shebang not specifying a version.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, you actually wrote "in Python 3 environments." So I wonder what this means for Python 2, then? If this script does not support Python 2 anymore (which would be mildly unfortunate), then we need to update the shebang to python3.

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

Successfully merging this pull request may close these issues.

3 participants