blob: 431b91b07dc85b0b6d031b8596d0a432d433c3c9 (
plain)
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
|
package main
import (
"bufio"
"log"
"os"
)
// readWordlist reads the lines in the file located at the given path
// (wordlistPath) into an array returning the array and an error, if an error
// occurs
func readWordlist(wordlistPath string) ([]string, error) {
if verbose == true {
log.Printf("%s Reading the wordlist", green("[i]"))
}
// open the given wordlist file
file, err := os.Open(wordlistPath)
if err != nil {
return nil, err
}
defer file.Close()
// read the file content line by line
scanner := bufio.NewScanner(file)
scanner.Split(bufio.ScanLines)
// append the lines to the lines array
var lines []string
for scanner.Scan() {
lines = append(lines, scanner.Text())
}
if verbose == true {
log.Printf("%s Done reading the wordlist", boldGreen("[+]"))
}
// return the lines, the line count and no error
return lines, nil
}
// writeWordlistToChannel writes the given wordlist (wordlist) into the given channel (wordlistChannel)
func writeWordlistToChannel(channels channels, wordlist []string) {
if verbose == true {
log.Printf("%s Starting inserting the given wordlist into the channel", green("[i]"))
}
// write all the words from the wordlist into the wordlistChannel
for _, line := range wordlist {
channels.wordlistChannel <- line
}
if verbose == true {
log.Printf("%s Done inserting the wordlist elements into the wordlist channel", green("[+]"))
}
}
|