Debian

Red Hat

Many people may have a user account on their system which they may not know the password to log in. Other passwords may also exist which can be recovered.This article will cover the use of Hashcat to find missing passwords. Of course, this process will not find every password, but it can help to attempt a recovery.The first step to use Hashcat is to get the program.To get the files needed you need to open a Terminal and type the following commands:Hashcat 3.50 is available, but the CPU and GPU requirements are quite limiting for use. Version 2.00 works on most systems.The commands will place you in your HOME folder and then download the compressed file containing Hashcat.To extract the downloaded file you need ‘7Zip’ the program for extracting the ‘7z’ file. Then you need to extract the file. Perform the following for your Linux type:Next, the commands will be the same for Debian and Red Hat systems.There are two files you need to be aware of in this folder. If you have a 64-bit system then you will need the file ‘hashcat64-cli.bin’. If your system is a 32-bit system then you need to use the file ‘hashcat-cli32.bin’.Once you know which file you need you can copy it to the folder ‘/usr/bin’ with the appropriate following command:To test that the file will work type the name of your specific file followed by ‘-help’. For example, for either a 32 or a 64-bit system type the command ‘sudo hashcat.bin -help’.You should be given a long list of help information for the hashcat program.Perform the following commands to prepare hashcat:The use of the ‘bzip2’ command will extract the specified file and the ‘-d’ parameter will decompress the compressed file. The original compressed file will be deleted once it has been extracted.If we are looking to recover a password for a Linux account then we should create one.To add a User Account I will name mine ‘tester’, perform the following commands:After typing the last command you will be prompted to enter and re-enter the password for the User ‘tester’.Next, we need to know what encryption method is used by your Linux System. I ran the following command on both a Ubuntu 14.04 and CentOS 7.0 system and received the result of SHA512:Before we can get the SALT for the User ‘tester’ you need to log in as ‘tester’ and then log back in as you. You can get the SALT for the user ‘tester’ by typing one of the following commands:Since the User ‘tester’ was the last User Account created then it will be the last line in the file. The output is shown in Figure 1.We need to create a hash file for the User ‘tester’. To create the hash file perform the following command:You will need to edit the file and remove the Users name (tester) and all colons and periods at the end of the line as shown in Figure 2.Now, about the SALT. SALT is random data that is included with a password to produce the hash.In Figure 1, the SALT is between the two dollar signs ($) and is ‘yL2thS.Y’.We can also combine the three password files into one file to make things easier. To do thisenter the following command:You should now have a file named ‘passwords.txt’ which contains all of the passwords from the three original files.We are now ready to look at Hashcat and hopefully find the password for ‘tester’.First we must understand the Hashcat syntax to find our password.The basic syntax is:The two primary options we will use are as follows:The ‘hashtype’ is based off of the following values:To get a more extensive list use the command ‘hashcat64.bin –help’ and look for the section on ‘Hash Modes’.The ‘Attack Mode’ option has the following values:So the command we will use is as follows:The command is being run from the folder ‘hashcat-2.00’ where the ‘password.hash’ file is located.The command, as shown in Figure 3, took 2 milliseconds and found that password to be ‘starwars’. The process did not take long since the password was in the ‘passwords.txt’. What if I change the password to one which is not in the list?If you want to find a larger text file of words, try ‘’ which contains over 2,000,000 entries. Depending on the system it will take over an hour to get through the list. The time goes faster if the password is found in the list toward the beginning of the file.Keep in mind that all your lists can be concatenated together as we did before to make one large list. The command is as follows:Just enter as many filenames as you need and give the new larger file a new name (). The larger your dictionary the more chances you have of finding a password.I changed the password for ‘tester’ and created a new hash file. I am using the new passwords file from dazzlepod.com.What if a password is not found in the dictionary?We can provide a mask to use as a model for trying various passwords at random. The Brute Force Attack can be quite lengthy to determine a password which is completely unknown.The Mask you provide is based off of known or unknown characters. The characters are symbolized by the following:If you know the password is all lower-case alphabetic characters and is five characters long the the mask would be ‘?l?l?l?l?l’.Any way you can limit the mask to characters other than all (?a) will greatly reduce the time needed to find the password.If we have no clue as to the characters or even the length, we would have to use a mask of all ‘?a’ and assume there is a specific number, or less, of characters in the password. For instance, we can assume there will be ten or less characters in the password so the mask would be ‘?a?a?a?a?a?a?a?a?a?a’.The command given would be similar to that used before, but the dictionary list would be replaced with the mask:?a?a?a?a?a?a?a?a?a?a’Have fun with cracking passwords. Hope this helps find lost passwords.