-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
208 lines (172 loc) · 5.53 KB
/
Copy pathmain.go
File metadata and controls
208 lines (172 loc) · 5.53 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
package main
import (
"bufio"
"flag"
"fmt"
"os"
"strings"
"github.com/fatih/color"
)
const banner = `
██████╗ ██╗ ██╗████████╗███████╗
██╔══██╗██║ ██║╚══██╔══╝╚══███╔╝
██████╔╝██║ ██║ ██║ ███╔╝
██╔══██╗██║ ██║ ██║ ███╔╝
██████╔╝███████╗██║ ██║ ███████╗
╚═════╝ ╚══════╝╚═╝ ╚═╝ ╚══════╝
Fast Web Form Cracking
https://github.com/moscovium-mc/blitz
`
var (
targetURL string
usernameFile string
passwordFile string
threads int
timeout int
rateLimit int
verbose bool
skipWAF bool
formIndex int
)
func init() {
flag.StringVar(&targetURL, "url", "", "Target URL to test (required)")
flag.StringVar(&usernameFile, "usernames", "usernames.txt", "Path to username wordlist")
flag.StringVar(&passwordFile, "passwords", "passwords.txt", "Path to password wordlist")
flag.IntVar(&threads, "threads", 5, "Number of concurrent threads")
flag.IntVar(&timeout, "timeout", 10, "Request timeout in seconds")
flag.IntVar(&rateLimit, "rate", 100, "Requests per second limit")
flag.BoolVar(&verbose, "verbose", false, "Verbose output")
flag.BoolVar(&skipWAF, "skip-waf", false, "Skip WAF detection")
flag.IntVar(&formIndex, "form", 0, "Form index to target (default: auto-detect)")
}
func main() {
printBanner()
flag.Parse()
// Validate required flags
if targetURL == "" {
color.Red("[-] Error: Target URL is required")
fmt.Println("\nUsage:")
flag.PrintDefaults()
fmt.Println("\nExample:")
fmt.Println(" ./blitz -url http://example.com/login")
os.Exit(1)
}
// Display legal disclaimer
printLegalDisclaimer()
// Load wordlists
usernames, err := loadWordlist(usernameFile)
if err != nil {
color.Red("[-] Failed to load usernames: %v", err)
os.Exit(1)
}
color.Green("[+] Loaded %d usernames", len(usernames))
passwords, err := loadWordlist(passwordFile)
if err != nil {
color.Red("[-] Failed to load passwords: %v", err)
os.Exit(1)
}
color.Green("[+] Loaded %d passwords", len(passwords))
// Initialize the scanner
scanner, err := NewScanner(targetURL, timeout, verbose)
if err != nil {
color.Red("[-] Failed to initialize scanner: %v", err)
os.Exit(1)
}
// Run security checks
color.Cyan("\n[*] Running security checks...")
scanner.RunSecurityChecks(skipWAF)
// Find and analyze forms
forms, err := scanner.FindForms()
if err != nil {
color.Red("[-] Failed to find forms: %v", err)
os.Exit(1)
}
if len(forms) == 0 {
color.Red("[-] No forms found on target page")
os.Exit(1)
}
color.Green("[+] Found %d form(s)", len(forms))
// Select target form
var targetForm *Form
if formIndex >= 0 && formIndex < len(forms) {
targetForm = forms[formIndex]
} else {
targetForm = selectForm(forms)
}
if targetForm == nil {
color.Red("[-] No suitable form found for testing")
os.Exit(1)
}
// Initialize brute forcer
bruteForcer := NewBruteForcer(scanner, targetForm, threads, rateLimit)
// Start brute force attack
color.Cyan("\n[*] Starting credential testing...")
color.Yellow("[!] Testing %d username(s) with %d password(s) each", len(usernames), len(passwords))
result := bruteForcer.Start(usernames, passwords)
if result != nil {
color.Green("\n[+] ✓ Valid credentials found!")
color.Green(" Username: %s", result.Username)
color.Green(" Password: %s", result.Password)
// Save results
saveResults(result)
} else {
color.Red("\n[-] No valid credentials found")
}
}
func printBanner() {
color.Cyan(banner)
}
func printLegalDisclaimer() {
color.Yellow("\nLEGAL DISCLAIMER")
color.White("This tool is designed for authorized security testing only.")
color.White("Unauthorized access to computer systems is illegal.")
color.White("You must have explicit permission to test the target system.")
color.White("\nBy using this tool, you agree that you have proper authorization.")
color.White("The author assumes NO LIABILITY for misuse or damage.\n")
}
func loadWordlist(filename string) ([]string, error) {
file, err := os.Open(filename)
if err != nil {
return nil, err
}
defer file.Close()
var lines []string
scanner := bufio.NewScanner(file)
for scanner.Scan() {
line := strings.TrimSpace(scanner.Text())
if line != "" && !strings.HasPrefix(line, "#") {
lines = append(lines, line)
}
}
if err := scanner.Err(); err != nil {
return nil, err
}
return lines, nil
}
func selectForm(forms []*Form) *Form {
color.Cyan("\n[*] Available forms:")
for i, form := range forms {
color.White(" [%d] %s", i, form.Description())
}
// Auto-select first login-like form
for _, form := range forms {
if form.UsernameField != "" && form.PasswordField != "" {
color.Green("[+] Auto-selected form with username and password fields")
return form
}
}
return nil
}
func saveResults(result *Credential) {
filename := "blitz_results.txt"
file, err := os.OpenFile(filename, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
color.Yellow("[!] Could not save results: %v", err)
return
}
defer file.Close()
output := fmt.Sprintf("\n=== Blitz Results ===\nTarget: %s\nUsername: %s\nPassword: %s\nTimestamp: %v\n",
targetURL, result.Username, result.Password, result.Timestamp)
file.WriteString(output)
color.Green("[+] Results saved to %s", filename)
}