Gracefully error in case stdin is used for search result (#634)

This commit is contained in:
Joona Hoikkala 2023-02-04 13:36:00 +02:00 committed by GitHub
parent 643f6b883f
commit c7d0fb5cf5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View File

@ -170,7 +170,13 @@ func main() {
if err != nil {
continue
}
printSearchResults(conf, pos, copt.Time, opts.General.Searchhash)
ok, reason := ffuf.HistoryReplayable(conf)
if ok {
printSearchResults(conf, pos, copt.Time, opts.General.Searchhash)
} else {
fmt.Printf("[ERR] Hash cannot be mapped back because %s\n", reason)
}
}
if err != nil {
fmt.Printf("[ERR] %s\n", err)

View File

@ -72,6 +72,15 @@ func SearchHash(hash string) ([]ConfigOptionsHistory, int, error) {
return coptions, int(position), err
}
func HistoryReplayable(conf *Config) (bool, string) {
for _, w := range conf.Wordlists {
if w == "-" || strings.HasPrefix(w, "-:") {
return false, "stdin input was used for one of the wordlists"
}
}
return true, ""
}
func configFromHistory(dirname string) (ConfigOptionsHistory, error) {
jsonOptions, err := os.ReadFile(filepath.Join(dirname, "options"))
if err != nil {