Skip to content

Instantly share code, notes, and snippets.

@bitsandbooks
Last active June 10, 2023 10:16
Show Gist options
  • Save bitsandbooks/31cb7be719f25715b830e569fc7eb115 to your computer and use it in GitHub Desktop.
Save bitsandbooks/31cb7be719f25715b830e569fc7eb115 to your computer and use it in GitHub Desktop.
Mksha - generate $6$ shadow password hashes on macOS

Mksha

Mksha is a tiny Python 3 script to generate SHA-512 ($6$) password shadows on macOS, which truncates them by default.

Instructions

  1. Make sure mksha.py is executable: chmod u+x /path/to/mksha.py
  2. Symlink mksha.py as mksha in a folder on your $PATH: ln -s /path/to/mksha.py /usr/local/bin/mksha

You can now use the mksha command in your Terminal.

License (MIT)

Copyright 2021 by Rob D.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

#!/usr/bin/env python
import getpass
from passlib.hash import sha512_crypt
if __name__ == "__main__":
passwd = getpass.getpass('Password to hash: ')
hash = sha512_crypt.hash(passwd)
print(hash)
# Copyright 2021 by Rob D.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment