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 // hidden defines if the value should be displayed (normally a 200 // status code) or hidden (gets printed, but the next entry overwrites the // line var hidden bool // hide some of the requests, filter using the status code for _, codeToHide := range hide.HideCode { if response.StatusCode == codeToHide { hidden = true } else { hidden = false } } for _, linesToHide := range hide.HideLine { if response.ResponseLines == linesToHide { hidden = true } else { hidden = false } } for _, wordsToHide := range hide.HideWord { if response.ResponseWords == wordsToHide { hidden = true } else { hidden = false } } for _, charsToHide := range hide.HideChar { if response.ResponseChars == charsToHide { hidden = true } else { hidden = false } } // show some of the requests, filter using the status code for _, codeToShow := range show.ShowCode { if response.StatusCode == codeToShow { hidden = false } else { hidden = true } } for _, linesToShow := range show.ShowLine { if response.ResponseLines == linesToShow { hidden = false } else { hidden = true } } for _, wordsToShow := range show.ShowWord { if response.ResponseWords == wordsToShow { hidden = false } else { hidden = true } } for _, charsToShow := range show.ShowChar { if response.ResponseChars == charsToShow { hidden = false } else { hidden = true } } // color to display the status code in (either green or red) var color string // set the prefix, postfix and color according to the hidden state if hidden == true { prefix = "" postfix = "\033[K\r" color = "red" } else { prefix = "\r\033[K" postfix = "\n" color = "green" } // statusCode string (with ansi escape codes) var statusCode string // 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("[+]")) }