From 8d057ea17747d1fbb82b3f9112ba80499d528ec0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ossi=20V=C3=A4=C3=A4n=C3=A4nen?= Date: Thu, 24 Oct 2019 13:25:07 +0300 Subject: [PATCH] Match both %ext% and %EXT% in DirSearch compatibility mode (#81) * Match both %ext% and %EXT% * Match both %ext% and %EXT% * Case insensitive regex search & replace --- pkg/input/wordlist.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/input/wordlist.go b/pkg/input/wordlist.go index be487d6..135c7f5 100644 --- a/pkg/input/wordlist.go +++ b/pkg/input/wordlist.go @@ -3,7 +3,7 @@ package input import ( "bufio" "os" - "strings" + "regexp" "github.com/ffuf/ffuf/pkg/ffuf" ) @@ -91,11 +91,13 @@ func (w *WordlistInput) readFile(path string) error { var data [][]byte reader := bufio.NewScanner(file) + re := regexp.MustCompile(`(?i)%ext%`) for reader.Scan() { if w.config.DirSearchCompat && len(w.config.Extensions) > 0 { - if strings.Index(reader.Text(), "%EXT%") != -1 { + text := []byte(reader.Text()) + if re.Match(text) { for _, ext := range w.config.Extensions { - contnt := strings.Replace(reader.Text(), "%EXT%", ext, -1) + contnt := re.ReplaceAll(text, []byte(ext)) data = append(data, []byte(contnt)) } } else {