From 7b0542a5a77300edf6e88ae7ddfa22984f958905 Mon Sep 17 00:00:00 2001 From: Joona Hoikkala Date: Sat, 16 Nov 2019 15:29:09 +0200 Subject: [PATCH] Show RedirectLocation and full URL in output files (#97) --- pkg/output/file_csv.go | 4 +++- pkg/output/file_html.go | 6 ++++-- pkg/output/file_json.go | 28 ++++++++++++++++------------ pkg/output/file_md.go | 6 +++--- pkg/output/stdout.go | 30 +++++++++++++++++------------- 5 files changed, 43 insertions(+), 31 deletions(-) diff --git a/pkg/output/file_csv.go b/pkg/output/file_csv.go index 0e50cd1..01cb582 100644 --- a/pkg/output/file_csv.go +++ b/pkg/output/file_csv.go @@ -9,7 +9,7 @@ import ( "github.com/ffuf/ffuf/pkg/ffuf" ) -var staticheaders = []string{"position", "status_code", "content_length", "content_words", "content_lines"} +var staticheaders = []string{"url", "redirectlocation", "position", "status_code", "content_length", "content_words", "content_lines"} func writeCSV(config *ffuf.Config, res []Result, encode bool) error { header := make([]string, 0) @@ -59,6 +59,8 @@ func toCSV(r Result) []string { for _, v := range r.Input { res = append(res, string(v)) } + res = append(res, r.Url) + res = append(res, r.RedirectLocation) res = append(res, strconv.Itoa(r.Position)) res = append(res, strconv.FormatInt(r.StatusCode, 10)) res = append(res, strconv.FormatInt(r.ContentLength, 10)) diff --git a/pkg/output/file_html.go b/pkg/output/file_html.go index a937631..cb9e2bd 100644 --- a/pkg/output/file_html.go +++ b/pkg/output/file_html.go @@ -65,6 +65,8 @@ const ( Status {{ range .Keys }} {{ . }} {{ end }} + URL + Redirect location Position Length Words @@ -75,9 +77,9 @@ const ( {{range $result := .Results}}
-|result_raw|{{ $result.StatusCode }}{{ range $keyword, $value := $result.Input }}|{{ $value | printf "%s" }}{{ end }}|{{ $result.Position }}|{{ $result.ContentLength }}|{{ $result.ContentWords }}|{{ $result.ContentLines }}| +|result_raw|{{ $result.StatusCode }}{{ range $keyword, $value := $result.Input }}|{{ $value | printf "%s" }}{{ end }}|{{ $result.Url }}|{{ $result.RedirectLocation }}|{{ $result.Position }}|{{ $result.ContentLength }}|{{ $result.ContentWords }}|{{ $result.ContentLines }}|
- {{ $result.StatusCode }}{{ range $keyword, $value := $result.Input }}{{ $value | printf "%s" }}{{ end }}{{ $result.Position }}{{ $result.ContentLength }}{{ $result.ContentWords }}{{ $result.ContentLines }} + {{ $result.StatusCode }}{{ range $keyword, $value := $result.Input }}{{ $value | printf "%s" }}{{ end }}{{ $result.Url }}{{ $result.RedirectLocation }}{{ $result.Position }}{{ $result.ContentLength }}{{ $result.ContentWords }}{{ $result.ContentLines }} {{end}} diff --git a/pkg/output/file_json.go b/pkg/output/file_json.go index 286fc97..e091304 100644 --- a/pkg/output/file_json.go +++ b/pkg/output/file_json.go @@ -15,12 +15,14 @@ type ejsonFileOutput struct { } type JsonResult struct { - Input map[string]string `json:"input"` - Position int `json:"position"` - StatusCode int64 `json:"status"` - ContentLength int64 `json:"length"` - ContentWords int64 `json:"words"` - ContentLines int64 `json:"lines"` + Input map[string]string `json:"input"` + Position int `json:"position"` + StatusCode int64 `json:"status"` + ContentLength int64 `json:"length"` + ContentWords int64 `json:"words"` + ContentLines int64 `json:"lines"` + RedirectLocation string `json:"redirectlocation"` + Url string `json:"url"` } type jsonFileOutput struct { @@ -57,12 +59,14 @@ func writeJSON(config *ffuf.Config, res []Result) error { strinput[k] = string(v) } jsonRes = append(jsonRes, JsonResult{ - Input: strinput, - Position: r.Position, - StatusCode: r.StatusCode, - ContentLength: r.ContentLength, - ContentWords: r.ContentWords, - ContentLines: r.ContentLines, + Input: strinput, + Position: r.Position, + StatusCode: r.StatusCode, + ContentLength: r.ContentLength, + ContentWords: r.ContentWords, + ContentLines: r.ContentLines, + RedirectLocation: r.RedirectLocation, + Url: r.Url, }) } outJSON := jsonFileOutput{ diff --git a/pkg/output/file_md.go b/pkg/output/file_md.go index b408cf0..0c13d7e 100644 --- a/pkg/output/file_md.go +++ b/pkg/output/file_md.go @@ -14,9 +14,9 @@ const ( Command line : ` + "`{{.CommandLine}}`" + ` Time: ` + "{{ .Time }}" + ` - {{ range .Keys }}| {{ . }} {{ end }}| Position | Status Code | Content Length | Content Words | Content Lines | - {{ range .Keys }}| :- {{ end }}| :---- | :------- | :---------- | :------------- | :------------ | :------------ | - {{range .Results}}{{ range $keyword, $value := .Input }}| {{ $value | printf "%s" }} {{ end }}| {{ .Position }} | {{ .StatusCode }} | {{ .ContentLength }} | {{ .ContentWords }} | {{ .ContentLines }} | + {{ range .Keys }}| {{ . }} {{ end }}| URL | Redirectlocation | Position | Status Code | Content Length | Content Words | Content Lines | + {{ range .Keys }}| :- {{ end }}| :-- | :--------------- | :---- | :------- | :---------- | :------------- | :------------ | + {{range .Results}}{{ range $keyword, $value := .Input }}| {{ $value | printf "%s" }} {{ end }}| {{ .Url }} | {{ .RedirectLocation }} | {{ .Position }} | {{ .StatusCode }} | {{ .ContentLength }} | {{ .ContentWords }} | {{ .ContentLines }} | {{end}}` // The template format is not pretty but follows the markdown guide ) diff --git a/pkg/output/stdout.go b/pkg/output/stdout.go index c8aecf7..ea3092a 100644 --- a/pkg/output/stdout.go +++ b/pkg/output/stdout.go @@ -27,13 +27,15 @@ type Stdoutput struct { } type Result struct { - Input map[string][]byte `json:"input"` - Position int `json:"position"` - StatusCode int64 `json:"status"` - ContentLength int64 `json:"length"` - ContentWords int64 `json:"words"` - ContentLines int64 `json:"lines"` - HTMLColor string `json:"-"` + Input map[string][]byte `json:"input"` + Position int `json:"position"` + StatusCode int64 `json:"status"` + ContentLength int64 `json:"length"` + ContentWords int64 `json:"words"` + ContentLines int64 `json:"lines"` + RedirectLocation string `json:"redirectlocation"` + Url string `json:"url"` + HTMLColor string `json:"-"` } func NewStdoutput(conf *ffuf.Config) *Stdoutput { @@ -140,12 +142,14 @@ func (s *Stdoutput) Result(resp ffuf.Response) { inputs[k] = v } sResult := Result{ - Input: inputs, - Position: resp.Request.Position, - StatusCode: resp.StatusCode, - ContentLength: resp.ContentLength, - ContentWords: resp.ContentWords, - ContentLines: resp.ContentLines, + Input: inputs, + Position: resp.Request.Position, + StatusCode: resp.StatusCode, + ContentLength: resp.ContentLength, + ContentWords: resp.ContentWords, + ContentLines: resp.ContentLines, + RedirectLocation: resp.GetRedirectLocation(), + Url: resp.Request.Url, } s.Results = append(s.Results, sResult) }