package main import ( "fmt" "log" ) // printResponse reads a response from the printChannel, formats it and prints it func printResponses(channels channels) { var i int for { // read a response from the printChannel for further usage response := <-channels.printChannel // define a postfix: a string attached to the end of all printed // string set in the section filtering the status code cases var postfix string var prefix string // define what color should be used to print the individual status // codes var statusCode string var color string // hide some of the requests, filter using the status code for _, codeToHide := range hide.HideCode { if response.StatusCode == codeToHide { prefix = "" postfix = "\033[K\r" color = "red" } else { prefix = "\r\033[K" postfix = "\n" color = "green" } } for _, linesToHide := range hide.HideLine { if response.ResponseLines == linesToHide { prefix = "" postfix = "\033[K\r" color = "red" } else { prefix = "\r\033[K" postfix = "\n" color = "green" } } for _, wordsToHide := range hide.HideWord { if response.ResponseWords == wordsToHide { prefix = "" postfix = "\033[K\r" color = "red" } else { prefix = "\r\033[K" postfix = "\n" color = "green" } } for _, charsToHide := range hide.HideChar { if response.ResponseChars == charsToHide { prefix = "" postfix = "\033[K\r" color = "red" } else { prefix = "\r\033[K" postfix = "\n" color = "green" } } // show some of the requests, filter using the status code for _, codeToShow := range show.ShowCode { if response.StatusCode == codeToShow { prefix = "\r\033[K" postfix = "\n" color = "green" } else { prefix = "" postfix = "\033[K\r" color = "red" } } for _, linesToShow := range show.ShowLine { if response.ResponseLines == linesToShow { prefix = "\r\033[K" postfix = "\n" color = "green" } else { prefix = "" postfix = "\033[K\r" color = "red" } } for _, wordsToShow := range show.ShowWord { if response.ResponseWords == wordsToShow { prefix = "\r\033[K" postfix = "\n" color = "green" } else { prefix = "" postfix = "\033[K\r" color = "red" } } for _, charsToShow := range show.ShowChar { if response.ResponseChars == charsToShow { prefix = "\r\033[K" postfix = "\n" color = "green" } else { prefix = "" postfix = "\033[K\r" color = "red" } } // color if color == "red" { statusCode = red(fmt.Sprintf("%d", response.StatusCode)) } else if color == "green" { statusCode = green(fmt.Sprintf("%d", response.StatusCode)) } else { statusCode = cyan(fmt.Sprintf("%d", response.StatusCode)) } // print the requests fmt.Printf("%s%.7d: %s | %7d L | %7d W | %7d Ch | %s%s", prefix, i, statusCode, response.ResponseLines, response.ResponseWords, response.ResponseChars, response.FuzzWord, postfix) i++ } log.Printf("%s Done printing the responses", green("[+]")) }