Hashcat

-m /—hash-type

Hash id对照表

因为实在是太多了,所有我就贴一部分常见的hash类型,要想了解所有的参数可到hashcat的Wiki上去看,或者直接hashcat —help查看hash对照表

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
- [ Hash modes ] -

# | Name | Category
======+==================================================+======================================
900 | MD4 | Raw Hash
0 | MD5 | Raw Hash
5100 | Half MD5 | Raw Hash
100 | SHA1 | Raw Hash
1300 | SHA2-224 | Raw Hash
1400 | SHA2-256 | Raw Hash
10800 | SHA2-384 | Raw Hash
1700 | SHA2-512 | Raw Hash
17300 | SHA3-224 | Raw Hash
17400 | SHA3-256 | Raw Hash
17500 | SHA3-384 | Raw Hash
17600 | SHA3-512 | Raw Hash
10 | md5($pass.$salt) | Raw Hash, Salted and/or Iterated
20 | md5($salt.$pass) | Raw Hash, Salted and/or Iterated
30 | md5(utf16le($pass).$salt) | Raw Hash, Salted and/or Iterated
40 | md5($salt.utf16le($pass)) | Raw Hash, Salted and/or Iterated
3800 | md5($salt.$pass.$salt) | Raw Hash, Salted and/or Iterated
3710 | md5($salt.md5($pass)) | Raw Hash, Salted and/or Iterated
4010 | md5($salt.md5($salt.$pass)) | Raw Hash, Salted and/or Iterated
4110 | md5($salt.md5($pass.$salt)) | Raw Hash, Salted and/or Iterated
2600 | md5(md5($pass)) | Raw Hash, Salted and/or Iterated
3910 | md5(md5($pass).md5($salt)) | Raw Hash, Salted and/or Iterated
4300 | md5(strtoupper(md5($pass))) | Raw Hash, Salted and/or Iterated
4400 | md5(sha1($pass)) | Raw Hash, Salted and/or Iterated
110 | sha1($pass.$salt) | Raw Hash, Salted and/or Iterated
120 | sha1($salt.$pass) | Raw Hash, Salted and/or Iterated
130 | sha1(utf16le($pass).$salt) | Raw Hash, Salted and/or Iterated
140 | sha1($salt.utf16le($pass)) | Raw Hash, Salted and/or Iterated
4500 | sha1(sha1($pass)) | Raw Hash, Salted and/or Iterated
4520 | sha1($salt.sha1($pass)) | Raw Hash, Salted and/or Iterated
4700 | sha1(md5($pass)) | Raw Hash, Salted and/or Iterated
4900 | sha1($salt.$pass.$salt) | Raw Hash, Salted and/or Iterated
14400 | sha1(CX) | Raw Hash, Salted and/or Iterated
1410 | sha256($pass.$salt) | Raw Hash, Salted and/or Iterated
1420 | sha256($salt.$pass) | Raw Hash, Salted and/or Iterated
1430 | sha256(utf16le($pass).$salt) | Raw Hash, Salted and/or Iterated
1440 | sha256($salt.utf16le($pass)) | Raw Hash, Salted and/or Iterated
1710 | sha512($pass.$salt) | Raw Hash, Salted and/or Iterated
1720 | sha512($salt.$pass) | Raw Hash, Salted and/or Iterated
1730 | sha512(utf16le($pass).$salt) | Raw Hash, Salted and/or Iterated
1740 | sha512($salt.utf16le($pass)) | Raw Hash, Salted and/or Iterated
14000 | DES (PT = $salt, key = $pass) | Raw Cipher, Known-Plaintext attack
14100 | 3DES (PT = $salt, key = $pass) | Raw Cipher, Known-Plaintext attack
14900 | Skip32 (PT = $salt, key = $pass) | Raw Cipher, Known-Plaintext attack
15400 | ChaCha20 | Raw Cipher, Known-Plaintext attack
2500 | WPA-EAPOL-PBKDF2 | Network Protocols
2501 | WPA-EAPOL-PMK | Network Protocols
16800 | WPA-PMKID-PBKDF2 | Network Protocols
16801 | WPA-PMKID-PMK | Network Protocols
7300 | IPMI2 RAKP HMAC-SHA1 | Network Protocols
7500 | Kerberos 5 AS-REQ Pre-Auth etype 23 | Network Protocols
8300 | DNSSEC (NSEC3) | Network Protocols
10200 | CRAM-MD5 | Network Protocols
11100 | PostgreSQL CRAM (MD5) | Network Protocols
11200 | MySQL CRAM (SHA1) | Network Protocols
16100 | TACACS+ | Network Protocols
16500 | JWT (JSON Web Token) | Network Protocols
121 | SMF (Simple Machines Forum) > v1.1 | Forums, CMS, E-Commerce, Frameworks
400 | phpBB3 (MD5) | Forums, CMS, E-Commerce, Frameworks
2811 | MyBB 1.2+ | Forums, CMS, E-Commerce, Frameworks
2811 | IPB2+ (Invision Power Board) | Forums, CMS, E-Commerce, Frameworks
8400 | WBB3 (Woltlab Burning Board) | Forums, CMS, E-Commerce, Frameworks
11 | Joomla < 2.5.18 | Forums, CMS, E-Commerce, Frameworks
400 | Joomla >= 2.5.18 (MD5) | Forums, CMS, E-Commerce, Frameworks
400 | WordPress (MD5) | Forums, CMS, E-Commerce, Frameworks
2612 | PHPS | Forums, CMS, E-Commerce, Frameworks
7900 | Drupal7 | Forums, CMS, E-Commerce, Frameworks
21 | osCommerce | Forums, CMS, E-Commerce, Frameworks
21 | xt:Commerce | Forums, CMS, E-Commerce, Frameworks
11000 | PrestaShop | Forums, CMS, E-Commerce, Frameworks
124 | Django (SHA-1) | Forums, CMS, E-Commerce, Frameworks
10000 | Django (PBKDF2-SHA256) | Forums, CMS, E-Commerce, Frameworks
12 | PostgreSQL | Database Server
131 | MSSQL (2000) | Database Server
132 | MSSQL (2005) | Database Server
1731 | MSSQL (2012, 2014) | Database Server
200 | MySQL323 | Database Server
300 | MySQL4.1/MySQL5 | Database Server
3100 | Oracle H: Type (Oracle 7+) | Database Server
112 | Oracle S: Type (Oracle 11+) | Database Server
12300 | Oracle T: Type (Oracle 12+) | Database Server
8000 | Sybase ASE | Database Server
15000 | FileZilla Server >= 0.9.55 | FTP Server
11500 | CRC32 | Checksums
3000 | LM | Operating Systems
1000 | NTLM | Operating Systems
500 | md5crypt, MD5 (Unix), Cisco-IOS $1$ (MD5) | Operating Systems
3200 | bcrypt $2*$, Blowfish (Unix) | Operating Systems
7400 | sha256crypt $5$, SHA256 (Unix) | Operating Systems
1800 | sha512crypt $6$, SHA512 (Unix) | Operating Systems
122 | macOS v10.4, MacOS v10.5, MacOS v10.6 | Operating Systems
1722 | macOS v10.7 | Operating Systems
7100 | macOS v10.8+ (PBKDF2-SHA512) | Operating Systems
11600 | 7-Zip | Archives
12500 | RAR3-hp | Archives
13000 | RAR5 | Archives
13600 | WinZip | Archives
9700 | MS Office <= 2003 $0/$1, MD5 + RC4 | Documents
9710 | MS Office <= 2003 $0/$1, MD5 + RC4, collider #1 | Documents
9720 | MS Office <= 2003 $0/$1, MD5 + RC4, collider #2 | Documents
9800 | MS Office <= 2003 $3/$4, SHA1 + RC4 | Documents
9810 | MS Office <= 2003 $3, SHA1 + RC4, collider #1 | Documents
9820 | MS Office <= 2003 $3, SHA1 + RC4, collider #2 | Documents
9400 | MS Office 2007 | Documents
9500 | MS Office 2010 | Documents
9600 | MS Office 2013 | Documents
10400 | PDF 1.1 - 1.3 (Acrobat 2 - 4) | Documents
10410 | PDF 1.1 - 1.3 (Acrobat 2 - 4), collider #1 | Documents
10420 | PDF 1.1 - 1.3 (Acrobat 2 - 4), collider #2 | Documents
10500 | PDF 1.4 - 1.6 (Acrobat 5 - 8) | Documents
10600 | PDF 1.7 Level 3 (Acrobat 9) | Documents
10700 | PDF 1.7 Level 8 (Acrobat 10 - 11) | Documents
99999 | Plaintext | Plaintext

攻击模式:

1
2
3
4
5
6
7
# | Mode
===+======
0 | Straight(字段破解)
1 | Combination(组合破解)
3 | Brute-force(掩码暴力破解)
6 | Hybrid Wordlist + Mask(字典+掩码破解)
7 | Hybrid Mask + Wordlist(掩码+字典破解)

掩码设置

这里列一下常见的掩码字符集

1
2
3
4
5
6
7
8
l | abcdefghijklmnopqrstuvwxyz          纯小写字母
u | ABCDEFGHIJKLMNOPQRSTUVWXYZ 纯大写字母
d | 0123456789 纯数字
h | 0123456789abcdef 常见小写子目录和数字
H | 0123456789ABCDEF 常见大写字母和数字
s | !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~ 特殊字符
a | ?l?u?d?s 键盘上所有可见的字符
b | 0x00 - 0xff 可能是用来匹配像空格这种密码的

下面举几个简单的例子来了解一下掩码的设置

1
2
3
4
5
6
7
八位数字密码:?d?d?d?d?d?d?d?d
八位未知密码:?a?a?a?a?a?a?a?a
前四位为大写字母,后面四位为数字:?u?u?u?u?d?d?d?d
前四位为数字或者是小写字母,后四位为大写字母或者数字:?h?h?h?h?H?H?H?H
前三个字符未知,中间为admin,后三位未知:?a?a?aadmin?a?a?a
6-8位数字密码:--increment --increment-min 6 --increment-max 8 ?l?l?l?l?l?l?l?l
6-8位数字+小写字母密码:--increment --increment-min 6 --increment-max 8 ?h?h?h?h?h?h?h?h

如果我们想设置字符集为:abcd123456!@-+,那该怎么做呢。这就需要用到自定义字符集这个参数了,hashcat支持用户最多定义4组字符集

1
2
3
4
5
--custom-charset1 [chars]等价于 -1
--custom-charset2 [chars]等价于 -2
--custom-charset3 [chars]等价于 -3
--custom-charset4 [chars]等价于 -4
在掩码中用?1、?2、?3、?4来表示。

再来举几个例子:

1
2
3
4
--custom-charset1 abcd123456!@-+。然后我们就可以用"?1"去表示这个字符集了
--custom-charset2 ?l?d,这里和?2就等价于?h
-1 ?d?l?u,?1就表示数字+小写字母+大写字母
-3 abcdef -4 123456 那么?3?3?3?3?4?4?4?4就表示为前四位可能是“abcdef”,后四位可能是“123456”

-a /—attack-mode

-a命令可以指定攻击模式。用hashcat破译密码,仅知到密码的编号是不够的,还需要选定用hashcat进行密码破译的攻击模式。

Hashcat4.0.1有5中攻击模式,每种攻击模式都有其特征。

编号 攻击模式 含义
0 straight 直接攻击模式
1 Combinstion 组合攻击模式
3 Brute-force 爆力破解模式
4 Mask Attack 掩码攻击
6 Hybrid Wordlist+Mask 字典+掩码组合
7 Hybird Mask+Wordlist 掩码+字典组合

在这5中攻击模式下,我们可以利用字典进行密码破译,利用暴力破解的方式遍历所有可能的密码,也可以结合字典和掩码进行密码破译。在不同的攻击模式下,hashcat命令所用到的参数有所不同,我们以straight攻击模式为例,学习hashcat是如何利用字典文件进行密码破译。同事也会穿插其他参数的使用方法。

1.Straight

这一攻击模式又名“Dictionary Attack”。没啥好说的,就是给定一个字典,hashcat会逐行读取字典中的内容,计算每行的hash值,与目标hash值相比较。

示例:

1
hashcat -a 0 -m 400 example400.hash example.dict

2.Combination

这一攻击模式其实很简单,组合两个密码字典的内容。使用这一攻击模式需要不多不少地指定两个密码字典。

1
hashcat -m 0 -a 1 hash.txt dict1.txt dict2.txt

实际上尝试的字典是:

1
2
3
4
5
6
huntingparis
huntingrock
kittyparis
kittyrock
rainbowparis
rainbowrock

dict1.txt中的词在左、dict2.txt中的词在右,共3×2=6个。

与这一模式相关的参数有:

1
2
-j, --rule-left
-k, --rule-right

-j后的规则作用于左边,-k后的规则作用于右边,如添加参数 -j ‘$-‘,则实际尝试的字典便是:

1
2
3
4
5
6
hunting-paris
hunting-rock
kitty-paris
kitty-rock
rain-bowparis
rain-bowrock

添加参数 -j ‘^!’,则实际尝试的字典便是:

1
2
3
4
5
6
!huntingparis
!huntingrock
!kittyparis
!kittyrock
!rainbowparis
!rainbowrock

添加参数 -k ‘^>’,则实际尝试的字典便是:

1
2
3
4
5
6
hunting>paris
hunting>rock
kitty>paris
kitty>rock
rain>bowparis
rain>bowrock

这个规则是什么规则呢?“$”、“^”的用法和正则表达式相似,所以是正则吗?其实不是啦,hashcat的规则是自己实现的,这又是一大块内容了,详情参见Rule-based Attack,或是我翻译的hashcat之基于规则的攻击

3.Brute-force

尝试给定字符集的各种各样的组合。根据hashcat官方wiki,该方法已经过时,被Mask-Attack全方位取代,故不做研究,

4.Mask Attack

这是一种比较新颖的攻击方式,示例如下:

1
hashcat -a 3 -m 0 md5.hash ?l?l?l?l?l

虽然按照“Attack Modes”表,-a 3对应的是Brute-force,但实际上,-a 3使用的就是Mask Attack。Mask Attack可以看做高级的Brute-force。

-m参数用于指定hash函数类型,md5.hash文件中存放着md5值。关键便是最后的字符串“?l?l?l?l?l”了,这样的字符串被称为mask。

一个mask是一个字符串,这个字符串由若干个占位符组成。“?l”便是一个占位符,其中的“?”是关键字,用于修饰其后的“l”,“?l”合起来表示一个字符集合,除“?l”外,还可以有“?u”、“?d”、“?h”、“?H”、“?s”、“?a”和“?b”,代表的字符集合如下表所示。

? Charset
l abcdefghijklmnopqrstuvwxyz
u ABCDEFGHIJKLMNOPQRSTUVWXYZ
d 0123456789
h 0123456789abcdef
H 0123456789ABCDEF
s ! “#$%&’()*+,-./:;<=>?@[]^_`~{\ }
a ?l?u?d?s
b 0x00 – 0xff

这样,我们便明白了,“?l?l?l?l?l”其实等价于密码字典:

1
2
3
4
aaaaa
aaaab
...
zzzzz

同理,“?l?u?d”便等价于密码字典:

1
2
3
4
5
6
aA0
aA1
...
bA0
...
zZ9

上表中的字符集合是hashcat内置的,我们也可以自己指定字符集合:

1
2
3
4
--custom-charset1=字符集合1
--custom-charset2=字符集合2
--custom-charset3=字符集合3
--custom-charset4=字符集合4

参数 –custom-charsetN 可以缩写为 -N,如 –custom-charset1 可以缩写为 -1。用 -N 指定的字符集合在mask中以占位符“?N”的形式指定,如:

1
-1 abc123 ?1?1?1

便等价于密码字典:

1
2
3
4
5
6
aaa
aab
...
aa3
...
333

-N 后除了接表示字符集合的字符串外,还可以是一个以.hcchr结尾的文件,文件中存储着字符集合。hashcat自带了许多.hcchr文件,在安装包的charsets/目录中。

占位符“??”代表的字符集合是“?”本身。除此之外,其余的字符作为占位符时,代表的都是字符本身,如“?lwerner?d”等价于密码字典:

1
2
3
4
awerner0
awerner1
...
zwerner9

有了以上知识,便很容易理解mask了。一个mask由若干个占位符组成,每个占位符是一个字符集合,一个mask便是各个占位符字符集合的组合。占位符的个数和密码的长度相等。这样的设计,比起单纯得给定字符集合和密码长度来,有何好处呢?