mirror of
https://github.com/ffuf/ffuf
synced 2025-01-10 02:08:49 +00:00
34 lines
629 B
Go
34 lines
629 B
Go
|
package output
|
||
|
|
||
|
import (
|
||
|
"encoding/json"
|
||
|
"io/ioutil"
|
||
|
"time"
|
||
|
|
||
|
"github.com/ffuf/ffuf/pkg/ffuf"
|
||
|
)
|
||
|
|
||
|
type jsonFileOutput struct {
|
||
|
CommandLine string `json:"commandline"`
|
||
|
Time string `json:"time"`
|
||
|
Results []Result `json:"results"`
|
||
|
}
|
||
|
|
||
|
func writeJSON(config *ffuf.Config, res []Result) error {
|
||
|
t := time.Now()
|
||
|
outJSON := jsonFileOutput{
|
||
|
CommandLine: config.CommandLine,
|
||
|
Time: t.Format(time.RFC3339),
|
||
|
Results: res,
|
||
|
}
|
||
|
outBytes, err := json.Marshal(outJSON)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
err = ioutil.WriteFile(config.OutputFile, outBytes, 0644)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
return nil
|
||
|
}
|