mirror of
https://github.com/ffuf/ffuf
synced 2024-11-21 19:23:08 +00:00
Fixed behavior of wordlist:keyword separator in Windows (#240)
This commit is contained in:
parent
08ec6bad2a
commit
0633fb6b0a
3 changed files with 30 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1 +1,2 @@
|
|||
/ffuf
|
||||
.idea
|
||||
|
|
20
main.go
20
main.go
|
@ -10,6 +10,7 @@ import (
|
|||
"net/textproto"
|
||||
"net/url"
|
||||
"os"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
|
@ -303,7 +304,24 @@ func prepareConfig(parseOpts *cliOptions, conf *ffuf.Config) error {
|
|||
|
||||
//Prepare inputproviders
|
||||
for _, v := range parseOpts.wordlists {
|
||||
wl := strings.SplitN(v, ":", 2)
|
||||
var wl []string
|
||||
if runtime.GOOS == "windows" {
|
||||
// Try to ensure that Windows file paths like C:\path\to\wordlist.txt:KEYWORD are treated properly
|
||||
if ffuf.FileExists(v) {
|
||||
// The wordlist was supplied without a keyword parameter
|
||||
wl = []string{v}
|
||||
} else {
|
||||
filepart := v[:strings.LastIndex(v, ":")]
|
||||
if ffuf.FileExists(filepart) {
|
||||
wl = []string{filepart, v[strings.LastIndex(v, ":")+1:]}
|
||||
} else {
|
||||
// The file was not found. Use full wordlist parameter value for more concise error message down the line
|
||||
wl = []string{v}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
wl = strings.SplitN(v, ":", 2)
|
||||
}
|
||||
if len(wl) == 2 {
|
||||
conf.InputProviders = append(conf.InputProviders, ffuf.InputProviderConfig{
|
||||
Name: "wordlist",
|
||||
|
|
|
@ -2,6 +2,7 @@ package ffuf
|
|||
|
||||
import (
|
||||
"math/rand"
|
||||
"os"
|
||||
)
|
||||
|
||||
//used for random string generation in calibration function
|
||||
|
@ -29,3 +30,12 @@ func UniqStringSlice(inslice []string) []string {
|
|||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
//FileExists checks if the filepath exists and is not a directory
|
||||
func FileExists(path string) bool {
|
||||
md, err := os.Stat(path)
|
||||
if os.IsNotExist(err) {
|
||||
return false
|
||||
}
|
||||
return !md.IsDir()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue