From 06f1c2c4c595123a263baa627b4a7293f551feaf Mon Sep 17 00:00:00 2001 From: mzack Date: Fri, 15 Apr 2022 17:41:57 +0200 Subject: [PATCH 1/3] Adding support for custom SNI name --- common/httpx/httpx.go | 1 + common/httpx/option.go | 1 + go.mod | 2 +- go.sum | 3 +++ runner/options.go | 5 ++++- runner/runner.go | 3 ++- 6 files changed, 12 insertions(+), 3 deletions(-) diff --git a/common/httpx/httpx.go b/common/httpx/httpx.go index 23c04619..b33c9a5a 100644 --- a/common/httpx/httpx.go +++ b/common/httpx/httpx.go @@ -47,6 +47,7 @@ func New(options *Options) (*HTTPX, error) { if len(options.Resolvers) > 0 { fastdialerOpts.BaseResolvers = options.Resolvers } + fastdialerOpts.SNIName = options.SniName dialer, err := fastdialer.NewDialer(fastdialerOpts) if err != nil { return nil, fmt.Errorf("could not create resolver cache: %s", err) diff --git a/common/httpx/option.go b/common/httpx/option.go index 059665a0..b703bd58 100644 --- a/common/httpx/option.go +++ b/common/httpx/option.go @@ -40,6 +40,7 @@ type Options struct { UnsafeURI string Resolvers []string customCookies []*http.Cookie + SniName string } // DefaultOptions contains the default options diff --git a/go.mod b/go.mod index 561e69d7..8d6f3298 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( github.com/projectdiscovery/cdncheck v0.0.3 github.com/projectdiscovery/clistats v0.0.8 github.com/projectdiscovery/cryptoutil v0.0.0-20210805184155-b5d2512f9345 - github.com/projectdiscovery/fastdialer v0.0.15 + github.com/projectdiscovery/fastdialer v0.0.16-0.20220415153642-29a3e094f5d3 github.com/projectdiscovery/fdmax v0.0.3 github.com/projectdiscovery/fileutil v0.0.0-20210926202739-6050d0acf73c github.com/projectdiscovery/goconfig v0.0.0-20210804090219-f893ccd0c69c diff --git a/go.sum b/go.sum index 0e9450a8..bdf15335 100644 --- a/go.sum +++ b/go.sum @@ -130,6 +130,8 @@ github.com/projectdiscovery/cryptoutil v0.0.0-20210805184155-b5d2512f9345 h1:jT6 github.com/projectdiscovery/cryptoutil v0.0.0-20210805184155-b5d2512f9345/go.mod h1:clhQmPnt35ziJW1AhJRKyu8aygXCSoyWj6dtmZBRjjc= github.com/projectdiscovery/fastdialer v0.0.15 h1:vOLk8jty+1H9osPRzUT6acD0XBSaglyLS3MlIQaYczk= github.com/projectdiscovery/fastdialer v0.0.15/go.mod h1:Q28lw9oTpiZHq09uFG6YYYLUsUjsOypZ7PXWwQGBB80= +github.com/projectdiscovery/fastdialer v0.0.16-0.20220415153642-29a3e094f5d3 h1:m2z3BKKqDyzY06pTX8stOWKzZuIWSi6FmwT6wRR052E= +github.com/projectdiscovery/fastdialer v0.0.16-0.20220415153642-29a3e094f5d3/go.mod h1:wn6jSJ1fIO6kLplFEbFIkRB6Kj/Q6VngnzKuBHLVPiI= github.com/projectdiscovery/fdmax v0.0.3 h1:FM6lv9expZ/rEEBI9tkRh6tx3DV0gtpwzdc0h7bGPqg= github.com/projectdiscovery/fdmax v0.0.3/go.mod h1:NWRcaR7JTO7fC27H4jCl9n7Z+KIredwpgw1fV+4KrKI= github.com/projectdiscovery/fileutil v0.0.0-20210926202739-6050d0acf73c h1:KDmCXhLLnS/Gc1VDyTxxamRzc8OmHCm1X+f8WQoaTRs= @@ -204,6 +206,7 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5 github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/syndtr/goleveldb v1.0.0 h1:fBdIW9lB4Iz0n9khmH8w27SJ3QEJ7+IgjPEwGSZiFdE= github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ= github.com/ulule/deepcopier v0.0.0-20200430083143-45decc6639b6 h1:TtyC78WMafNW8QFfv3TeP3yWNDG+uxNkk9vOrnDu6JA= diff --git a/runner/options.go b/runner/options.go index 509b6bcb..b74b6105 100644 --- a/runner/options.go +++ b/runner/options.go @@ -5,7 +5,7 @@ import ( "os" "regexp" "strings" - "github.com/projectdiscovery/httpx/common/slice" + "github.com/projectdiscovery/fileutil" "github.com/projectdiscovery/goconfig" "github.com/projectdiscovery/goflags" @@ -16,6 +16,7 @@ import ( "github.com/projectdiscovery/httpx/common/customlist" customport "github.com/projectdiscovery/httpx/common/customports" fileutilz "github.com/projectdiscovery/httpx/common/fileutil" + "github.com/projectdiscovery/httpx/common/slice" "github.com/projectdiscovery/httpx/common/stringz" ) @@ -229,6 +230,7 @@ type Options struct { Hashes string Jarm bool Asn bool + SniName string } // ParseOptions parses the command line options for application @@ -264,6 +266,7 @@ func ParseOptions() *Options { flagSet.BoolVar(&options.Asn, "asn", false, "display host asn information"), flagSet.BoolVar(&options.OutputCDN, "cdn", false, "display cdn in use"), flagSet.BoolVar(&options.Probe, "probe", false, "display probe status"), + flagSet.StringVar(&options.SniName, "sni-name", "", "Custom SNI Name"), ) createGroup(flagSet, "matchers", "Matchers", diff --git a/runner/runner.go b/runner/runner.go index 73c0270d..3db5e582 100644 --- a/runner/runner.go +++ b/runner/runner.go @@ -125,6 +125,7 @@ func New(options *Options) (*Runner, error) { value = strings.TrimSpace(tokens[1]) httpxOptions.CustomHeaders[key] = value } + httpxOptions.SniName = options.SniName runner.hp, err = httpx.New(&httpxOptions) if err != nil { @@ -1293,7 +1294,7 @@ retry: } jarmhash := "" if r.options.Jarm { - jarmhash = hashes.Jarm(fullURL,r.options.Timeout) + jarmhash = hashes.Jarm(fullURL, r.options.Timeout) builder.WriteString(" [") if !scanopts.OutputWithNoColor { builder.WriteString(aurora.Magenta(jarmhash).String()) From c32cbbcfa2aa6fd84b12d779900a6d13def3e10f Mon Sep 17 00:00:00 2001 From: mzack Date: Fri, 15 Apr 2022 17:45:02 +0200 Subject: [PATCH 2/3] mod tidy --- go.sum | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/go.sum b/go.sum index d06472c8..fadea166 100644 --- a/go.sum +++ b/go.sum @@ -122,16 +122,12 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/projectdiscovery/blackrock v0.0.0-20210415162320-b38689ae3a2e h1:7bwaFH1jvtOo5ndhTQgoA349ozhX+1dc4b6tbaPnBOA= github.com/projectdiscovery/blackrock v0.0.0-20210415162320-b38689ae3a2e/go.mod h1:/IsapnEYiWG+yEDPXp0e8NWj3npzB9Ccy9lXEUJwMZs= -github.com/projectdiscovery/cdncheck v0.0.3 h1:li2/rUJmhVXSqRFyhJMqi6pdBX6ZxMnwzBfE0Kifj/g= -github.com/projectdiscovery/cdncheck v0.0.3/go.mod h1:EevMeCG1ogBoUJYaa0Mv9R1VUboDm/DiynId7DboKy0= github.com/projectdiscovery/cdncheck v0.0.4-0.20220413175814-b47bc2d578b1 h1:QtTPPx0uu42AsQJiXT86/wqdHS7/iVcgz1VM38tjv20= github.com/projectdiscovery/cdncheck v0.0.4-0.20220413175814-b47bc2d578b1/go.mod h1:EevMeCG1ogBoUJYaa0Mv9R1VUboDm/DiynId7DboKy0= github.com/projectdiscovery/clistats v0.0.8 h1:tjmWb15mqsPf/yrQXVHLe2ThZX/5+mgKSfZBKWWLh20= github.com/projectdiscovery/clistats v0.0.8/go.mod h1:lV6jUHAv2bYWqrQstqW8iVIydKJhWlVaLl3Xo9ioVGg= github.com/projectdiscovery/cryptoutil v0.0.0-20210805184155-b5d2512f9345 h1:jT6f/cdOpLkp9GAfRrxk57BUjYfIrR8E+AjMv5H5U4U= github.com/projectdiscovery/cryptoutil v0.0.0-20210805184155-b5d2512f9345/go.mod h1:clhQmPnt35ziJW1AhJRKyu8aygXCSoyWj6dtmZBRjjc= -github.com/projectdiscovery/fastdialer v0.0.15 h1:vOLk8jty+1H9osPRzUT6acD0XBSaglyLS3MlIQaYczk= -github.com/projectdiscovery/fastdialer v0.0.15/go.mod h1:Q28lw9oTpiZHq09uFG6YYYLUsUjsOypZ7PXWwQGBB80= github.com/projectdiscovery/fastdialer v0.0.16-0.20220415153642-29a3e094f5d3 h1:m2z3BKKqDyzY06pTX8stOWKzZuIWSi6FmwT6wRR052E= github.com/projectdiscovery/fastdialer v0.0.16-0.20220415153642-29a3e094f5d3/go.mod h1:wn6jSJ1fIO6kLplFEbFIkRB6Kj/Q6VngnzKuBHLVPiI= github.com/projectdiscovery/fdmax v0.0.3 h1:FM6lv9expZ/rEEBI9tkRh6tx3DV0gtpwzdc0h7bGPqg= @@ -206,8 +202,8 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/syndtr/goleveldb v1.0.0 h1:fBdIW9lB4Iz0n9khmH8w27SJ3QEJ7+IgjPEwGSZiFdE= github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ= From 4c0b28374e74d825df3668d429c3ae255e23baaa Mon Sep 17 00:00:00 2001 From: sandeep Date: Thu, 21 Apr 2022 13:05:58 +0530 Subject: [PATCH 3/3] misc update --- runner/options.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runner/options.go b/runner/options.go index 98598756..d2cacbb3 100644 --- a/runner/options.go +++ b/runner/options.go @@ -272,7 +272,6 @@ func ParseOptions() *Options { flagSet.BoolVar(&options.Asn, "asn", false, "display host asn information"), flagSet.BoolVar(&options.OutputCDN, "cdn", false, "display cdn in use"), flagSet.BoolVar(&options.Probe, "probe", false, "display probe status"), - flagSet.StringVar(&options.SniName, "sni-name", "", "Custom SNI Name"), ) createGroup(flagSet, "matchers", "Matchers", @@ -334,6 +333,7 @@ func ParseOptions() *Options { flagSet.NormalizedStringSliceVarP(&options.Resolvers, "resolvers", "r", []string{}, "list of custom resolver (file or comma separated)"), flagSet.Var(&options.Allow, "allow", "allowed list of IP/CIDR's to process (file or comma separated)"), flagSet.Var(&options.Deny, "deny", "denied list of IP/CIDR's to process (file or comma separated)"), + flagSet.StringVarP(&options.SniName, "sni-name", "sni", "", "Custom TLS SNI name"), flagSet.BoolVar(&options.RandomAgent, "random-agent", true, "Enable Random User-Agent to use"), flagSet.VarP(&options.CustomHeaders, "header", "H", "custom http headers to send with request"), flagSet.StringVarP(&options.HTTPProxy, "proxy", "http-proxy", "", "http proxy to use (eg http://127.0.0.1:8080)"),