package main import ( "flag" "fmt" "log" "strconv" "strings" ) var ( // boolean flags color bool verbose bool dryrun bool followRedirects bool // string values proxy string url string payload string wordlist string data string header string // int values threads int delay int httpServerPort int // string values defining what request to show or hide hideCode string hideLine string hideWord string hideChar string showCode string showLine string showWord string showChar string hide Hide show Show ) func registerFlags() { shortcut := " (shortcut)" // Boolean values colorUsage := "Output with color" flag.BoolVar(&color, "color", false, colorUsage) flag.BoolVar(&color, "c", false, colorUsage+shortcut) verboseUsage := "Verbose output" flag.BoolVar(&verbose, "verbose", false, verboseUsage) flag.BoolVar(&verbose, "v", false, verboseUsage+shortcut) dryrunUsage := "Print the results of applying the requests without actually making any HTTP requests" flag.BoolVar(&dryrun, "dryrun", false, dryrunUsage) flag.BoolVar(&dryrun, "D", false, dryrunUsage+shortcut) followRedirectsUsage := "Follow HTTP redirects" flag.BoolVar(&followRedirects, "followRedirects", false, followRedirectsUsage) flag.BoolVar(&followRedirects, "L", false, followRedirectsUsage+shortcut) // Strings proxyUsage := "Proxy to use" flag.StringVar(&proxy, "proxy", "", proxyUsage) flag.StringVar(&proxy, "p", "", proxyUsage+shortcut) urlUsage := "url to use" flag.StringVar(&url, "url", "", urlUsage) flag.StringVar(&url, "u", "", urlUsage+shortcut) payloadUsage := "payload type" flag.StringVar(&payload, "payload", "file", payloadUsage) flag.StringVar(&payload, "P", "file", payloadUsage+shortcut) wordlistUsage := "wordlist path" flag.StringVar(&wordlist, "wordlist", "", wordlistUsage) flag.StringVar(&wordlist, "w", "", wordlistUsage+shortcut) headerUsage := "Define the headers to set" flag.StringVar(&header, "header", "", headerUsage) flag.StringVar(&header, "h", "", headerUsage+shortcut) // Ints threadsUsage := "Amount of threads connections to use" flag.IntVar(&threads, "threads", 1, threadsUsage) flag.IntVar(&threads, "t", 1, threadsUsage+shortcut) delayUsage := "Amount of delay in between the requests" flag.IntVar(&delay, "delay", 0, delayUsage) flag.IntVar(&delay, "d", 0, delayUsage+shortcut) httpServerPortUsage := "Port the http server exposing the findings should listen on" flag.IntVar(&httpServerPort, "httpServerPort", 8080, httpServerPortUsage) flag.IntVar(&httpServerPort, "hsp", 8080, httpServerPortUsage+shortcut) // hide / show hideCodeUsage := "Status codes to hide, comma seperated" flag.StringVar(&hideCode, "hideCode", "", hideCodeUsage) flag.StringVar(&hideCode, "hc", "", hideCodeUsage+shortcut) hideLineUsage := "Response body with given amount of words to hide, comma seperated" flag.StringVar(&hideLine, "hideLine", "", hideLineUsage) flag.StringVar(&hideLine, "hl", "", hideLineUsage+shortcut) hideWordUsage := "Response body with given amount of words to hide, comma seperated" flag.StringVar(&hideWord, "hideWord", "", hideWordUsage) flag.StringVar(&hideWord, "hw", "", hideWordUsage+shortcut) hideCharUsage := "Response body with given amount of chars to hide, comma seperated" flag.StringVar(&hideChar, "hideChar", "", hideCharUsage) flag.StringVar(&hideChar, "hch", "", hideCharUsage+shortcut) showCodeUsage := "Status codes to show, comma seperated" flag.StringVar(&showCode, "showCode", "", showCodeUsage) flag.StringVar(&showCode, "sc", "", showCodeUsage+shortcut) showLineUsage := "Response body with given amount of words to show, comma seperated" flag.StringVar(&showLine, "showLine", "", showLineUsage) flag.StringVar(&showLine, "sl", "", showLineUsage+shortcut) showWordUsage := "Response body with given amount of words to show, comma seperated" flag.StringVar(&showWord, "showWord", "", showWordUsage) flag.StringVar(&showWord, "sw", "", showWordUsage+shortcut) showCharUsage := "Response body with given amount of chars to show, comma seperated" flag.StringVar(&showChar, "showChar", "", showCharUsage) flag.StringVar(&showChar, "sch", "", showCharUsage+shortcut) // parse the flags flag.Parse() hide = Hide{ HideCode: parseIntList(hideCode), HideLine: parseIntList(hideLine), HideWord: parseIntList(hideWord), HideChar: parseIntList(hideChar), } 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), ShowLine: parseIntList(showLine), ShowWord: parseIntList(showWord), ShowChar: parseIntList(showChar), } 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 func parseIntList(inputStringList string) []int { // if the input list is empty, return an empty list if inputStringList == "" { return []int{} } // define an array to store the black or whitelisted values in var intList []int // split the input elementList := strings.Split(inputStringList, ",") // parse all elements inserting the into the intList for _, element := range elementList { rawInt, err := strconv.Atoi(element) if err != nil { fmt.Println("Could not parse: %s", err) } else { intList = append(intList, rawInt) } } // return the intList return intList }