Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding trace #1883

Merged
merged 8 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common/httpx/httpx.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func New(options *Options) (*HTTPX, error) {
var retryablehttpOptions = retryablehttp.DefaultOptionsSpraying
retryablehttpOptions.Timeout = httpx.Options.Timeout
retryablehttpOptions.RetryMax = httpx.Options.RetryMax

retryablehttpOptions.Trace = options.Trace
handleHSTS := func(req *http.Request) {
if req.Response.Header.Get("Strict-Transport-Security") == "" {
return
Expand Down
1 change: 1 addition & 0 deletions common/httpx/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ type Options struct {
NetworkPolicy *networkpolicy.NetworkPolicy
CDNCheckClient *cdncheck.Client
Protocol Proto
Trace bool
}

// DefaultOptions contains the default options
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ require (
github.com/projectdiscovery/networkpolicy v0.0.9
github.com/projectdiscovery/ratelimit v0.0.49
github.com/projectdiscovery/rawhttp v0.1.63
github.com/projectdiscovery/retryablehttp-go v1.0.75
github.com/projectdiscovery/retryablehttp-go v1.0.76-0.20240826132304-648e6e6f3a4c
github.com/projectdiscovery/tlsx v1.1.6
github.com/projectdiscovery/useragent v0.0.68
github.com/projectdiscovery/utils v0.2.7
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,8 @@ github.com/projectdiscovery/rawhttp v0.1.63 h1:1MYB+2jFIF+KY7YpevBQebWGKsUixZh1f
github.com/projectdiscovery/rawhttp v0.1.63/go.mod h1:nKAUkg61DfonVFnVeFx0hhEHaycIjKdDK7iJosp9yDA=
github.com/projectdiscovery/retryabledns v1.0.74 h1:4NtSjnVdPWT1NuabOMf5vjUoky3X1DwJN6iFanrtQnk=
github.com/projectdiscovery/retryabledns v1.0.74/go.mod h1:GRBpKmWIds0UVeDpqSek2Q8RITuuIZWD5wHL4cN5geg=
github.com/projectdiscovery/retryablehttp-go v1.0.75 h1:Aw0UZst7Q9cO69kERb1eFZA5BQOCXR8OuKGlj4cnOKY=
github.com/projectdiscovery/retryablehttp-go v1.0.75/go.mod h1:YK2gKa4prlAI++mAA8PeDRSd1IztSfpkpQiUdn0Z5Nc=
github.com/projectdiscovery/retryablehttp-go v1.0.76-0.20240826132304-648e6e6f3a4c h1:JkhMT0G7asauApqOZGhxPeXfO9SyZgjqUogS33GBzt0=
github.com/projectdiscovery/retryablehttp-go v1.0.76-0.20240826132304-648e6e6f3a4c/go.mod h1:5bkmRMjnFPxPCOgF1NZRLQDOuVW4rs1vtr0ADFjn6oQ=
github.com/projectdiscovery/stringsutil v0.0.2 h1:uzmw3IVLJSMW1kEg8eCStG/cGbYYZAja8BH3LqqJXMA=
github.com/projectdiscovery/stringsutil v0.0.2/go.mod h1:EJ3w6bC5fBYjVou6ryzodQq37D5c6qbAYQpGmAy+DC0=
github.com/projectdiscovery/tlsx v1.1.6 h1:iw2zwKbd2+kRQ8J1G4dLmS0CLyemd/tKz1UzcNsC77A=
Expand Down
3 changes: 3 additions & 0 deletions runner/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,8 @@ type Options struct {
// to be exact at end of existing closures
OnClose func()

Trace bool

// Optional pre-created objects to reduce allocations
Wappalyzer *wappalyzer.Wappalyze
Networkpolicy *networkpolicy.NetworkPolicy
Expand Down Expand Up @@ -496,6 +498,7 @@ func ParseOptions() *Options {
flagSet.BoolVarP(&options.Verbose, "verbose", "v", false, "verbose mode"),
flagSet.IntVarP(&options.StatsInterval, "stats-interval", "si", 0, "number of seconds to wait between showing a statistics update (default: 5)"),
flagSet.BoolVarP(&options.NoColor, "no-color", "nc", false, "disable colors in cli output"),
flagSet.BoolVarP(&options.Trace, "trace", "tr", false, "trace"),
)

flagSet.CreateGroup("Optimizations", "Optimizations",
Expand Down
15 changes: 11 additions & 4 deletions runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ func New(options *Options) (*Runner, error) {
}

httpxOptions := httpx.DefaultOptions
httpxOptions.Trace = options.Trace

var np *networkpolicy.NetworkPolicy
if options.Networkpolicy != nil {
Expand Down Expand Up @@ -1523,19 +1524,22 @@ retry:
if err := URL.MergePath(scanopts.RequestURI, scanopts.Unsafe); err != nil {
gologger.Debug().Msgf("failed to merge paths of url %v and %v", URL.String(), scanopts.RequestURI)
}
var req *retryablehttp.Request
var (
req *retryablehttp.Request
ctx context.Context
)
if target.CustomIP != "" {
var requestIP string
if iputil.IsIPv6(target.CustomIP) {
requestIP = fmt.Sprintf("[%s]", target.CustomIP)
} else {
requestIP = target.CustomIP
}
ctx := context.WithValue(context.Background(), fastdialer.IP, requestIP)
req, err = hp.NewRequestWithContext(ctx, method, URL.String())
ctx = context.WithValue(context.Background(), fastdialer.IP, requestIP)
} else {
req, err = hp.NewRequest(method, URL.String())
ctx = context.Background()
}
req, err = hp.NewRequestWithContext(ctx, method, URL.String())
if err != nil {
return Result{URL: URL.String(), Input: origInput, Err: err}
}
Expand Down Expand Up @@ -2252,6 +2256,9 @@ retry:
result.Fqdns = resp.BodyDomains.Fqdns
result.Domains = resp.BodyDomains.Domains
}
if r.options.Trace {
result.Trace = req.TraceInfo
}
return result
}

Expand Down
Loading
Loading