Skip to content

Commit

Permalink
Gracefully error in case stdin is used for search result (#634)
Browse files Browse the repository at this point in the history
  • Loading branch information
joohoi committed Feb 4, 2023
1 parent 643f6b8 commit c7d0fb5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
8 changes: 7 additions & 1 deletion main.go
Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions pkg/ffuf/history.go
Expand Up @@ -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 {
Expand Down

0 comments on commit c7d0fb5

Please sign in to comment.