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) doneChannel := make(chan int) log.Printf("%s Done defining channels", green("[+]")) // write into the wordlist channel and read out of the print channel // these functions wait for input into the channels and process the given // data go writeWordlistToChannel(wordlistChannel, wordlist) go printResponses(printChannel) log.Printf("%s Done starting hander routines", green("[+]")) log.Printf("%s Starting the http handlers", cyan("[+]")) // handle one or more theads if threads <= 1 { log.Printf("%s 1 thread", yellow("[i]")) httpRequest(wordlistChannel, printChannel, nil, 0) } else { log.Printf("%s Starting %d threads...", yellow("[i]"), threads) // 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++ { go httpRequest(wordlistChannel, printChannel, doneChannel, i) } log.Printf("%s Done starting %d threads", green("[i]"), threads) for i := 0; i < threads; i++ { threadNum := <-doneChannel fmt.Printf("Thread %d done!\n", threadNum) } } }