about summary refs log tree commit diff
path: root/src/main.go
blob: 6bb8bebf9e523ac9e91f440a18a9f04804a39ed3 (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
package main

import (
	"fmt"
	"log"
)

func main() {
	// pase the command line aguments
	registerFlags()
	log.Printf("%s Done reading flags", green("[+]"))

	// read the wordlist from a file
	wordlist, err := readWordlist(wordlist)
	if err != nil {
		log.Println(err)
	}
	log.Printf("%s Done reading the wordlist", green("[+]"))

	// define channels storing the wordlist and the responses resulting from the
	// requests
	wordlistChannel := make(chan string)
	printChannel := make(chan Response)

	// write into the wordlist channel and read out of the print channel
	go writeWordlistToChannel(wordlistChannel, wordlist)
	go printResponses(printChannel)

	log.Printf("%s Starting the http handlers", cyan("[+]"))
	// handle one or more theads
	if threads <= 1 {
		log.Printf("%s 1 thread", yellow("[+]"))
		httpRequest(wordlistChannel, printChannel)
	} else {
		log.Printf("%s multiple threads", yellow("[+]"))

		// loop over all the threads starting a go routine fetching a word from
		// the wordlistChannel, making the request and inserting the result into
		// the printChannel
		for i := 0; i < threads; i++ {
			log.Printf("%s Starting Thread %d\n", cyan("[i]"), i)
			go httpRequest(wordlistChannel, printChannel)
		}
	}

	fmt.Println(len(wordlistChannel))

	for {
		if len(wordlistChannel) > 0 {
			break
		}
	}
}