Colors
This commit is contained in:
parent
cee6b2f25b
commit
36a0a103e7
1
main.go
1
main.go
@ -51,6 +51,7 @@ func main() {
|
|||||||
flag.StringVar(&opts.filterStatus, "fc", "", "Filter HTTP status codes from response")
|
flag.StringVar(&opts.filterStatus, "fc", "", "Filter HTTP status codes from response")
|
||||||
flag.StringVar(&opts.filterSize, "fs", "", "Filter HTTP response size")
|
flag.StringVar(&opts.filterSize, "fs", "", "Filter HTTP response size")
|
||||||
flag.StringVar(&conf.Data, "d", "", "POST data.")
|
flag.StringVar(&conf.Data, "d", "", "POST data.")
|
||||||
|
flag.BoolVar(&conf.Colors, "c", false, "Colorize output.")
|
||||||
//flag.StringVar(&opts.filterRegex, "fr", "", "Filter regex")
|
//flag.StringVar(&opts.filterRegex, "fr", "", "Filter regex")
|
||||||
//flag.StringVar(&opts.filterReflect, "fref", "", "Filter reflected payload")
|
//flag.StringVar(&opts.filterReflect, "fref", "", "Filter reflected payload")
|
||||||
flag.StringVar(&opts.matcherStatus, "mc", "200,204,301,302,307,401", "Match HTTP status codes from respose")
|
flag.StringVar(&opts.matcherStatus, "mc", "200,204,301,302,307,401", "Match HTTP status codes from respose")
|
||||||
|
|||||||
@ -12,6 +12,7 @@ type Config struct {
|
|||||||
TLSSkipVerify bool
|
TLSSkipVerify bool
|
||||||
Data string
|
Data string
|
||||||
Quiet bool
|
Quiet bool
|
||||||
|
Colors bool
|
||||||
Wordlist string
|
Wordlist string
|
||||||
Filters []FilterProvider
|
Filters []FilterProvider
|
||||||
Matchers []FilterProvider
|
Matchers []FilterProvider
|
||||||
|
|||||||
@ -70,6 +70,11 @@ func (j *Job) runProgress(wg *sync.WaitGroup) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (j *Job) updateProgress() {
|
func (j *Job) updateProgress() {
|
||||||
|
//TODO: refactor to use a defined progress struct for future output modules
|
||||||
|
if j.Config.Quiet {
|
||||||
|
// Do not print progress status in silent mode
|
||||||
|
return
|
||||||
|
}
|
||||||
dur := time.Now().Sub(j.startTime)
|
dur := time.Now().Sub(j.startTime)
|
||||||
hours := dur / time.Hour
|
hours := dur / time.Hour
|
||||||
dur -= hours * time.Hour
|
dur -= hours * time.Hour
|
||||||
|
|||||||
@ -4,4 +4,9 @@ package output
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
TERMINAL_CLEAR_LINE = "\r\x1b[2K"
|
TERMINAL_CLEAR_LINE = "\r\x1b[2K"
|
||||||
|
ANSI_CLEAR = "\x1b[0m"
|
||||||
|
ANSI_RED = "\x1b[31m"
|
||||||
|
ANSI_GREEN = "\x1b[32m"
|
||||||
|
ANSI_BLUE = "\x1b[34m"
|
||||||
|
ANSI_YELLOW = "\x1b[33m"
|
||||||
)
|
)
|
||||||
|
|||||||
@ -4,4 +4,9 @@ package output
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
TERMINAL_CLEAR_LINE = "\r\r"
|
TERMINAL_CLEAR_LINE = "\r\r"
|
||||||
|
ANSI_CLEAR = ""
|
||||||
|
ANSI_RED = ""
|
||||||
|
ANSI_GREEN = ""
|
||||||
|
ANSI_BLUE = ""
|
||||||
|
ANSI_YELLOW = ""
|
||||||
)
|
)
|
||||||
|
|||||||
@ -98,10 +98,30 @@ func (s *Stdoutput) resultQuiet(resp ffuf.Response) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Stdoutput) resultNormal(resp ffuf.Response) {
|
func (s *Stdoutput) resultNormal(resp ffuf.Response) {
|
||||||
res_str := fmt.Sprintf("%s%-23s [Status: %d, Size: %d]", TERMINAL_CLEAR_LINE, resp.Request.Input, resp.StatusCode, resp.ContentLength)
|
res_str := fmt.Sprintf("%s%-23s [Status: %s, Size: %d]", TERMINAL_CLEAR_LINE, resp.Request.Input, s.colorizeStatus(resp.StatusCode), resp.ContentLength)
|
||||||
fmt.Println(res_str)
|
fmt.Println(res_str)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Stdoutput) colorizeStatus(status int64) string {
|
||||||
|
if !s.config.Colors {
|
||||||
|
return fmt.Sprintf("%d", status)
|
||||||
|
}
|
||||||
|
colorCode := ANSI_CLEAR
|
||||||
|
if status >= 200 && status < 300 {
|
||||||
|
colorCode = ANSI_GREEN
|
||||||
|
}
|
||||||
|
if status >= 300 && status < 400 {
|
||||||
|
colorCode = ANSI_BLUE
|
||||||
|
}
|
||||||
|
if status >= 400 && status < 500 {
|
||||||
|
colorCode = ANSI_YELLOW
|
||||||
|
}
|
||||||
|
if status >= 500 && status < 600 {
|
||||||
|
colorCode = ANSI_RED
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("%s%d%s", colorCode, status, ANSI_CLEAR)
|
||||||
|
}
|
||||||
|
|
||||||
func printOption(name []byte, value []byte) {
|
func printOption(name []byte, value []byte) {
|
||||||
fmt.Printf(" :: %-12s : %s\n", name, value)
|
fmt.Printf(" :: %-12s : %s\n", name, value)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -64,6 +64,10 @@ func (r *SimpleRunner) Execute(req *ffuf.Request) (ffuf.Response, error) {
|
|||||||
if _, ok := req.Headers["User-Agent"]; !ok {
|
if _, ok := req.Headers["User-Agent"]; !ok {
|
||||||
req.Headers["User-Agent"] = fmt.Sprintf("%s v%s", "Fuzz Faster U Fool", ffuf.VERSION)
|
req.Headers["User-Agent"] = fmt.Sprintf("%s v%s", "Fuzz Faster U Fool", ffuf.VERSION)
|
||||||
}
|
}
|
||||||
|
// Handle Go http.Request special cases
|
||||||
|
if _, ok := req.Headers["Host"]; ok {
|
||||||
|
httpreq.Host = req.Headers["Host"]
|
||||||
|
}
|
||||||
httpreq = httpreq.WithContext(r.config.Context)
|
httpreq = httpreq.WithContext(r.config.Context)
|
||||||
for k, v := range req.Headers {
|
for k, v := range req.Headers {
|
||||||
httpreq.Header.Set(k, v)
|
httpreq.Header.Set(k, v)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user