Fix HTML output (#640)

This commit is contained in:
Maxime Catrice 2023-02-19 13:41:37 +01:00 committed by GitHub
parent e952deb061
commit b2c1f9471f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -23,6 +23,8 @@ type htmlResult struct {
ResultFile string ResultFile string
Url string Url string
Host string Host string
HTMLColor string
FfufHash string
} }
type htmlFileOutput struct { type htmlFileOutput struct {
@ -82,12 +84,11 @@ const (
<table id="ffufreport"> <table id="ffufreport">
<thead> <thead>
<div style="display:none"> <div style="display:none">
|result_raw|StatusCode|Input|Position|ContentLength|ContentWords|ContentLines|ContentType|Duration|Resultfile|ScraperData| |result_raw|StatusCode{{ range $keyword := .Keys }}|{{ $keyword | printf "%s" }}{{ end }}|Url|RedirectLocation|Position|ContentLength|ContentWords|ContentLines|ContentType|Duration|Resultfile|ScraperData|FfufHash|
</div> </div>
<tr> <tr>
<th>Status</th> <th>Status</th>
{{ range .Keys }} <th>{{ . }}</th> {{ range .Keys }} <th>{{ . }}</th>{{ end }}
{{ end }}
<th>URL</th> <th>URL</th>
<th>Redirect location</th> <th>Redirect location</th>
<th>Position</th> <th>Position</th>
@ -98,13 +99,14 @@ const (
<th>Duration</th> <th>Duration</th>
<th>Resultfile</th> <th>Resultfile</th>
<th>Scraper data</th> <th>Scraper data</th>
<th>Ffuf Hash</th>
</tr> </tr>
</thead> </thead>
<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.Url }}|{{ $result.RedirectLocation }}|{{ $result.Position }}|{{ $result.ContentLength }}|{{ $result.ContentWords }}|{{ $result.ContentLines }}|{{ $result.ContentType }}| |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 }}|{{ $result.Duration }}|{{ $result.ResultFile }}|{{ $result.ScraperData }}|{{ $result.FfufHash }}|
</div> </div>
<tr class="result-{{ $result.StatusCode }}" style="background-color: {{$result.HTMLColor}};"> <tr class="result-{{ $result.StatusCode }}" style="background-color: {{$result.HTMLColor}};">
<td><font color="black" class="status-code">{{ $result.StatusCode }}</font></td> <td><font color="black" class="status-code">{{ $result.StatusCode }}</font></td>
@ -120,7 +122,8 @@ const (
<td>{{ $result.ContentType }}</td> <td>{{ $result.ContentType }}</td>
<td>{{ $result.Duration }}</td> <td>{{ $result.Duration }}</td>
<td>{{ $result.ResultFile }}</td> <td>{{ $result.ResultFile }}</td>
<td>{{ $result.ScraperData }} <td>{{ $result.ScraperData }}</td>
<td>{{ $result.FfufHash }}</td>
</tr> </tr>
{{ end }} {{ end }}
</tbody> </tbody>
@ -209,9 +212,14 @@ func writeHTML(filename string, config *ffuf.Config, results []ffuf.Result) erro
htmlResults := make([]htmlResult, 0) htmlResults := make([]htmlResult, 0)
for _, r := range results { for _, r := range results {
ffufhash := ""
strinput := make(map[string]string) strinput := make(map[string]string)
for k, v := range r.Input { for k, v := range r.Input {
strinput[k] = string(v) if k == "FFUFHASH" {
ffufhash = string(v)
} else {
strinput[k] = string(v)
}
} }
strscraper := "" strscraper := ""
for k, v := range r.ScraperData { for k, v := range r.ScraperData {
@ -242,6 +250,8 @@ func writeHTML(filename string, config *ffuf.Config, results []ffuf.Result) erro
ResultFile: r.ResultFile, ResultFile: r.ResultFile,
Url: r.Url, Url: r.Url,
Host: r.Host, Host: r.Host,
HTMLColor: r.HTMLColor,
FfufHash: ffufhash,
} }
htmlResults = append(htmlResults, hres) htmlResults = append(htmlResults, hres)
} }