Brute Forcing/ Password Cracking
Hash Identifier
Online Hash Crackers
Default Credentials
base64 decoder
Windows Password Cracking
Dumping SAM files
Dumping Hashes with Impacket's secretsdump.py
One incredibly useful tool we can use to dump the hashes offline is Impacket's secretsdump.py
. Impacket can be found on most modern penetration testing distributions. We can check for it by using locate
on a Linux-based system:
Locating secretsdump.py
Using secretsdump.py is a simple process. All we must do is run secretsdump.py using Python, then specify each hive file we retrieved from the target host.
Running secretsdump.py
Here we see that secretsdump successfully dumps the local
SAM hashes and would've also dumped the cached domain logon information if the target was domain-joined and had cached credentials present in hklm\security. Notice the first step secretsdump executes is targeting the system bootkey
before proceeding to dump the LOCAL SAM hashes
. It cannot dump those hashes without the boot key because that boot key is used to encrypt & decrypt the SAM database, which is why it is important for us to have copies of the registry hives we discussed earlier in this section. Notice at the top of the secretsdump.py output:
This tells us how to read the output and what hashes we can crack. Most modern Windows operating systems store the password as an NT hash. Operating systems older than Windows Vista & Windows Server 2008 store passwords as an LM hash, so we may only benefit from cracking those if our target is an older Windows OS.
Knowing this, we can copy the NT hashes associated with each user account into a text file and start cracking passwords. It may be beneficial to make a note of each user, so we know which password is associated with which user account.
Generating Word list with Crunch
3 the first number is the minimum length of the generated password
3 the second number is the maximum length of the generated password
0123456789ABCDEF is the character set to use to generate the passwords
-o 3digits.txt saves the output to the 3digits.txt file
Hydra
Http brute force with Hydra
hydra -C tomcat-betterdefaultpasslist.txt -s 8080 10.10.10.95 http-get /manager/html
HTTP GET FORM
Hydra Post Form
-l '' indicates that the login name is blank as the security lock only requires a password
-P 3digits.txt specifies the password file to use
-f stops Hydra after finding a working password
-v provides verbose output and is helpful for catching errors
MACHINE_IP is the IP address of the target
http-post-form specifies the HTTP method to use
"/login.php:pin=^PASS^:Access denied" has three parts separated by : /login.php is the page where the PIN code is submitted pin=^PASS^ will replace ^PASS^ with values from the password list Access denied indicates that invalid passwords will lead to a page that contains the text “Access denied”
-s 8000 indicates the port number on the target
Hydra SSH brute force
John the Ripper
SSH key
Simple Format to crack hashes
To list supported hash types by John
Cracking Hashes
Linux Password cracking
Single Crack Mode
John also has another mode, called Single Crack mode. In this mode, John uses only the information provided in the username, to try and work out possible passwords heuristically, by slightly changing the letters and numbers contained within the username. To use single crack mode, we use roughly the same syntax that we've used to so far, for example if we wanted to crack the password of the user named "Mike", using single mode, we'd use:
If you're cracking hashes in single crack mode, you need to change the file format that you're feeding john for it to understand what data to create a wordlist from. You do this by prepending the hash with the username that the hash belongs to, so according to the above example- we would change the file hashes.txt
From:
1efee03cdcb96d90ad48ccc7b8666033
To
mike:1efee03cdcb96d90ad48ccc7b8666033
Zip Hash cracking
Rar Password Cracking
gpg Encryption
GnuPG or GPG is an Open Source implementation of PGP from the GNU project. You may need to use GPG to decrypt files in CTFs. With PGP/GPG, private keys can be protected with passphrases in a similar way to SSH private keys. If the key is passphrase protected, you can attempt to crack this passphrase using John The Ripper and gpg2john.
Import gpg key
Decrypt Message
Cracking groups.xml file (Windows server 2008)
Viewing the downloaded file, we get the username." userName="active.htb\SVC_TGS"
Now lets decrypt it with gpp-decrypt
Crackmapexec
Let's check if we have access through winrm.
Evil-winrm
We can then use evil-winrm to connect to our target
SSH Bruteforcing CrackMapExec
Listing Shares with crackmapexec
We can then use smbclient to view the share
You can also use MSF to bruteforce SMB.
Password Mutations
Considering that many people want to keep their passwords as simple as possible despite password policies, we can create rules for generating weak passwords. Based on statistics provided by WPengine, most password lengths are not longer
than ten
characters. So what we can do is to pick specific terms that are at least five
characters long and seem to be the most familiar to the users, such as the names of their pets, hobbies, preferences, and other interests. If the user chooses a single word (such as the current month), adds the current year
, followed by a special character, at the end of their password, we would reach the ten-character
password requirement. Considering that most companies require regular password changes, a user can modify their password by just changing the name of a month or a single number, etc. Let's use a simple example to create a password list with only one entry.
Password List
We can use a very powerful tool called Hashcat to combine lists of potential names and labels with specific mutation rules to create custom wordlists. To become more familiar with Hashcat and discover the full potential of this tool, we recommend the module Cracking Passwords with Hashcat. Hashcat uses a specific syntax for defining characters and words and how they can be modified. The complete list of this syntax can be found in the official documentation of Hashcat. However, the ones listed below are enough for us to understand how Hashcat mutates words.
Function | Description |
| Do nothing. |
| Lowercase all letters. |
| Uppercase all letters. |
| Capitalize the first letter and lowercase others. |
| Replace all instances of X with Y. |
| Add the exclamation character at the end. |
Each rule is written on a new line which determines how the word should be mutated. If we write the functions shown above into a file and consider the aspects mentioned, this file can then look like this:
Hashcat Rule File
Hashcat will apply the rules of custom.rule
for each word in password.list
and store the mutated version in our mut_password.list
accordingly. Thus, one word will result in fifteen mutated words in this case.
Generating Rule-based Wordlist
Hashcat
and John
come with pre-built rule lists that we can use for our password generating and cracking purposes. One of the most used rules is best64.rule
, which can often lead to good results. It is important to note that password cracking and the creation of custom wordlists is a guessing game in most cases. We can narrow this down and perform more targeted guessing if we have information about the password policy and take into account the company name, geographical region, industry, and other topics/words that users may select from to create their passwords. Exceptions are, of course, cases where passwords are leaked and found.
Hashcat Existing Rules
Generating wordlist from a website with CEWL
We can now use another tool called CeWL to scan potential words from the company's website and save them in a separate list. We can then combine this list with the desired rules and create a customized password list that has a higher probability of guessing a correct password. We specify some parameters, like the depth to spider (-d
), the minimum length of the word (-m
), the storage of the found words in lowercase (--lowercase
), as well as the file where we want to store the results (-w
).
Generating Wordlists Using CeWL
Crowbar - another tool for bruteforcing
Works best for RDP brute forcing
Xfreerdp
Remote Dumping & LSA Secrets Considerations
With access to credentials with local admin privileges
, it is also possible for us to target LSA Secrets over the network. This could allow us to extract credentials from a running service, scheduled task, or application that uses LSA secrets to store passwords.
Dumping SAM Remotely
We can also dump hashes from the SAM database remotely.
Password Cracking Cheatsheat
Connecting to Target
Command | Description |
| CLI-based tool used to connect to a Windows target using the Remote Desktop Protocol. |
| Uses Evil-WinRM to establish a Powershell session with a target. |
| Uses SSH to connect to a target using a specified user. |
| Uses smbclient to connect to an SMB share using a specified user. |
| Uses smbserver.py to create a share on a linux-based attack host. Can be useful when needing to transfer files from a target to an attack host. |
Password Mutations
Command | Description |
| Uses cewl to generate a wordlist based on keywords present on a website. |
| Uses Hashcat to generate a rule-based word list. |
| Users username-anarchy tool in conjunction with a pre-made list of first and last names to generate a list of potential username. |
| Uses Linux-based commands curl, awk, grep and tee to download a list of file extensions to be used in searching for files that could contain passwords. |
Remote Password Attacks
Command | Description |
| Uses CrackMapExec over WinRM to attempt to brute force user names and passwords specified hosted on a target. |
| Uses CrackMapExec to enumerate smb shares on a target using a specified set of credentials. |
| Uses Hydra in conjunction with a user list and password list to attempt to crack a password over the specified service. |
| Uses Hydra in conjunction with a username and password list to attempt to crack a password over the specified service. |
| Uses Hydra in conjunction with a user list and password to attempt to crack a password over the specified service. |
| Uses Hydra in conjunction with a list of credentials to attempt to login to a target over the specified service. This can be used to attempt a credential stuffing attack. |
| Uses CrackMapExec in conjunction with admin credentials to dump password hashes stored in SAM, over the network. |
| Uses CrackMapExec in conjunction with admin credentials to dump lsa secrets, over the network. It is possible to get clear-text credentials this way. |
| Uses CrackMapExec in conjunction with admin credentials to dump hashes from the ntds file over a network. |
| Uses Evil-WinRM to establish a Powershell session with a Windows target using a user and password hash. This is one type of |
Windows Local Password Attacks
Command | Description |
| A command-line-based utility in Windows used to list running processes. |
| Uses Windows command-line based utility findstr to search for the string "password" in many different file type. |
| A Powershell cmdlet is used to display process information. Using this with the LSASS process can be helpful when attempting to dump LSASS process memory from the command line. |
| Uses rundll32 in Windows to create a LSASS memory dump file. This file can then be transferred to an attack box to extract credentials. |
| Uses Pypykatz to parse and attempt to extract credentials & password hashes from an LSASS process memory dump file. |
| Uses reg.exe in Windows to save a copy of a registry hive at a specified location on the file system. It can be used to make copies of any registry hive (i.e., hklm\sam, hklm\security, hklm\system). |
| Uses move in Windows to transfer a file to a specified file share over the network. |
| Uses Secretsdump.py to dump password hashes from the SAM database. |
| Uses Windows command line based tool vssadmin to create a volume shadow copy for |
| Uses Windows command line based tool copy to create a copy of NTDS.dit for a volume shadow copy of |
Linux Local Password Attacks
Command | Description |
| Script that can be used to find .conf, .config and .cnf files on a Linux system. |
| Script that can be used to find credentials in specified file types. |
| Script that can be used to find common database files. |
| Uses Linux-based find command to search for text files. |
| Script that can be used to search for common file types used with scripts. |
| Script used to look for common types of documents. |
| Uses Linux-based cat command to view the contents of crontab in search for credentials. |
| Uses Linux-based ls -la command to list all files that start with |
| Uses Linux-based command grep to search the file system for key terms |
| Uses Linux-based grep command to search for the keywords |
| Uses Linux-based grep command to search for keywords |
| Uses Linux-based tail command to search the through bash history files and output the last 5 lines. |
| Runs Mimipenguin.py using python3. |
| Runs Mimipenguin.sh using bash. |
| Runs Lazagne.py with all modules using python2.7 |
| Uses Linux-based command to search for credentials stored by Firefox then searches for the keyword |
| Uses Linux-based command cat to search for credentials stored by Firefox in JSON. |
| Runs Firefox_decrypt.py to decrypt any encrypted credentials stored by Firefox. Program will run using python3.9. |
| Runs Lazagne.py browsers module using Python 3. |
Cracking Passwords
Command | Description |
| Uses Hashcat to crack NTLM hashes using a specified wordlist. |
| Uses Hashcat to attempt to crack a single NTLM hash and display the results in the terminal output. |
| Uses unshadow to combine data from passwd.bak and shadow.bk into one single file to prepare for cracking. |
| Uses Hashcat in conjunction with a wordlist to crack the unshadowed hashes and outputs the cracked hashes to a file called unshadowed.cracked. |
| Uses Hashcat in conjunction with a word list to crack the md5 hashes in the md5-hashes.list file. |
| Uses Hashcat to crack the extracted BitLocker hashes using a wordlist and outputs the cracked hashes into a file called backup.cracked. |
| Runs Ssh2john.pl script to generate hashes for the SSH keys in the SSH.private file, then redirects the hashes to a file called ssh.hash. |
| Uses John to attempt to crack the hashes in the ssh.hash file, then outputs the results in the terminal. |
| Runs Office2john.py against a protected .docx file and converts it to a hash stored in a file called protected-docx.hash. |
| Uses John in conjunction with the wordlist rockyou.txt to crack the hash protected-docx.hash. |
| Runs Pdf2john.pl script to convert a pdf file to a pdf has to be cracked. |
| Runs John in conjunction with a wordlist to crack a pdf hash. |
| Runs Zip2john against a zip file to generate a hash, then adds that hash to a file called zip.hash. |
| Uses John in conjunction with a wordlist to crack the hashes contained in zip.hash. |
| Uses Bitlocker2john script to extract hashes from a VHD file and directs the output to a file called backup.hashes. |
| Uses the Linux-based file tool to gather file format information. |
| Script that runs a for-loop to extract files from an archive. |
Last updated