Fixed behavior of wordlist:keyword separator in Windows (#240)
This commit is contained in:
parent
08ec6bad2a
commit
0633fb6b0a
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
/ffuf
|
/ffuf
|
||||||
|
.idea
|
||||||
|
|||||||
20
main.go
20
main.go
@ -10,6 +10,7 @@ import (
|
|||||||
"net/textproto"
|
"net/textproto"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -303,7 +304,24 @@ func prepareConfig(parseOpts *cliOptions, conf *ffuf.Config) error {
|
|||||||
|
|
||||||
//Prepare inputproviders
|
//Prepare inputproviders
|
||||||
for _, v := range parseOpts.wordlists {
|
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 {
|
if len(wl) == 2 {
|
||||||
conf.InputProviders = append(conf.InputProviders, ffuf.InputProviderConfig{
|
conf.InputProviders = append(conf.InputProviders, ffuf.InputProviderConfig{
|
||||||
Name: "wordlist",
|
Name: "wordlist",
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package ffuf
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
//used for random string generation in calibration function
|
//used for random string generation in calibration function
|
||||||
@ -29,3 +30,12 @@ func UniqStringSlice(inslice []string) []string {
|
|||||||
}
|
}
|
||||||
return ret
|
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 New Issue
Block a user