Passwords, Hashes and wordlist tools
Here is a how to for tools useful for passwords attack or generating wordlists Notes from my practice and HTB Academy
Cewl
Cewl can be used to generate a wordlist from a website, this can make you gain a lot of time and it was definitely helpful for me on a lot of CTF ;)
cewl http://website/ > pass.txt
cewl -w pass.txt -m 8 http://website
-m 8 will specify to find words of 8 chars or more we can also use--lowecase
Username generator
During the enumeration phase we might find users last and first name. Username generator can use thoses to generate usernames.
python3 username_generator.py -w wordlist > users.txt
will send in users.txt a list o usernames generated with a wordlist
Crunch
Crunch will generate a word based on criterias you will need.
crunch -h
will show help and optionsUsage:
crunch min max pattern -o outfile
crunch 8 8 01234abcd -o pass.txt
you will get a list of 8 chars word containing the chars in the pattern 01234abcdMore advanced options
@
lower case alpha characters,
upper case alpha characters%
numeric characters^
special characters including space
crunch 8 8 -t mypass%%
will generate a list of 8 chars word with 2 digits in the end
Home made script
It can happen for instance that you know the begining of a password or a part of a password, you can use this script to generate 2 to 3 more digits at the end (you can modify it to put it anywhere else in the string) And of course we could use crunch as well.
CUPP
CUPP is a very cool tool that will ask you question about your target in order to generate a personnalized wordlist for your target. It can use different languages
python3 cupp.py -i
launch this to start answering question about the target
hash-identifier
hash-identifier
Enter your hash
You will get a list of possible hashs
hashid
hashid <hash-here>
You will get a list of possible hashs
hashcat
It is a tool that can help crack hashes using a wordlist.
hashcat -h
will print helphashcat -m 1000 hashes.txt /usr/share/wordlists/rockyou.txt
the flag
-m
will define the hash mode see all modes hereYou can find also the proper module using this
hashcat --help | grep <service-you-need>
See the example below
the flag
-a
will set the attack modeWe can either give it a single hash or a file
Adding
--show
will show the crack value if the hash is crackedWe can use it for Brute-force attack:
-a 3
will specify it is bruteforce?d?d?d
will use 3 digits from 000 to 999.Example:
hashcat -a 3 -m 0 HASH-HERE ?d?d?d
Using hashcat with rules
Source: HTB Academy
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. |
l | Lowercase all letters. |
u | Uppercase all letters. |
c | Capitalize the first letter and lowercase others. |
sXY | 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.
In kali rules are located in
/usr/share/hashcat/rules
hashcat -a 0 -m 1000 <HASH-HERE> -r /usr/share/hashcat/rules/OneRuleToRuleThemAll.rule /usr/share/wordlists/rockyou.txt
hashcat --force password.list -r custom.rule --stdout | sort -u > mut_password.list
generate a new listmut_password.list
from another listpassword.list
and a rule filecustom.rule
John the Ripper
Single Crack mode
Brute force attack.
john --format=<hash_type> <hash or hash_file>
When we run the command, John will read the hashes from the specified file, and then it will try to crack them by comparing them to the words in its built-in wordlist and any additional wordlists specified with the --wordlist
option. Additionally, It will use any rules set with the --rules
option (if any rules are given) to generate further candidate passwords.
John will output the cracked passwords to the console and the file "john.pot" (~/.john/john.pot) in the current directory. Furthermore, it will continue cracking the remaining hashes in the background, and we can check the progress by running the john --show command. To maximize the chances of success, it is important to ensure that the wordlists and rules used are comprehensive and up to date.
Hash Format | Example Command | Description |
---|---|---|
afs |
| AFS (Andrew File System) password hashes |
bfegg |
| bfegg hashes used in Eggdrop IRC bots |
bf |
| Blowfish-based crypt(3) hashes |
bsdi |
| BSDi crypt(3) hashes |
crypt(3) |
| Traditional Unix crypt(3) hashes |
des |
| Traditional DES-based crypt(3) hashes |
dmd5 |
| DMD5 (Dragonfly BSD MD5) password hashes |
dominosec |
| IBM Lotus Domino 6/7 password hashes |
EPiServer SID hashes |
| EPiServer SID (Security Identifier) password hashes |
hdaa |
| hdaa password hashes used in Openwall GNU/Linux |
hmac-md5 |
| hmac-md5 password hashes |
hmailserver |
| hmailserver password hashes |
ipb2 |
| Invision Power Board 2 password hashes |
krb4 |
| Kerberos 4 password hashes |
krb5 |
| Kerberos 5 password hashes |
LM |
| LM (Lan Manager) password hashes |
lotus5 |
| Lotus Notes/Domino 5 password hashes |
md4-gen |
| Generic MD4 password hashes |
md5 |
| MD5 password hashes |
md5-gen |
| Generic MD5 password hashes |
mscash |
| MS Cache password hashes |
mscash2 |
| MS Cache v2 password hashes |
mschapv2 |
| MS CHAP v2 password hashes |
mskrb5 |
| MS Kerberos 5 password hashes |
mssql05 |
| MS SQL 2005 password hashes |
mssql |
| MS SQL password hashes |
mysql-fast |
| MySQL fast password hashes |
mysql |
| MySQL password hashes |
mysql-sha1 |
| MySQL SHA1 password hashes |
NETLM |
| NETLM (NT LAN Manager) password hashes |
NETLMv2 |
| NETLMv2 (NT LAN Manager version 2) password hashes |
NETNTLM |
| NETNTLM (NT LAN Manager) password hashes |
NETNTLMv2 |
| NETNTLMv2 (NT LAN Manager version 2) password hashes |
NEThalfLM |
| NEThalfLM (NT LAN Manager) password hashes |
md5ns |
| md5ns (MD5 namespace) password hashes |
nsldap |
| nsldap (OpenLDAP SHA) password hashes |
ssha |
| ssha (Salted SHA) password hashes |
NT |
| NT (Windows NT) password hashes |
openssha |
| OPENSSH private key password hashes |
oracle11 |
| Oracle 11 password hashes |
oracle |
| Oracle password hashes |
| PDF (Portable Document Format) password hashes | |
phpass-md5 |
| PHPass-MD5 (Portable PHP password hashing framework) password hashes |
phps |
| PHPS password hashes |
pix-md5 |
| Cisco PIX MD5 password hashes |
po |
| Po (Sybase SQL Anywhere) password hashes |
rar |
| RAR (WinRAR) password hashes |
raw-md4 |
| Raw MD4 password hashes |
raw-md5 |
| Raw MD5 password hashes |
raw-md5-unicode |
| Raw MD5 Unicode password hashes |
raw-sha1 |
| Raw SHA1 password hashes |
raw-sha224 |
| Raw SHA224 password hashes |
raw-sha256 |
| Raw SHA256 password hashes |
raw-sha384 |
| Raw SHA384 password hashes |
raw-sha512 |
| Raw SHA512 password hashes |
salted-sha |
| Salted SHA password hashes |
sapb |
| SAP CODVN B (BCODE) password hashes |
sapg |
| SAP CODVN G (PASSCODE) password hashes |
sha1-gen |
| Generic SHA1 password hashes |
skey |
| S/Key (One-time password) hashes |
ssh |
| SSH (Secure Shell) password hashes |
sybasease |
| Sybase ASE password hashes |
xsha |
| xsha (Extended SHA) password hashes |
zip |
| ZIP (WinZip) password hashes |
Wordlist mode
john --wordlist=<wordlist_file> --rules <hash_file>
we can specify multiple lists
Incremental Mode
Incremental Mode is an advanced John mode used to crack passwords using a character set. It is a hybrid attack, which means it will attempt to match the password by trying all possible combinations of characters from the character set. This mode is the most effective yet most time-consuming of all the John modes. This mode works best when we know what the password might be, as it will try all the possible combinations in sequence, starting from the shortest one. This makes it much faster than the brute force attack, where all combinations are tried randomly. Moreover, the incremental mode can also be used to crack weak passwords, which may be challenging to crack using the standard John modes. The main difference between incremental mode and wordlist mode is the source of the password guesses. Incremental mode generates the guesses on the fly, while wordlist mode uses a predefined list of words. At the same time, the single crack mode is used to check a single password against a hash.
john --incremental <hash_file>
read the hashes in the specified hash file and then generate all possible combinations of characters, starting with a single character and incrementing with each iteration. The default character set is limited to a-zA-Z0-9. If we attempt to crack complex passwords with special characters, we need to use a custom character set.
Rule-Based Attack
John the ripper has a config file that contains rule sets, which is located at /etc/john/john.conf or /opt/john/john.conf depending on your distro or how john was installed. You can read /etc/john/john.conf and look for List.Rules to see all the available rules:
cat /etc/john/john.conf|grep "List.Rules:" | cut -d"." -f3 | cut -d":" -f2 | cut -d"]" -f1 | awk NF
We can create a rule and add it to the conf file, for example this rule will add a symbol at the beginning of the word and a number at the end:
Cracking files
Tool | Description |
---|---|
pdf2john | Converts PDF documents for John |
ssh2john | Converts SSH private keys for John |
mscash2john | Converts MS Cash hashes for John |
keychain2john | Converts OS X keychain files for John |
rar2john | Converts RAR archives for John |
pfx2john | Converts PKCS#12 files for John |
truecrypt_volume2john | Converts TrueCrypt volumes for John |
keepass2john | Converts KeePass databases for John |
vncpcap2john | Converts VNC PCAP files for John |
putty2john | Converts PuTTY private keys for John |
zip2john | Converts ZIP archives for John |
hccap2john | Converts WPA/WPA2 handshake captures for John |
office2john | Converts MS Office documents for John |
wpa2john | Converts WPA/WPA2 handshakes for John |
Find more tools with
locate *2john*
Crackmapexec
sudo apt-get -y install crackmapexec
installcrackmapexec <proto> <target-IP> -u <user or userlist> -p <password or passwordlist>
usage
Hydra
Hydra is a very handy tool for when you need to bruteforce auth. It supports a lot of protocols.
SSH
hydra -L users -P pass 10.10.4.129 -t 4 ssh
will use the user list and password list mentioned if you put minus l or minus p you can just specify one user or one password. ORhydra -L users.lst -P /path/to/wordlist.txt ssh://10.10.x.x -v
hydra -L usernames-list.txt -p Spring2021 ssh://10.1.1.10
Password spraying attack
FTP
It is pretty much the same for ftp except you need to add ftp instead of ssh in the end:
hydra -L users -P pass 10.10.4.129 -t 4 ftp
if you have the username you can also do has followhydra -l ftp -P passlist.txt ftp://10.10.x.x
(we useftp
as the username)
SMTP
hydra -l email@company.xyz -P /path/to/wordlist.txt
HTTP logins
hydra -l admin -P 500-worst-passwords.txt 10.10.x.x http-get-form "/login-get/index.php:username=^USER^&password=^PASS^:S=logout.php" -f
RDP
hydra -L user.list -P password.list rdp://10.129.42.197
SMB
hydra -L user.list -P password.list smb://10.129.42.197
RDPassSpray
Get it here. This tool allows you to perform attacks on RDP services
python3 RDPassSpray.py -u victim -p Spring2021! -t 10.100.10.240:3026
Secretdump (Impacket)
Get SAM hashes with SAM file, SECURITY file and SYSTEM file
You can also work only with SAM and SYSTEM
secretsdump.py local -sam SAM -system SYSTEM
Mentalist
Mentalist is a graphical tool for custom wordlist generation. It utilizes common human paradigms for constructing passwords and can output the full wordlist as well as rules compatible with Hashcat and John the Ripper.
Resources
Last updated