How to use the command 'hashid' (with examples)
Hashid is a handy tool for anyone dealing with cryptographic hash functions. This Python3 program helps identify types of data and password hashes quickly and accurately. Whether dealing with password security, digital data integrity, or file verification, ‘hashid’ can be an essential tool in your software toolkit. This article will walk you through various examples demonstrating how to use this command effectively.
Use Case 1: Identify hashes from stdin
Code:
hashid
Motivation:
When working with multiple hashes or when a hash is not in a file, you might want to determine its type directly from the command line. By using ‘hashid’ from standard input, it’s possible to interactively identify hashes by simply typing, copying, and pasting, or using pipes.
Explanation:
hashid
: Invokes the hashid command in interactive mode, allowing input through stdin. You can type or paste hashes directly into the terminal after initiating the command.
Example Output:
160a3e214d0e46d917b00f03cf247ade:
Possible Hashes:
[+] MD2
[+] MD5
Use Case 2: Identify one or more hashes
Code:
hashid hash1 hash2 ...
Motivation:
When confronted with multiple hashes, determining each of their types can be cumbersome if done individually. By using hashid with multiple hashes as input, you can simplify the process and gain insight into what cryptographic algorithms have likely been used.
Explanation:
hashid
: The main command being executed.hash1 hash2 ...
: Replace these with actual hash values. This allows for the identification of multiple hash types in a single command execution.
Example Output:
hash1:
Possible Hashes:
[+] SHA-1
hash2:
Possible Hashes:
[+] SHA-256
Use Case 3: Identify hashes on a file
Code:
hashid path/to/hashes.txt
Motivation:
If you have a file with multiple hashes to process, it can be inefficient to process each manually. Supplying a file directly to the command lets you automate the batch process, improving efficiency and accuracy when managing large data sets.
Explanation:
hashid
: The command you’re interacting with.path/to/hashes.txt
: Specifies the file path containing the hashes, with one hash per line. The command will read these hashes and identify them.
Example Output:
hash from file line 1:
Possible Hashes:
[+] SHA-512
hash from file line 2:
Possible Hashes:
[+] Whirlpool
Use Case 4: Show all possible hash types (including salted hashes)
Code:
hashid --extended hash
Motivation:
Sometimes, it’s crucial to discover all types of algorithms that could possibly generate a particular hash, including salted variations. This is especially true in a security context where you need to be thorough in evaluating potential hashing algorithms.
Explanation:
hashid
: The command being run.--extended
: An option that allows the command to display more comprehensive results, including salted hash types, which are often used in security practices to enhance password protection.hash
: The hash for which all possible types are to be identified.
Example Output:
hash:
Possible Hashes:
[+] many different and extended options
Use Case 5: Show hashcat
’s mode number and john
’s format string of the hash types
Code:
hashid --mode --john hash
Motivation:
‘Hashcat’ and ‘John the Ripper’ are popular tools for hash cracking. Knowing the exact mode for hashcat or format for John can streamline breaking unknown hashes down to known formats, significantly expediting the process of recovering plain text information from hashes.
Explanation:
hashid
: The command you are using.--mode
: Displays hashcat’s mode number.--john
: Displays the format strings used by John the Ripper.hash
: The hash for which you need the format or mode numbers.
Example Output:
hash:
Possible Hashes:
[+] SHA-512
- Hashcat Mode: 1800
- John Format: raw-sha512
Use Case 6: Save output to a file instead of printing to stdout
Code:
hashid --outfile path/to/output.txt hash
Motivation:
Automating outputs by saving results to a file can be crucial for record-keeping or subsequent analysis, particularly when handling a significant number of hashes or when output needs to be preserved for compliance or reporting.
Explanation:
hashid
: The command executed.--outfile
: Directs the output to a specified file location instead of displaying it in the terminal.path/to/output.txt
: The path to a file where you want to save the results.hash
: The hash you are identifying and outputting.
Example Output:
Output is in the specified file path/to/output.txt.
Conclusion
The ‘hashid’ command is an excellent utility for identifying hash types in various contexts. Its integration abilities with tools like hashcat and John the Ripper further enhance its utility in cybersecurity and data integrity tasks. By understanding each use case, users can greatly improve their workflow related to hash management.