【笔记】Hashcat学习笔记

前言

hashcat is the world’s fastest and most advanced password recovery utility, supporting five unique modes of attack for over 300 highly-optimized hashing algorithms. hashcat currently supports CPUs, GPUs, and other hardware accelerators on Linux, Windows, and macOS, and has facilities to help enable distributed password cracking.(GitHub

本文仅用于网络信息防御学习

准备工作

直接下载二进制文件

手动编译

1
2
3
git clone https://github.com/hashcat/hashcat.git
cd hashcat
make && make install

基本命令

<hash>:hash值或包含多个hash值(每个值占一行)的文件
<str>:掩码
<dict>:(包含多个可能是明文的)字典文件(每个值占一行)

-m <num>:指定哈希类型

0:md5
100:sha1
更多类型参见帮助

-a <num>:指定破解模式

0:Straight,字典爆破
1:Combination,将字典中密码进行组合
3 <str>:Brute-force,使用指定掩码破解

?l:小写字母
?u:大写字母
?d:数字
?s:特殊字符
?a:小写字母、大写字母、数字、特殊字符组合
?b:0x00-0xff

6:Hybrid Wordlist + Mask,字典+掩码破解
7:Hybrid Mask + Wordlist,掩码+字典破解

-D <num>:指定OpenCL驱动

1:CPU
2:GPU
3:FPGA, DSP, Co-Processor

-V:显示版本
-h:显示帮助
-o <file>:输出到文件
-b:测试计算机破解速度和相关硬件信息
-T <num>:设置线程数

--show:展示成功破解的hash值及对应的明文
--force:忽略警告
--show:仅显示破解的hash值和明文
--remove:从源文件删除破解成功的hash值
--username:忽略hash表中的用户名
--increment-min <num>:设置密码最小长度
--increment-max <num>:设置密码最大长度

1
2
3
4
hashcat -m 0 -a 3 e10adc3949ba59abbe56e057f20f883e dddddd --show

hashcat -m 0 -a 0 <hash> <dict>
hashcat -m 0 -a 7 <hash> <str> <dict>

爆破rar5密文

通过rar2john获取密文

<file>:有密码的rar文件

1
rar2john <file>

通过hashcat爆破密文

<str>:通过rar2john获取的冒号后面的密文

1
hashcat -m 13000 -a 3 '<str>' --increment-min 1 --increment-min 8

踩坑

  • 报错:No such file or directory

原因

  • hashcat在运行时需要一个存放hashcat.pid文件和hashcat.outfiles文件的目录,找不到所以报错

解决问题

  • 手动创建hashcat需要的层级目录

<dir>:报错中提示找不到的目录结构

1
mkdir -p <dir>

踩坑

  • 报错:no matches found: ?d?d?d?d?d?d

原因

  • 找不到?d?d?d?d?d?d相关参数

解决问题

  • 经过测试,MacOS上不加?,Windows上加?

完成

参考文献

微信公众号——白帽子左一