diff options
-rw-r--r-- | src/channel.go | 8 | ||||
-rw-r--r-- | src/flags.go | 12 | ||||
-rw-r--r-- | src/http.go | 8 | ||||
-rw-r--r-- | src/httpRequest.go | 28 | ||||
-rw-r--r-- | src/wordlist.go | 16 |
5 files changed, 51 insertions, 21 deletions
diff --git a/src/channel.go b/src/channel.go index 11a6257..fbe3190 100644 --- a/src/channel.go +++ b/src/channel.go @@ -4,7 +4,9 @@ import "log" // registerChannels creats some channels, stores them in a channels struct and returns the struct for futher usage func registerChannels() channels { - log.Printf("%s Defining channels", green("[i]")) + if verbose == true { + log.Printf("%s Defining channels", green("[i]")) + } // define the channels wordlistChannel := make(chan string) @@ -18,7 +20,9 @@ func registerChannels() channels { doneChannel: doneChannel, } - log.Printf("%s Done defining channels", boldGreen("[+]")) + if verbose == true { + log.Printf("%s Done defining channels", boldGreen("[+]")) + } return channels } diff --git a/src/flags.go b/src/flags.go index aae5004..6139eef 100644 --- a/src/flags.go +++ b/src/flags.go @@ -44,8 +44,6 @@ var ( ) func registerFlags() { - log.Printf("%s Reading flags", green("[i]")) - shortcut := " (shortcut)" // Boolean values @@ -146,7 +144,9 @@ func registerFlags() { HideChar: parseIntList(hideChar), } - log.Printf("%s Hiding: %v", cyan("[i]"), hide) + if verbose == true { + log.Printf("%s Hiding: {code: %v, line: %v, word: %v, char: %v}", cyan("[i]"), hide.HideCode, hide.HideLine, hide.HideWord, hide.HideChar) + } show = Show{ ShowCode: parseIntList(showCode), @@ -154,9 +154,9 @@ func registerFlags() { ShowWord: parseIntList(showWord), ShowChar: parseIntList(showChar), } - log.Printf("%s Showing: %v", cyan("[i]"), show) - - log.Printf("%s Done reading flags", boldGreen("[+]")) + if verbose == true { + log.Printf("%s Showing: {code: %v, line: %v, word: %v, char: %v}", cyan("[i]"), show.ShowCode, show.ShowLine, show.ShowWord, show.ShowChar) + } } // parseIntList parses the given string by spliting it at commas returning a list of all ints diff --git a/src/http.go b/src/http.go index f2518f6..d309791 100644 --- a/src/http.go +++ b/src/http.go @@ -30,13 +30,17 @@ func indexHandler(w http.ResponseWriter, r *http.Request) { func httpStartServer() { if httpServerPort != 8080 { - log.Printf("%s Starting the http server", green("[i]")) + if verbose == true { + log.Printf("%s Starting the http server", green("[i]")) + } // setup the http server and start it httpServer := setupHTTPServer() log.Fatalln(httpServer.ListenAndServe()) - log.Printf("%s Done starting the http server", boldGreen("[+]")) + if verbose == true { + log.Printf("%s Done starting the http server", boldGreen("[+]")) + } } else { return } diff --git a/src/httpRequest.go b/src/httpRequest.go index 3cc3b17..163a524 100644 --- a/src/httpRequest.go +++ b/src/httpRequest.go @@ -22,13 +22,17 @@ func httpRequest(channels channels, threadNr int) { // make the http get request resp, err := http.Get(requestURL) if err != nil { - log.Println(err) + if verbose == true { + log.Println(err) + } } else { defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { - log.Println(err) + if verbose == true { + log.Println(err) + } } responseLines := len(strings.Split(string(body), "\n")) - 1 @@ -55,7 +59,9 @@ func httpRequest(channels channels, threadNr int) { } func httpHandler(channels channels) { - log.Printf("%s Starting the http handlers", green("[i]")) + if verbose == true { + log.Printf("%s Starting the http handlers", green("[i]")) + } // handle one or more theads if threads <= 1 { @@ -63,7 +69,9 @@ func httpHandler(channels channels) { httpRequest(channels, 0) } else { - log.Printf("%s Starting %d threads...", yellow("[i]"), threads) + if verbose == true { + 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 @@ -71,13 +79,19 @@ func httpHandler(channels channels) { for i := 0; i < threads; i++ { go httpRequest(channels, i) } - log.Printf("%s Done starting %d threads", green("[i]"), threads) + if verbose == true { + log.Printf("%s Done starting %d threads", green("[i]"), threads) + } for i := 0; i < threads; i++ { threadNum := <-channels.doneChannel - fmt.Printf("Thread %d done!\n", threadNum) + if verbose == true { + fmt.Printf("Thread %d done!\n", threadNum) + } } } - log.Printf("%s Done starting the http handlers", boldGreen("[+]")) + if verbose == true { + log.Printf("%s Done starting the http handlers", boldGreen("[+]")) + } } diff --git a/src/wordlist.go b/src/wordlist.go index 4125851..431b91b 100644 --- a/src/wordlist.go +++ b/src/wordlist.go @@ -10,7 +10,9 @@ import ( // (wordlistPath) into an array returning the array and an error, if an error // occurs func readWordlist(wordlistPath string) ([]string, error) { - log.Printf("%s Reading the wordlist", green("[i]")) + if verbose == true { + log.Printf("%s Reading the wordlist", green("[i]")) + } // open the given wordlist file file, err := os.Open(wordlistPath) @@ -30,7 +32,9 @@ func readWordlist(wordlistPath string) ([]string, error) { lines = append(lines, scanner.Text()) } - log.Printf("%s Done reading the wordlist", boldGreen("[+]")) + if verbose == true { + log.Printf("%s Done reading the wordlist", boldGreen("[+]")) + } // return the lines, the line count and no error return lines, nil @@ -38,12 +42,16 @@ func readWordlist(wordlistPath string) ([]string, error) { // writeWordlistToChannel writes the given wordlist (wordlist) into the given channel (wordlistChannel) func writeWordlistToChannel(channels channels, wordlist []string) { - log.Printf("%s Starting inserting the given wordlist into the channel", green("[i]")) + 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 } - log.Printf("%s Done inserting the wordlist elements into the wordlist channel", green("[+]")) + if verbose == true { + log.Printf("%s Done inserting the wordlist elements into the wordlist channel", green("[+]")) + } } |