Show RedirectLocation and full URL in output files (#97)

This commit is contained in:
Joona Hoikkala 2019-11-16 15:29:09 +02:00 committed by GitHub
parent 3ad8ce2716
commit 7b0542a5a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 43 additions and 31 deletions

View File

@ -9,7 +9,7 @@ import (
"github.com/ffuf/ffuf/pkg/ffuf" "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 { func writeCSV(config *ffuf.Config, res []Result, encode bool) error {
header := make([]string, 0) header := make([]string, 0)
@ -59,6 +59,8 @@ func toCSV(r Result) []string {
for _, v := range r.Input { for _, v := range r.Input {
res = append(res, string(v)) 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.Itoa(r.Position))
res = append(res, strconv.FormatInt(r.StatusCode, 10)) res = append(res, strconv.FormatInt(r.StatusCode, 10))
res = append(res, strconv.FormatInt(r.ContentLength, 10)) res = append(res, strconv.FormatInt(r.ContentLength, 10))

View File

@ -65,6 +65,8 @@ const (
<th>Status</th> <th>Status</th>
{{ range .Keys }} <th>{{ . }}</th> {{ range .Keys }} <th>{{ . }}</th>
{{ end }} {{ end }}
<th>URL</th>
<th>Redirect location</th>
<th>Position</th> <th>Position</th>
<th>Length</th> <th>Length</th>
<th>Words</th> <th>Words</th>
@ -75,9 +77,9 @@ const (
<tbody> <tbody>
{{range $result := .Results}} {{range $result := .Results}}
<div style="display:none"> <div style="display:none">
|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 }}|
</div> </div>
<tr class="result-{{ $result.StatusCode }}" style="background-color: {{$result.HTMLColor}};"><td><font color="black" class="status-code">{{ $result.StatusCode }}</font></td>{{ range $keyword, $value := $result.Input }}<td>{{ $value | printf "%s" }}</td>{{ end }}</td><td>{{ $result.Position }}</td><td>{{ $result.ContentLength }}</td><td>{{ $result.ContentWords }}</td><td>{{ $result.ContentLines }}</td></tr> <tr class="result-{{ $result.StatusCode }}" style="background-color: {{$result.HTMLColor}};"><td><font color="black" class="status-code">{{ $result.StatusCode }}</font></td>{{ range $keyword, $value := $result.Input }}<td>{{ $value | printf "%s" }}</td>{{ end }}</td><td>{{ $result.Url }}</td><td>{{ $result.RedirectLocation }}</td><td>{{ $result.Position }}</td><td>{{ $result.ContentLength }}</td><td>{{ $result.ContentWords }}</td><td>{{ $result.ContentLines }}</td></tr>
{{end}} {{end}}
</tbody> </tbody>
</table> </table>

View File

@ -15,12 +15,14 @@ type ejsonFileOutput struct {
} }
type JsonResult struct { type JsonResult struct {
Input map[string]string `json:"input"` Input map[string]string `json:"input"`
Position int `json:"position"` Position int `json:"position"`
StatusCode int64 `json:"status"` StatusCode int64 `json:"status"`
ContentLength int64 `json:"length"` ContentLength int64 `json:"length"`
ContentWords int64 `json:"words"` ContentWords int64 `json:"words"`
ContentLines int64 `json:"lines"` ContentLines int64 `json:"lines"`
RedirectLocation string `json:"redirectlocation"`
Url string `json:"url"`
} }
type jsonFileOutput struct { type jsonFileOutput struct {
@ -57,12 +59,14 @@ func writeJSON(config *ffuf.Config, res []Result) error {
strinput[k] = string(v) strinput[k] = string(v)
} }
jsonRes = append(jsonRes, JsonResult{ jsonRes = append(jsonRes, JsonResult{
Input: strinput, Input: strinput,
Position: r.Position, Position: r.Position,
StatusCode: r.StatusCode, StatusCode: r.StatusCode,
ContentLength: r.ContentLength, ContentLength: r.ContentLength,
ContentWords: r.ContentWords, ContentWords: r.ContentWords,
ContentLines: r.ContentLines, ContentLines: r.ContentLines,
RedirectLocation: r.RedirectLocation,
Url: r.Url,
}) })
} }
outJSON := jsonFileOutput{ outJSON := jsonFileOutput{

View File

@ -14,9 +14,9 @@ const (
Command line : ` + "`{{.CommandLine}}`" + ` Command line : ` + "`{{.CommandLine}}`" + `
Time: ` + "{{ .Time }}" + ` Time: ` + "{{ .Time }}" + `
{{ range .Keys }}| {{ . }} {{ end }}| Position | Status Code | Content Length | Content Words | Content Lines | {{ range .Keys }}| {{ . }} {{ end }}| URL | Redirectlocation | Position | Status Code | Content Length | Content Words | Content Lines |
{{ range .Keys }}| :- {{ end }}| :---- | :------- | :---------- | :------------- | :------------ | :------------ | {{ range .Keys }}| :- {{ end }}| :-- | :--------------- | :---- | :------- | :---------- | :------------- | :------------ |
{{range .Results}}{{ range $keyword, $value := .Input }}| {{ $value | printf "%s" }} {{ end }}| {{ .Position }} | {{ .StatusCode }} | {{ .ContentLength }} | {{ .ContentWords }} | {{ .ContentLines }} | {{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 {{end}}` // The template format is not pretty but follows the markdown guide
) )

View File

@ -27,13 +27,15 @@ type Stdoutput struct {
} }
type Result struct { type Result struct {
Input map[string][]byte `json:"input"` Input map[string][]byte `json:"input"`
Position int `json:"position"` Position int `json:"position"`
StatusCode int64 `json:"status"` StatusCode int64 `json:"status"`
ContentLength int64 `json:"length"` ContentLength int64 `json:"length"`
ContentWords int64 `json:"words"` ContentWords int64 `json:"words"`
ContentLines int64 `json:"lines"` ContentLines int64 `json:"lines"`
HTMLColor string `json:"-"` RedirectLocation string `json:"redirectlocation"`
Url string `json:"url"`
HTMLColor string `json:"-"`
} }
func NewStdoutput(conf *ffuf.Config) *Stdoutput { func NewStdoutput(conf *ffuf.Config) *Stdoutput {
@ -140,12 +142,14 @@ func (s *Stdoutput) Result(resp ffuf.Response) {
inputs[k] = v inputs[k] = v
} }
sResult := Result{ sResult := Result{
Input: inputs, Input: inputs,
Position: resp.Request.Position, Position: resp.Request.Position,
StatusCode: resp.StatusCode, StatusCode: resp.StatusCode,
ContentLength: resp.ContentLength, ContentLength: resp.ContentLength,
ContentWords: resp.ContentWords, ContentWords: resp.ContentWords,
ContentLines: resp.ContentLines, ContentLines: resp.ContentLines,
RedirectLocation: resp.GetRedirectLocation(),
Url: resp.Request.Url,
} }
s.Results = append(s.Results, sResult) s.Results = append(s.Results, sResult)
} }