这是indexloc提供的服务,不要输入任何密码
Skip to content

Match both %ext% and %EXT% in DirSearch compatibility mode #81

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 24, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions pkg/input/wordlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package input
import (
"bufio"
"os"
"strings"
"regexp"

"github.com/ffuf/ffuf/pkg/ffuf"
)
Expand Down Expand Up @@ -91,11 +91,13 @@ func (w *WordlistInput) readFile(path string) error {

var data [][]byte
reader := bufio.NewScanner(file)
re := regexp.MustCompile(`(?i)%ext%`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For readability, this should get moved to the if w.config.DirSearchCompat... block

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think outside the loop is better so the regex doesn't get created for every line in the input

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely, thanks for clarification.

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 {
Expand Down