forked from sunw4r/weakpass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
134 lines (115 loc) · 3.55 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
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
122
123
124
125
126
127
128
129
130
131
132
133
134
package main
import (
"flag"
"fmt"
"os"
"strings"
"time"
)
func main() {
// Command line arguments
bigFlag := flag.Bool("b", false, "Generate more permutations of passwords (recommended for offline brute)")
webFlag := flag.Bool("w", true, "Generate a smaller amount of permutations (recommended for online spray)")
silent := flag.Bool("silent", false, "Don't show banner")
companyFlag := flag.String("c", "", "Company Names (comma-separated) to be used in permutations")
outputFlag := flag.String("o", "", "File to store the passwords. If not specified, it will be printed to stdout")
flag.Parse()
if *companyFlag == "" || (!*bigFlag && !*webFlag) {
flag.Usage()
os.Exit(1)
}
if !*silent {
// banner
fmt.Fprintln(os.Stderr, `
_______ _______ _ _______ _______ _______ _______ _
|\ /|( ____ \( ___ )| \ /\( ____ )( ___ )( ____ \( ____ \ / )
| ) ( || ( \/| ( ) || \ / /| ( )|| ( ) || ( \/| ( \/ _ / /
| | _ | || (__ | (___) || (_/ / | (____)|| (___) || (_____ | (_____ (_)( (
| |( )| || __) | ___ || _ ( | _____)| ___ |(_____ )(_____ ) | |
| || || || ( | ( ) || ( \ \ | ( | ( ) | ) | ) | _ ( (
| () () || (____/\| ) ( || / \ \| ) | ) ( |/\____) |/\____) | (_) \ \
(_______)(_______/|/ \||_/ \/|/ |/ \|\_______)\_______) \_)
by: @sunw4r
`)
}
// Split the comma-separated company names
companyNames := strings.Split(*companyFlag, ",")
var wpwdlist []string
for _, company := range companyNames {
company := strings.ToLower(company)
companyCap := strings.Title(company)
companyFullCap := strings.ToUpper(company)
caseTypes := []string{companyCap, company, companyFullCap}
webCaseTypes := []string{companyCap, company}
currentYear := time.Now().Year()
currentYearM := currentYear - 1
currentYearMM := currentYear - 2
currentYearMMM := currentYear - 3
currentYearMMMM := currentYear - 4
currentYearMMMMM := currentYear - 5
currentYearP := currentYear + 1
numbers := []string{
fmt.Sprintf("%d", currentYear),
fmt.Sprintf("%d", currentYearM),
fmt.Sprintf("%d", currentYearMM),
fmt.Sprintf("%d", currentYearMMM),
fmt.Sprintf("%d", currentYearMMMM),
fmt.Sprintf("%d", currentYearMMMMM),
fmt.Sprintf("%d", currentYearP),
"1",
"12",
"123",
"1234",
"12345",
}
webNumbers := []string{
fmt.Sprintf("%d", currentYear),
fmt.Sprintf("%d", currentYearM),
"123",
}
specials := []string{"@", "", "!", "*", "#"}
webSpecials := []string{"@", ""}
if *bigFlag {
for _, x := range caseTypes {
for _, y := range numbers {
for _, z := range specials {
wpwdlist = append(wpwdlist, x+z+y, x+y+z, y+x+z, y+z+x, z+y+x, z+x+y)
}
}
}
} else if *webFlag {
for _, x := range webCaseTypes {
for _, y := range webNumbers {
for _, z := range webSpecials {
wpwdlist = append(wpwdlist, x+z+y)
}
}
}
}
}
// Remove duplicates
outputMap := make(map[string]struct{})
for _, password := range wpwdlist {
outputMap[password] = struct{}{}
}
var output []string
for password := range outputMap {
output = append(output, password)
}
// Print or save to file
if *outputFlag != "" {
file, err := os.Create(*outputFlag)
if err != nil {
fmt.Fprintln(os.Stderr, "Error opening output file:", err)
os.Exit(1)
}
defer file.Close()
for _, password := range output {
fmt.Fprintln(file, password)
}
} else {
for _, password := range output {
fmt.Println(password)
}
}
}