-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
80 lines (62 loc) · 1.41 KB
/
main.go
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
package main
import (
"crypto/md5"
"crypto/sha256"
"fmt"
"os"
"strings"
"golang.org/x/crypto/sha3"
)
type Hasher interface {
Hash(input string) string
}
type SHA256Hasher struct{}
func (s *SHA256Hasher) Hash(input string) string {
h := sha256.New()
h.Write([]byte(input))
return fmt.Sprintf("%x", h.Sum(nil))
}
type SHA3Hasher struct{}
func (s *SHA3Hasher) Hash(input string) string {
h := sha3.New512()
h.Write([]byte(input))
return fmt.Sprintf("%x", h.Sum(nil))
}
type MD5Hasher struct{}
func (m *MD5Hasher) Hash(input string) string {
h := md5.New()
h.Write([]byte(input))
return fmt.Sprintf("%x", h.Sum(nil))
}
func main() {
targetHash := os.Args[1]
wordlistPath := os.Args[2]
wordlist, err := os.ReadFile(wordlistPath)
if err != nil {
fmt.Println("Error reading wordlist:", err)
os.Exit(1)
}
passwords := strings.Split(string(wordlist), "\n")
hashers := []Hasher{
&SHA256Hasher{},
&SHA3Hasher{},
&MD5Hasher{},
}
for _, password := range passwords {
password = strings.TrimSpace(password)
if checkPassword(password, targetHash, hashers) {
fmt.Printf("Found password: \"%s\"\n", password)
return
}
}
fmt.Println("Password not found in the wordlist.")
}
func checkPassword(password, targetHash string, hashers []Hasher) bool {
for _, hasher := range hashers {
hashedPassword := hasher.Hash(password)
if hashedPassword == targetHash {
return true
}
}
return false
}