Created
November 9, 2022 19:51
-
-
Save Arokota/70d1fd382255d5b9eef05714c1286ed9 to your computer and use it in GitHub Desktop.
Generate NTLM Hash from Command-Line
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| #Credit: https://stackoverflow.com/questions/15603628/how-to-calculate-ntlm-hash-in-python | |
| import binascii, hashlib, sys | |
| def generate(input_str): | |
| ntlm_hash = binascii.hexlify(hashlib.new('md4', input_str.encode('utf-16le')).digest()) | |
| return ntlm_hash | |
| num_of_args = len(sys.argv) | |
| if num_of_args == 1: | |
| print("[!] Need input!") | |
| print("[*] EX: ntlm-gen.py mypassword") | |
| if num_of_args == 3 and sys.argv[1] == "-c": | |
| #Print formatted for C Array | |
| ntlm_hash = generate(sys.argv[2]).decode() | |
| c_array = "" | |
| for x in range(0, len(ntlm_hash), 2): | |
| c_array += "0x" + ntlm_hash[x] + ntlm_hash[x+1] + "," | |
| print(c_array) | |
| elif num_of_args == 2: | |
| ntlm_hash = generate(sys.argv[1]) | |
| print(ntlm_hash.decode()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment