Added ignore comment option (#138)
* Added ignore comment option * Ignore blank lines & added changelog entry
This commit is contained in:
parent
e7069b945c
commit
3d8e233097
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
- master
|
- master
|
||||||
- New
|
- New
|
||||||
|
- New CLI flag `-ic` to ignore comments from wordlist.
|
||||||
- New CLI flags `-request` to specify the raw request file to build the actual request from and `-request-proto` to define the new request format.
|
- New CLI flags `-request` to specify the raw request file to build the actual request from and `-request-proto` to define the new request format.
|
||||||
- New CLI flag `-od` (output directory) to enable writing requests and responses for matched results to a file for postprocessing or debugging purposes.
|
- New CLI flag `-od` (output directory) to enable writing requests and responses for matched results to a file for postprocessing or debugging purposes.
|
||||||
- New CLI flag `-maxtime` to limit the running time of ffuf
|
- New CLI flag `-maxtime` to limit the running time of ffuf
|
||||||
|
|||||||
1
main.go
1
main.go
@ -62,6 +62,7 @@ func main() {
|
|||||||
conf := ffuf.NewConfig(ctx)
|
conf := ffuf.NewConfig(ctx)
|
||||||
opts := cliOptions{}
|
opts := cliOptions{}
|
||||||
var ignored bool
|
var ignored bool
|
||||||
|
flag.BoolVar(&conf.IgnoreWordlistComments, "ic", false, "Ignore wordlist comments")
|
||||||
flag.StringVar(&opts.extensions, "e", "", "Comma separated list of extensions to apply. Each extension provided will extend the wordlist entry once. Only extends a wordlist with (default) FUZZ keyword.")
|
flag.StringVar(&opts.extensions, "e", "", "Comma separated list of extensions to apply. Each extension provided will extend the wordlist entry once. Only extends a wordlist with (default) FUZZ keyword.")
|
||||||
flag.BoolVar(&conf.DirSearchCompat, "D", false, "DirSearch style wordlist compatibility mode. Used in conjunction with -e flag. Replaces %EXT% in wordlist entry with each of the extensions provided by -e.")
|
flag.BoolVar(&conf.DirSearchCompat, "D", false, "DirSearch style wordlist compatibility mode. Used in conjunction with -e flag. Replaces %EXT% in wordlist entry with each of the extensions provided by -e.")
|
||||||
flag.Var(&opts.headers, "H", "Header `\"Name: Value\"`, separated by colon. Multiple -H flags are accepted.")
|
flag.Var(&opts.headers, "H", "Header `\"Name: Value\"`, separated by colon. Multiple -H flags are accepted.")
|
||||||
|
|||||||
@ -20,6 +20,7 @@ type Config struct {
|
|||||||
OutputDirectory string `json:"outputdirectory"`
|
OutputDirectory string `json:"outputdirectory"`
|
||||||
OutputFile string `json:"outputfile"`
|
OutputFile string `json:"outputfile"`
|
||||||
OutputFormat string `json:"outputformat"`
|
OutputFormat string `json:"outputformat"`
|
||||||
|
IgnoreWordlistComments bool `json:"ignore_wordlist_comments"`
|
||||||
StopOn403 bool `json:"stop_403"`
|
StopOn403 bool `json:"stop_403"`
|
||||||
StopOnErrors bool `json:"stop_errors"`
|
StopOnErrors bool `json:"stop_errors"`
|
||||||
StopOnAll bool `json:"stop_all"`
|
StopOnAll bool `json:"stop_all"`
|
||||||
@ -55,6 +56,7 @@ func NewConfig(ctx context.Context) Config {
|
|||||||
conf.Url = ""
|
conf.Url = ""
|
||||||
conf.Data = ""
|
conf.Data = ""
|
||||||
conf.Quiet = false
|
conf.Quiet = false
|
||||||
|
conf.IgnoreWordlistComments = false
|
||||||
conf.StopOn403 = false
|
conf.StopOn403 = false
|
||||||
conf.StopOnErrors = false
|
conf.StopOnErrors = false
|
||||||
conf.StopOnAll = false
|
conf.StopOnAll = false
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/ffuf/ffuf/pkg/ffuf"
|
"github.com/ffuf/ffuf/pkg/ffuf"
|
||||||
)
|
)
|
||||||
@ -106,6 +107,7 @@ func (w *WordlistInput) readFile(path string) error {
|
|||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|
||||||
var data [][]byte
|
var data [][]byte
|
||||||
|
var ok bool
|
||||||
reader := bufio.NewScanner(file)
|
reader := bufio.NewScanner(file)
|
||||||
re := regexp.MustCompile(`(?i)%ext%`)
|
re := regexp.MustCompile(`(?i)%ext%`)
|
||||||
for reader.Scan() {
|
for reader.Scan() {
|
||||||
@ -117,13 +119,29 @@ func (w *WordlistInput) readFile(path string) error {
|
|||||||
data = append(data, []byte(contnt))
|
data = append(data, []byte(contnt))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
data = append(data, []byte(reader.Text()))
|
text := reader.Text()
|
||||||
|
|
||||||
|
if w.config.IgnoreWordlistComments {
|
||||||
|
text, ok = stripComments(text)
|
||||||
|
if !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
data = append(data, []byte(text))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
data = append(data, []byte(reader.Text()))
|
text := reader.Text()
|
||||||
|
|
||||||
|
if w.config.IgnoreWordlistComments {
|
||||||
|
text, ok = stripComments(text)
|
||||||
|
if !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
data = append(data, []byte(text))
|
||||||
if w.keyword == "FUZZ" && len(w.config.Extensions) > 0 {
|
if w.keyword == "FUZZ" && len(w.config.Extensions) > 0 {
|
||||||
for _, ext := range w.config.Extensions {
|
for _, ext := range w.config.Extensions {
|
||||||
data = append(data, []byte(reader.Text()+ext))
|
data = append(data, []byte(text+ext))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -131,3 +149,20 @@ func (w *WordlistInput) readFile(path string) error {
|
|||||||
w.data = data
|
w.data = data
|
||||||
return reader.Err()
|
return reader.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// stripComments removes all kind of comments from the word
|
||||||
|
func stripComments(text string) (string, bool) {
|
||||||
|
// If the line starts with a # ignoring any space on the left,
|
||||||
|
// return blank.
|
||||||
|
if strings.HasPrefix(strings.TrimLeft(text, " "), "#") {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the line has # later after a space, that's a comment.
|
||||||
|
// Only send the word upto space to the routine.
|
||||||
|
index := strings.Index(text, " #")
|
||||||
|
if index == -1 {
|
||||||
|
return text, true
|
||||||
|
}
|
||||||
|
return text[:index], true
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user