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
This commit is contained in:
Ossi Väänänen 2019-10-24 13:25:07 +03:00 committed by Joona Hoikkala
parent 492253b67b
commit 8d057ea177

View file

@ -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 {