mirror of
https://github.com/ffuf/ffuf
synced 2025-01-10 02:08:49 +00:00
5456a37f72
* Multiple wordlist support * Display error correctly if wordlist file could not be opened * Add back the redirect location * Support multiple keywords in HTML output and fix wordlist positioning * Support multiple wordlists for md output * Support multiple keywords in CSV output * Improve output for multi keyword runs * Add changelog entry * Switch the wordlist filename <-> keyword around to allow tab completion * Fix the usage example in README
66 lines
1.6 KiB
Go
66 lines
1.6 KiB
Go
package input
|
|
|
|
import (
|
|
"github.com/ffuf/ffuf/pkg/ffuf"
|
|
)
|
|
|
|
type MainInputProvider struct {
|
|
Providers []ffuf.InternalInputProvider
|
|
Config *ffuf.Config
|
|
position int
|
|
}
|
|
|
|
func NewInputProvider(conf *ffuf.Config) ffuf.InputProvider {
|
|
return &MainInputProvider{Config: conf}
|
|
}
|
|
|
|
func (i *MainInputProvider) AddProvider(provider ffuf.InputProviderConfig) error {
|
|
if provider.Name == "command" {
|
|
newcomm, _ := NewCommandInput(provider.Keyword, provider.Value, i.Config)
|
|
i.Providers = append(i.Providers, newcomm)
|
|
} else {
|
|
// Default to wordlist
|
|
newwl, err := NewWordlistInput(provider.Keyword, provider.Value, i.Config)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
i.Providers = append(i.Providers, newwl)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
//Position will return the current position of progress
|
|
func (i *MainInputProvider) Position() int {
|
|
return i.position
|
|
}
|
|
|
|
//Next will increment the cursor position, and return a boolean telling if there's inputs left
|
|
func (i *MainInputProvider) Next() bool {
|
|
if i.position >= i.Total() {
|
|
return false
|
|
}
|
|
i.position++
|
|
return true
|
|
}
|
|
|
|
//Value returns a map of keyword:value pairs including all inputs
|
|
func (i *MainInputProvider) Value() map[string][]byte {
|
|
values := make(map[string][]byte)
|
|
for _, p := range i.Providers {
|
|
if !p.Next() {
|
|
// Loop to beginning if the inputprovider has been exhausted
|
|
p.ResetPosition()
|
|
}
|
|
values[p.Keyword()] = p.Value()
|
|
}
|
|
return values
|
|
}
|
|
|
|
//Total returns the amount of input combinations available
|
|
func (i *MainInputProvider) Total() int {
|
|
count := 1
|
|
for _, p := range i.Providers {
|
|
count = count * p.Total()
|
|
}
|
|
return count
|
|
}
|