| 1 | package outputscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/ |
| 2 | |
| 3 | import ( |
| 4 | "html/templatescip-go gomod github.com/golang/go/src go1.18 `html/template`/" |
| 5 | "osscip-go gomod github.com/golang/go/src go1.18 os/" |
| 6 | "timescip-go gomod github.com/golang/go/src go1.18 time/" |
| 7 | |
| 8 | "github.com/ffuf/ffuf/v2/pkg/ffufscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/" |
| 9 | ) |
| 10 | |
| 11 | const ( |
| 12 | markdownTemplatescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/markdownTemplate. = `# FFUF Report |
| 13 | |
| 14 | Command line : ` + "`{{.CommandLine}}`" + ` |
| 15 | Time: ` + "{{ .Time }}" + ` |
| 16 | |
| 17 | {{ range .Keys }}| {{ . }} {{ end }}| URL | Redirectlocation | Position | Status Code | Content Length | Content Words | Content Lines | Content Type | Duration | ResultFile | ScraperData | Ffufhash |
| 18 | {{ range .Keys }}| :- {{ end }}| :-- | :--------------- | :---- | :------- | :---------- | :------------- | :------------ | :--------- | :----------- | :------------ | :-------- | |
| 19 | {{range .Results}}{{ range $keyword, $value := .Input }}| {{ $value | printf "%s" }} {{ end }}| {{ .Url }} | {{ .RedirectLocation }} | {{ .Position }} | {{ .StatusCode }} | {{ .ContentLength }} | {{ .ContentWords }} | {{ .ContentLines }} | {{ .ContentType }} | {{ .Duration}} | {{ .ResultFile }} | {{ .ScraperData }} | {{ .FfufHash }} |
| 20 | {{end}}` // The template format is not pretty but follows the markdown guide |
| 21 | ) |
| 22 | |
| 23 | func writeMarkdownscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/writeMarkdown().(filename string, config *ffufscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/.Configscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Config#, results []ffufscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/.Resultscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#) error { |
| 24 | ti := timescip-go gomod github.com/golang/go/src go1.18 time/.Nowscip-go gomod github.com/golang/go/src go1.18 time/Now().() |
| 25 | |
| 26 | keywords := make([]string, 0) |
| 27 | for _, inputprovider := range config.InputProvidersscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Config#InputProviders. { |
| 28 | keywords = append(keywords, inputprovider.Keywordscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/InputProviderConfig#Keyword.) |
| 29 | } |
| 30 | |
| 31 | htmlResults := make([]htmlResultscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult#, 0) |
| 32 | |
| 33 | ffufhash := "" |
| 34 | for _, r := range results { |
| 35 | strinput := make(map[string]string) |
| 36 | for k, v := range r.Inputscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#Input. { |
| 37 | if k == "FFUFHASH" { |
| 38 | ffufhash = string(v) |
| 39 | } else { |
| 40 | strinput[k] = string(v) |
| 41 | } |
| 42 | } |
| 43 | strscraper := "" |
| 44 | for k, v := range r.ScraperDatascip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#ScraperData. { |
| 45 | if len(v) > 0 { |
| 46 | strscraper = strscraper + "<p><b>" + k + ":</b><br />" |
| 47 | firstval := true |
| 48 | for _, val := range v { |
| 49 | if !firstval { |
| 50 | strscraper += "<br />" |
| 51 | } |
| 52 | strscraper += val |
| 53 | firstval = false |
| 54 | } |
| 55 | strscraper += "</p>" |
| 56 | } |
| 57 | } |
| 58 | hres := htmlResultscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult#{ |
| 59 | Inputscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult#Input.: strinput, |
| 60 | Positionscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult#Position.: r.Positionscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#Position., |
| 61 | StatusCodescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult#StatusCode.: r.StatusCodescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#StatusCode., |
| 62 | ContentLengthscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult#ContentLength.: r.ContentLengthscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#ContentLength., |
| 63 | ContentWordsscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult#ContentWords.: r.ContentWordsscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#ContentWords., |
| 64 | ContentLinesscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult#ContentLines.: r.ContentLinesscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#ContentLines., |
| 65 | ContentTypescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult#ContentType.: r.ContentTypescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#ContentType., |
| 66 | RedirectLocationscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult#RedirectLocation.: r.RedirectLocationscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#RedirectLocation., |
| 67 | ScraperDatascip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult#ScraperData.: strscraper, |
| 68 | Durationscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult#Duration.: r.Durationscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#Duration., |
| 69 | ResultFilescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult#ResultFile.: r.ResultFilescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#ResultFile., |
| 70 | Urlscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult#Url.: r.Urlscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#Url., |
| 71 | Hostscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult#Host.: r.Hostscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#Host., |
| 72 | FfufHashscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult#FfufHash.: ffufhash, |
| 73 | } |
| 74 | htmlResults = append(htmlResults, hres) |
| 75 | } |
| 76 | |
| 77 | outMD := htmlFileOutputscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlFileOutput#{ |
| 78 | CommandLinescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlFileOutput#CommandLine.: config.CommandLinescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Config#CommandLine., |
| 79 | Timescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlFileOutput#Time.: ti.Formatscip-go gomod github.com/golang/go/src go1.18 time/Time#Format().(timescip-go gomod github.com/golang/go/src go1.18 time/.RFC3339scip-go gomod github.com/golang/go/src go1.18 time/RFC3339.), |
| 80 | Resultsscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlFileOutput#Results.: htmlResults, |
| 81 | Keysscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlFileOutput#Keys.: keywords, |
| 82 | } |
| 83 | |
| 84 | f, err := osscip-go gomod github.com/golang/go/src go1.18 os/.Createscip-go gomod github.com/golang/go/src go1.18 os/Create().(filename) |
| 85 | if err != nil { |
| 86 | return err |
| 87 | } |
| 88 | defer f.Closescip-go gomod github.com/golang/go/src go1.18 os/File#Close().() |
| 89 | |
| 90 | templateName := "output.md" |
| 91 | t := templatescip-go gomod github.com/golang/go/src go1.18 `html/template`/.Newscip-go gomod github.com/golang/go/src go1.18 `html/template`/New().(templateName).Delimsscip-go gomod github.com/golang/go/src go1.18 `html/template`/Template#Delims().("{{", "}}") |
| 92 | _, err = t.Parsescip-go gomod github.com/golang/go/src go1.18 `html/template`/Template#Parse().(markdownTemplatescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/markdownTemplate.) |
| 93 | if err != nil { |
| 94 | return err |
| 95 | } |
| 96 | err = t.Executescip-go gomod github.com/golang/go/src go1.18 `html/template`/Template#Execute().(f, outMD) |
| 97 | return err |
| 98 | } |