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"
)
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))

View file

@ -65,6 +65,8 @@ const (
<th>Status</th>
{{ range .Keys }} <th>{{ . }}</th>
{{ end }}
<th>URL</th>
<th>Redirect location</th>
<th>Position</th>
<th>Length</th>
<th>Words</th>
@ -75,9 +77,9 @@ const (
<tbody>
{{range $result := .Results}}
<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>
<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}}
</tbody>
</table>

View file

@ -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{

View file

@ -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
)

View file

@ -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)
}