-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.go
More file actions
71 lines (55 loc) · 1.2 KB
/
main.go
File metadata and controls
71 lines (55 loc) · 1.2 KB
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
// Dump user password hashes from Active Directory databases.
//
// Usage:
//
// hashdump system ntds
//
// The arguments are:
//
// system
// System registry hive (required).
// ntds
// Active Directory database (required).
package main
import (
"fmt"
"os"
"go.foxforensics.dev/bootkey/bootkey"
"go.foxforensics.dev/go-mmap"
"go.foxforensics.dev/hashdump/hashdump"
)
func main() {
if len(os.Args) < 3 || os.Args[1] == "--help" {
_, _ = fmt.Fprintln(os.Stderr, "usage: hashdump system ntds")
os.Exit(2)
}
k, err := bootkey.ReadFile(os.Args[1])
if err != nil {
_, _ = fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
_, _ = fmt.Printf("BootKey: %x\n", k)
f, err := os.Open(os.Args[2])
if err != nil {
_, _ = fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
defer func() { _ = f.Close() }()
m, err := mmap.Map(f, mmap.RDONLY, 0)
if err != nil {
_, _ = fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
defer func() { _ = m.Unmap() }()
records, keys, err := hashdump.Dump(m, k)
if err != nil {
_, _ = fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
for i, key := range keys {
_, _ = fmt.Printf("PEK #%d: %x\n", i, key)
}
for _, record := range records {
_, _ = fmt.Println(record.String())
}
}