mirror of
https://github.com/ffuf/ffuf
synced 2025-03-01 21:37:13 +00:00
Make SIGINT more responsive, and handle zombied TCP connections properly (#302)
This commit is contained in:
parent
f3bcb50e3a
commit
dc24ad2639
5 changed files with 18 additions and 4 deletions
|
@ -5,6 +5,8 @@
|
||||||
|
|
||||||
- Changed
|
- Changed
|
||||||
- Pre-flight errors are now displayed also after the usage text to prevent the need to scroll through backlog.
|
- Pre-flight errors are now displayed also after the usage text to prevent the need to scroll through backlog.
|
||||||
|
- Cancelling via SIGINT (Ctrl-C) is now more responsive
|
||||||
|
- Fixed issue where a thread would hang due to TCP errors
|
||||||
- The `-w` flag now accepts comma delimited values in the form of `file1:W1,file2:W2`.
|
- The `-w` flag now accepts comma delimited values in the form of `file1:W1,file2:W2`.
|
||||||
|
|
||||||
- v1.1.0
|
- v1.1.0
|
||||||
|
|
2
main.go
2
main.go
|
@ -82,7 +82,7 @@ func (m *wordlistFlag) Set(value string) error {
|
||||||
func main() {
|
func main() {
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
conf := ffuf.NewConfig(ctx)
|
conf := ffuf.NewConfig(ctx, cancel)
|
||||||
opts := cliOptions{}
|
opts := cliOptions{}
|
||||||
var ignored bool
|
var ignored bool
|
||||||
flag.BoolVar(&conf.IgnoreWordlistComments, "ic", false, "Ignore wordlist comments")
|
flag.BoolVar(&conf.IgnoreWordlistComments, "ic", false, "Ignore wordlist comments")
|
||||||
|
|
|
@ -35,6 +35,7 @@ type Config struct {
|
||||||
Matchers map[string]FilterProvider `json:"matchers"`
|
Matchers map[string]FilterProvider `json:"matchers"`
|
||||||
Threads int `json:"threads"`
|
Threads int `json:"threads"`
|
||||||
Context context.Context `json:"-"`
|
Context context.Context `json:"-"`
|
||||||
|
Cancel context.CancelFunc `json:"-"`
|
||||||
ProxyURL string `json:"proxyurl"`
|
ProxyURL string `json:"proxyurl"`
|
||||||
ReplayProxyURL string `json:"replayproxyurl"`
|
ReplayProxyURL string `json:"replayproxyurl"`
|
||||||
CommandLine string `json:"cmdline"`
|
CommandLine string `json:"cmdline"`
|
||||||
|
@ -52,9 +53,10 @@ type InputProviderConfig struct {
|
||||||
Value string `json:"value"`
|
Value string `json:"value"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewConfig(ctx context.Context) Config {
|
func NewConfig(ctx context.Context, cancel context.CancelFunc) Config {
|
||||||
var conf Config
|
var conf Config
|
||||||
conf.Context = ctx
|
conf.Context = ctx
|
||||||
|
conf.Cancel = cancel
|
||||||
conf.Headers = make(map[string]string)
|
conf.Headers = make(map[string]string)
|
||||||
conf.Method = "GET"
|
conf.Method = "GET"
|
||||||
conf.Url = ""
|
conf.Url = ""
|
||||||
|
|
|
@ -146,7 +146,11 @@ func (j *Job) sleepIfNeeded() {
|
||||||
}
|
}
|
||||||
sleepDuration = sleepDuration * time.Millisecond
|
sleepDuration = sleepDuration * time.Millisecond
|
||||||
}
|
}
|
||||||
time.Sleep(sleepDuration)
|
// makes the sleep cancellable by context
|
||||||
|
select {
|
||||||
|
case <-j.Config.Context.Done(): // cancelled
|
||||||
|
case <-time.After(sleepDuration): // sleep
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (j *Job) startExecution() {
|
func (j *Job) startExecution() {
|
||||||
|
@ -428,6 +432,7 @@ func (j *Job) CheckStop() {
|
||||||
//Stop the execution of the Job
|
//Stop the execution of the Job
|
||||||
func (j *Job) Stop() {
|
func (j *Job) Stop() {
|
||||||
j.Running = false
|
j.Running = false
|
||||||
|
j.Config.Cancel()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httputil"
|
"net/http/httputil"
|
||||||
"net/textproto"
|
"net/textproto"
|
||||||
|
@ -51,6 +52,10 @@ func NewSimpleRunner(conf *ffuf.Config, replay bool) ffuf.RunnerProvider {
|
||||||
MaxIdleConns: 1000,
|
MaxIdleConns: 1000,
|
||||||
MaxIdleConnsPerHost: 500,
|
MaxIdleConnsPerHost: 500,
|
||||||
MaxConnsPerHost: 500,
|
MaxConnsPerHost: 500,
|
||||||
|
DialContext: (&net.Dialer{
|
||||||
|
Timeout: time.Duration(time.Duration(conf.Timeout) * time.Second),
|
||||||
|
}).DialContext,
|
||||||
|
TLSHandshakeTimeout: time.Duration(time.Duration(conf.Timeout) * time.Second),
|
||||||
TLSClientConfig: &tls.Config{
|
TLSClientConfig: &tls.Config{
|
||||||
InsecureSkipVerify: true,
|
InsecureSkipVerify: true,
|
||||||
Renegotiation: tls.RenegotiateOnceAsClient,
|
Renegotiation: tls.RenegotiateOnceAsClient,
|
||||||
|
@ -92,7 +97,7 @@ func (r *SimpleRunner) Execute(req *ffuf.Request) (ffuf.Response, error) {
|
||||||
var err error
|
var err error
|
||||||
var rawreq []byte
|
var rawreq []byte
|
||||||
data := bytes.NewReader(req.Data)
|
data := bytes.NewReader(req.Data)
|
||||||
httpreq, err = http.NewRequest(req.Method, req.Url, data)
|
httpreq, err = http.NewRequestWithContext(r.config.Context, req.Method, req.Url, data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ffuf.Response{}, err
|
return ffuf.Response{}, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue