Add cert authentication to crawl (#713)
* Add cert authentication to crawl * Update CONTRIBUTORS.md * Update CONTRIBUTORS.md
This commit is contained in:
parent
ca2224c148
commit
301968cb1c
@ -41,6 +41,7 @@
|
|||||||
* [putsi](https://github.com/putsi)
|
* [putsi](https://github.com/putsi)
|
||||||
* [SakiiR](https://github.com/SakiiR)
|
* [SakiiR](https://github.com/SakiiR)
|
||||||
* [seblw](https://github.com/seblw)
|
* [seblw](https://github.com/seblw)
|
||||||
|
* [Serizao](https://github.com/Serizao)
|
||||||
* [Shaked](https://github.com/Shaked)
|
* [Shaked](https://github.com/Shaked)
|
||||||
* [Skyehopper](https://github.com/Skyehopper)
|
* [Skyehopper](https://github.com/Skyehopper)
|
||||||
* [SolomonSklash](https://github.com/SolomonSklash)
|
* [SolomonSklash](https://github.com/SolomonSklash)
|
||||||
|
|||||||
2
main.go
2
main.go
@ -89,6 +89,8 @@ func ParseFlags(opts *ffuf.ConfigOptions) *ffuf.ConfigOptions {
|
|||||||
flag.IntVar(&opts.HTTP.Timeout, "timeout", opts.HTTP.Timeout, "HTTP request timeout in seconds.")
|
flag.IntVar(&opts.HTTP.Timeout, "timeout", opts.HTTP.Timeout, "HTTP request timeout in seconds.")
|
||||||
flag.IntVar(&opts.Input.InputNum, "input-num", opts.Input.InputNum, "Number of inputs to test. Used in conjunction with --input-cmd.")
|
flag.IntVar(&opts.Input.InputNum, "input-num", opts.Input.InputNum, "Number of inputs to test. Used in conjunction with --input-cmd.")
|
||||||
flag.StringVar(&opts.General.AutoCalibrationKeyword, "ack", opts.General.AutoCalibrationKeyword, "Autocalibration keyword")
|
flag.StringVar(&opts.General.AutoCalibrationKeyword, "ack", opts.General.AutoCalibrationKeyword, "Autocalibration keyword")
|
||||||
|
flag.StringVar(&opts.HTTP.ClientCert, "cc", "", "Client cert to auth must be define with client key too")
|
||||||
|
flag.StringVar(&opts.HTTP.ClientKey, "ck", "", "Client key to auth must be define with client cert too")
|
||||||
flag.StringVar(&opts.General.AutoCalibrationStrategy, "acs", opts.General.AutoCalibrationStrategy, "Autocalibration strategy: \"basic\" or \"advanced\"")
|
flag.StringVar(&opts.General.AutoCalibrationStrategy, "acs", opts.General.AutoCalibrationStrategy, "Autocalibration strategy: \"basic\" or \"advanced\"")
|
||||||
flag.StringVar(&opts.General.ConfigFile, "config", "", "Load configuration from a file")
|
flag.StringVar(&opts.General.ConfigFile, "config", "", "Load configuration from a file")
|
||||||
flag.StringVar(&opts.General.ScraperFile, "scraperfile", "", "Custom scraper file path")
|
flag.StringVar(&opts.General.ScraperFile, "scraperfile", "", "Custom scraper file path")
|
||||||
|
|||||||
@ -64,6 +64,8 @@ type Config struct {
|
|||||||
Verbose bool `json:"verbose"`
|
Verbose bool `json:"verbose"`
|
||||||
Wordlists []string `json:"wordlists"`
|
Wordlists []string `json:"wordlists"`
|
||||||
Http2 bool `json:"http2"`
|
Http2 bool `json:"http2"`
|
||||||
|
ClientCert string `json:"client-cert"`
|
||||||
|
ClientKey string `json:"client-key"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type InputProviderConfig struct {
|
type InputProviderConfig struct {
|
||||||
|
|||||||
@ -41,6 +41,8 @@ type HTTPOptions struct {
|
|||||||
Timeout int `json:"timeout"`
|
Timeout int `json:"timeout"`
|
||||||
URL string `json:"url"`
|
URL string `json:"url"`
|
||||||
Http2 bool `json:"http2"`
|
Http2 bool `json:"http2"`
|
||||||
|
ClientCert string `json:"client-cert"`
|
||||||
|
ClientKey string `json:"client-key"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GeneralOptions struct {
|
type GeneralOptions struct {
|
||||||
@ -361,6 +363,15 @@ func ConfigFromOptions(parseOpts *ConfigOptions, ctx context.Context, cancel con
|
|||||||
conf.SNI = parseOpts.HTTP.SNI
|
conf.SNI = parseOpts.HTTP.SNI
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// prepare cert
|
||||||
|
if parseOpts.HTTP.ClientCert != "" {
|
||||||
|
conf.ClientCert = parseOpts.HTTP.ClientCert
|
||||||
|
}
|
||||||
|
if parseOpts.HTTP.ClientKey != "" {
|
||||||
|
conf.ClientKey = parseOpts.HTTP.ClientKey
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//Prepare headers and make canonical
|
//Prepare headers and make canonical
|
||||||
for _, v := range parseOpts.HTTP.Headers {
|
for _, v := range parseOpts.HTTP.Headers {
|
||||||
hs := strings.SplitN(v, ":", 2)
|
hs := strings.SplitN(v, ":", 2)
|
||||||
|
|||||||
@ -43,6 +43,13 @@ func NewSimpleRunner(conf *ffuf.Config, replay bool) ffuf.RunnerProvider {
|
|||||||
proxyURL = http.ProxyURL(pu)
|
proxyURL = http.ProxyURL(pu)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
cert := []tls.Certificate{}
|
||||||
|
|
||||||
|
if conf.ClientCert != "" && conf.ClientKey != "" {
|
||||||
|
tmp, _ := tls.LoadX509KeyPair(conf.ClientCert, conf.ClientKey)
|
||||||
|
cert = []tls.Certificate{tmp}
|
||||||
|
}
|
||||||
|
|
||||||
simplerunner.config = conf
|
simplerunner.config = conf
|
||||||
simplerunner.client = &http.Client{
|
simplerunner.client = &http.Client{
|
||||||
CheckRedirect: func(req *http.Request, via []*http.Request) error { return http.ErrUseLastResponse },
|
CheckRedirect: func(req *http.Request, via []*http.Request) error { return http.ErrUseLastResponse },
|
||||||
@ -62,6 +69,7 @@ func NewSimpleRunner(conf *ffuf.Config, replay bool) ffuf.RunnerProvider {
|
|||||||
MinVersion: tls.VersionTLS10,
|
MinVersion: tls.VersionTLS10,
|
||||||
Renegotiation: tls.RenegotiateOnceAsClient,
|
Renegotiation: tls.RenegotiateOnceAsClient,
|
||||||
ServerName: conf.SNI,
|
ServerName: conf.SNI,
|
||||||
|
Certificates: cert,
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user