* adding content-type to csv and json output (#336) * added to contributors and changelog * changed 'type' to 'content-type' * added content-type for html and md output * updated changelog Co-authored-by: layton <layton@desktop-manjaro.fritz.box> Co-authored-by: Joona Hoikkala <joohoi@users.noreply.github.com>
This commit is contained in:
parent
825bd3231d
commit
0c991947a7
@ -1,6 +1,7 @@
|
||||
## Changelog
|
||||
- master
|
||||
- New
|
||||
- All output file formats now include the `Content-Type`.
|
||||
- Changed
|
||||
|
||||
- v1.2.1
|
||||
|
||||
@ -29,3 +29,4 @@
|
||||
* [seblw](https://github.com/seblw)
|
||||
* [Shaked](https://github.com/Shaked)
|
||||
* [SolomonSklash](https://github.com/SolomonSklash)
|
||||
* [l4yton](https://github.com/l4yton)
|
||||
|
||||
@ -13,6 +13,7 @@ type Response struct {
|
||||
ContentLength int64
|
||||
ContentWords int64
|
||||
ContentLines int64
|
||||
ContentType string
|
||||
Cancelled bool
|
||||
Request *Request
|
||||
Raw string
|
||||
@ -50,6 +51,7 @@ func NewResponse(httpresp *http.Response, req *Request) Response {
|
||||
var resp Response
|
||||
resp.Request = req
|
||||
resp.StatusCode = int64(httpresp.StatusCode)
|
||||
resp.ContentType = httpresp.Header.Get("Content-Type")
|
||||
resp.Headers = httpresp.Header
|
||||
resp.Cancelled = false
|
||||
resp.Raw = ""
|
||||
|
||||
@ -9,7 +9,7 @@ import (
|
||||
"github.com/ffuf/ffuf/pkg/ffuf"
|
||||
)
|
||||
|
||||
var staticheaders = []string{"url", "redirectlocation", "position", "status_code", "content_length", "content_words", "content_lines", "resultfile"}
|
||||
var staticheaders = []string{"url", "redirectlocation", "position", "status_code", "content_length", "content_words", "content_lines", "content_type", "resultfile"}
|
||||
|
||||
func writeCSV(config *ffuf.Config, res []Result, encode bool) error {
|
||||
|
||||
@ -68,6 +68,7 @@ func toCSV(r Result) []string {
|
||||
res = append(res, strconv.FormatInt(r.ContentLength, 10))
|
||||
res = append(res, strconv.FormatInt(r.ContentWords, 10))
|
||||
res = append(res, strconv.FormatInt(r.ContentLines, 10))
|
||||
res = append(res, r.ContentType)
|
||||
res = append(res, r.ResultFile)
|
||||
return res
|
||||
}
|
||||
|
||||
@ -76,7 +76,8 @@ const (
|
||||
<th>Position</th>
|
||||
<th>Length</th>
|
||||
<th>Words</th>
|
||||
<th>Lines</th>
|
||||
<th>Lines</th>
|
||||
<th>Type</th>
|
||||
<th>Resultfile</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -84,7 +85,7 @@ const (
|
||||
<tbody>
|
||||
{{range $result := .Results}}
|
||||
<div style="display:none">
|
||||
|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_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.ContentType }}|
|
||||
</div>
|
||||
<tr class="result-{{ $result.StatusCode }}" style="background-color: {{$result.HTMLColor}};">
|
||||
<td><font color="black" class="status-code">{{ $result.StatusCode }}</font></td>
|
||||
@ -96,7 +97,8 @@ const (
|
||||
<td>{{ $result.Position }}</td>
|
||||
<td>{{ $result.ContentLength }}</td>
|
||||
<td>{{ $result.ContentWords }}</td>
|
||||
<td>{{ $result.ContentLines }}</td>
|
||||
<td>{{ $result.ContentLines }}</td>
|
||||
<td>{{ $result.ContentType }}</td>
|
||||
<td>{{ $result.ResultFile }}</td>
|
||||
</tr>
|
||||
{{ end }}
|
||||
|
||||
@ -22,6 +22,7 @@ type JsonResult struct {
|
||||
ContentLength int64 `json:"length"`
|
||||
ContentWords int64 `json:"words"`
|
||||
ContentLines int64 `json:"lines"`
|
||||
ContentType string `json:"content-type"`
|
||||
RedirectLocation string `json:"redirectlocation"`
|
||||
ResultFile string `json:"resultfile"`
|
||||
Url string `json:"url"`
|
||||
@ -74,6 +75,7 @@ func writeJSON(config *ffuf.Config, res []Result) error {
|
||||
ContentLength: r.ContentLength,
|
||||
ContentWords: r.ContentWords,
|
||||
ContentLines: r.ContentLines,
|
||||
ContentType: r.ContentType,
|
||||
RedirectLocation: r.RedirectLocation,
|
||||
ResultFile: r.ResultFile,
|
||||
Url: r.Url,
|
||||
|
||||
@ -14,9 +14,9 @@ const (
|
||||
Command line : ` + "`{{.CommandLine}}`" + `
|
||||
Time: ` + "{{ .Time }}" + `
|
||||
|
||||
{{ range .Keys }}| {{ . }} {{ end }}| URL | Redirectlocation | Position | Status Code | Content Length | Content Words | Content Lines | ResultFile |
|
||||
{{ range .Keys }}| :- {{ end }}| :-- | :--------------- | :---- | :------- | :---------- | :------------- | :------------ | :--------- |
|
||||
{{range .Results}}{{ range $keyword, $value := .Input }}| {{ $value | printf "%s" }} {{ end }}| {{ .Url }} | {{ .RedirectLocation }} | {{ .Position }} | {{ .StatusCode }} | {{ .ContentLength }} | {{ .ContentWords }} | {{ .ContentLines }} | {{ .ResultFile }} |
|
||||
{{ range .Keys }}| {{ . }} {{ end }}| URL | Redirectlocation | Position | Status Code | Content Length | Content Words | Content Lines | Content Type | ResultFile |
|
||||
{{ range .Keys }}| :- {{ end }}| :-- | :--------------- | :---- | :------- | :---------- | :------------- | :------------ | :--------- | :----------- |
|
||||
{{range .Results}}{{ range $keyword, $value := .Input }}| {{ $value | printf "%s" }} {{ end }}| {{ .Url }} | {{ .RedirectLocation }} | {{ .Position }} | {{ .StatusCode }} | {{ .ContentLength }} | {{ .ContentWords }} | {{ .ContentLines }} | {{ .ContentType }} | {{ .ResultFile }} |
|
||||
{{end}}` // The template format is not pretty but follows the markdown guide
|
||||
)
|
||||
|
||||
|
||||
@ -36,6 +36,7 @@ type Result struct {
|
||||
ContentLength int64 `json:"length"`
|
||||
ContentWords int64 `json:"words"`
|
||||
ContentLines int64 `json:"lines"`
|
||||
ContentType string `json:"content-type"`
|
||||
RedirectLocation string `json:"redirectlocation"`
|
||||
Url string `json:"url"`
|
||||
ResultFile string `json:"resultfile"`
|
||||
@ -301,6 +302,7 @@ func (s *Stdoutput) Result(resp ffuf.Response) {
|
||||
ContentLength: resp.ContentLength,
|
||||
ContentWords: resp.ContentWords,
|
||||
ContentLines: resp.ContentLines,
|
||||
ContentType: resp.ContentType,
|
||||
RedirectLocation: resp.GetRedirectLocation(false),
|
||||
Url: resp.Request.Url,
|
||||
ResultFile: resp.ResultFile,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user