-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcracker.go
More file actions
121 lines (95 loc) · 2.57 KB
/
cracker.go
File metadata and controls
121 lines (95 loc) · 2.57 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
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
118
119
120
121
package main
import (
"bufio"
"bytes"
"crypto/md5"
"encoding/hex"
"fmt"
"os"
"strings"
"sync"
)
var pool = sync.Pool{
New: func() interface{} {
return &bytes.Buffer{}
},
}
var commonSuffixes = []string{"1", "12", "123", "123456", "!", "$", "!!", "..", "@", "234", "456"}
func main() {
if len(os.Args) < 3 {
fmt.Println("Usage: cracker.exe <wordlist> <hashes>")
os.Exit(1)
}
wordlistPath := os.Args[1]
hashesPath := os.Args[2]
wordlistFile, err := os.Open(wordlistPath)
if err != nil {
panic(err)
}
defer wordlistFile.Close()
hashesFile, err := os.Open(hashesPath)
if err != nil {
panic(err)
}
defer hashesFile.Close()
targetHashes := make([]string, 0)
scanner := bufio.NewScanner(hashesFile)
buf := make([]byte, 0, 64*1024)
scanner.Buffer(buf, 10*1024*1024)
for scanner.Scan() {
targetHashes = append(targetHashes, scanner.Text())
}
sem := make(chan bool, 100)
scanner = bufio.NewScanner(wordlistFile)
scanner.Buffer(buf, 10*1024*1024)
for scanner.Scan() {
word := scanner.Text()
for _, suffix := range commonSuffixes {
fullWord := word + suffix
sem <- true
go func(fullWord string) {
defer func() { <-sem }()
buf := pool.Get().(*bytes.Buffer)
defer pool.Put(buf)
buf.Reset()
buf.WriteString(fullWord + "wangduoyu666!.+-")
hash := md5.Sum(buf.Bytes())
hashString := hex.EncodeToString(hash[:])
hash = md5.Sum([]byte(hashString))
hashString = hex.EncodeToString(hash[:])
hash = md5.Sum([]byte(hashString))
hashString = hex.EncodeToString(hash[:])
for _, targetHash := range targetHashes {
if strings.EqualFold(hashString, targetHash) {
fmt.Printf("Found match: %s -> %s\n", fullWord, hashString)
return
}
}
}(fullWord)
}
// Try the regular word without the prefix or suffix
sem <- true
go func(word string) {
defer func() { <-sem }()
buf := pool.Get().(*bytes.Buffer)
defer pool.Put(buf)
buf.Reset()
buf.WriteString(word + "wangduoyu666!.+-")
hash := md5.Sum(buf.Bytes())
hashString := hex.EncodeToString(hash[:])
hash = md5.Sum([]byte(hashString))
hashString = hex.EncodeToString(hash[:])
hash = md5.Sum([]byte(hashString))
hashString = hex.EncodeToString(hash[:])
for _, targetHash := range targetHashes {
if strings.EqualFold(hashString, targetHash) {
fmt.Printf("Found match: %s -> %s\n", word, hashString)
return
}
}
}(word)
}
for i := 0; i < cap(sem); i++ {
sem <- true
}
}