Add Host information to JSON output file (#223)

This commit is contained in:
Joona Hoikkala 2020-04-23 00:53:28 +03:00 committed by GitHub
parent 88720dfdc9
commit 08ec6bad2a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 4 deletions

View file

@ -11,6 +11,7 @@
- Changed - Changed
- Added tls renegotiation flag to fix #193 in http.Client - Added tls renegotiation flag to fix #193 in http.Client
- Fixed HTML report to display select/combo-box for rows per page (and increased default from 10 to 250 rows). - Fixed HTML report to display select/combo-box for rows per page (and increased default from 10 to 250 rows).
- Added Host information to JSON output file
- v1.0.2 - v1.0.2
- Changed - Changed

View file

@ -3,6 +3,7 @@ package ffuf
// Request holds the meaningful data that is passed for runner for making the query // Request holds the meaningful data that is passed for runner for making the query
type Request struct { type Request struct {
Method string Method string
Host string
Url string Url string
Headers map[string]string Headers map[string]string
Data []byte Data []byte

View file

@ -9,9 +9,10 @@ import (
) )
type ejsonFileOutput struct { type ejsonFileOutput struct {
CommandLine string `json:"commandline"` CommandLine string `json:"commandline"`
Time string `json:"time"` Time string `json:"time"`
Results []Result `json:"results"` Results []Result `json:"results"`
Config *ffuf.Config `json:"config"`
} }
type JsonResult struct { type JsonResult struct {
@ -24,6 +25,7 @@ type JsonResult struct {
RedirectLocation string `json:"redirectlocation"` RedirectLocation string `json:"redirectlocation"`
ResultFile string `json:"resultfile"` ResultFile string `json:"resultfile"`
Url string `json:"url"` Url string `json:"url"`
Host string `json:"host"`
} }
type jsonFileOutput struct { type jsonFileOutput struct {
@ -70,6 +72,7 @@ func writeJSON(config *ffuf.Config, res []Result) error {
RedirectLocation: r.RedirectLocation, RedirectLocation: r.RedirectLocation,
ResultFile: r.ResultFile, ResultFile: r.ResultFile,
Url: r.Url, Url: r.Url,
Host: r.Host,
}) })
} }
outJSON := jsonFileOutput{ outJSON := jsonFileOutput{

View file

@ -39,6 +39,7 @@ type Result struct {
RedirectLocation string `json:"redirectlocation"` RedirectLocation string `json:"redirectlocation"`
Url string `json:"url"` Url string `json:"url"`
ResultFile string `json:"resultfile"` ResultFile string `json:"resultfile"`
Host string `json:"host"`
HTMLColor string `json:"-"` HTMLColor string `json:"-"`
} }
@ -57,7 +58,7 @@ func (s *Stdoutput) Banner() error {
// Print wordlists // Print wordlists
for _, provider := range s.config.InputProviders { for _, provider := range s.config.InputProviders {
if provider.Name == "wordlist" { if provider.Name == "wordlist" {
printOption([]byte("Wordlist"), []byte(provider.Keyword + ": " + provider.Value)) printOption([]byte("Wordlist"), []byte(provider.Keyword+": "+provider.Value))
} }
} }
@ -302,6 +303,7 @@ func (s *Stdoutput) Result(resp ffuf.Response) {
RedirectLocation: resp.GetRedirectLocation(false), RedirectLocation: resp.GetRedirectLocation(false),
Url: resp.Request.Url, Url: resp.Request.Url,
ResultFile: resp.ResultFile, ResultFile: resp.ResultFile,
Host: resp.Request.Host,
} }
s.Results = append(s.Results, sResult) s.Results = append(s.Results, sResult)
} }

View file

@ -106,6 +106,8 @@ func (r *SimpleRunner) Execute(req *ffuf.Request) (ffuf.Response, error) {
if _, ok := req.Headers["Host"]; ok { if _, ok := req.Headers["Host"]; ok {
httpreq.Host = req.Headers["Host"] httpreq.Host = req.Headers["Host"]
} }
req.Host = httpreq.Host
httpreq = httpreq.WithContext(r.config.Context) httpreq = httpreq.WithContext(r.config.Context)
for k, v := range req.Headers { for k, v := range req.Headers {
httpreq.Header.Set(k, v) httpreq.Header.Set(k, v)