Add HTTP proxy support
parent
01813b7cb0
commit
103553c3d0
|
@ -11,11 +11,11 @@ import (
|
|||
)
|
||||
|
||||
// EnumerateSubdomains enumerates all the subdomains for a given domain
|
||||
func (a *Agent) EnumerateSubdomains(domain string, keys *subscraping.Keys, timeout int, maxEnumTime time.Duration) chan subscraping.Result {
|
||||
func (a *Agent) EnumerateSubdomains(domain string, keys *subscraping.Keys, proxy string, timeout int, maxEnumTime time.Duration) chan subscraping.Result {
|
||||
results := make(chan subscraping.Result)
|
||||
|
||||
go func() {
|
||||
session, err := subscraping.NewSession(domain, keys, timeout)
|
||||
session, err := subscraping.NewSession(domain, keys, proxy, timeout)
|
||||
if err != nil {
|
||||
results <- subscraping.Result{Type: subscraping.Error, Error: fmt.Errorf("could not init passive session for %s: %s", domain, err)}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ func (r *Runner) EnumerateSingleDomain(ctx context.Context, domain string, outpu
|
|||
|
||||
// Run the passive subdomain enumeration
|
||||
now := time.Now()
|
||||
passiveResults := r.passiveAgent.EnumerateSubdomains(domain, &keys, r.options.Timeout, time.Duration(r.options.MaxEnumerationTime)*time.Minute)
|
||||
passiveResults := r.passiveAgent.EnumerateSubdomains(domain, &keys, r.options.Proxy, r.options.Timeout, time.Duration(r.options.MaxEnumerationTime)*time.Minute)
|
||||
|
||||
wg := &sync.WaitGroup{}
|
||||
wg.Add(1)
|
||||
|
|
|
@ -39,7 +39,7 @@ type Options struct {
|
|||
Resolvers string // Resolvers is the comma-separated resolvers to use for enumeration
|
||||
ResolverList string // ResolverList is a text file containing list of resolvers to use for enumeration
|
||||
ConfigFile string // ConfigFile contains the location of the config file
|
||||
|
||||
Proxy string // HTTP proxy
|
||||
YAMLConfig ConfigFile // YAMLConfig contains the unmarshalled yaml config file
|
||||
}
|
||||
|
||||
|
@ -76,6 +76,7 @@ func ParseOptions() *Options {
|
|||
flag.StringVar(&options.ResolverList, "rL", "", "Text file containing list of resolvers to use")
|
||||
flag.BoolVar(&options.RemoveWildcard, "nW", false, "Remove Wildcard & Dead Subdomains from output")
|
||||
flag.StringVar(&options.ConfigFile, "config", path.Join(config, "config.yaml"), "Configuration file for API Keys, etc")
|
||||
flag.StringVar(&options.Proxy, "proxy", "", "HTTP proxy")
|
||||
flag.BoolVar(&options.Version, "version", false, "Show version of subfinder")
|
||||
flag.Parse()
|
||||
|
||||
|
|
|
@ -14,15 +14,28 @@ import (
|
|||
)
|
||||
|
||||
// NewSession creates a new session object for a domain
|
||||
func NewSession(domain string, keys *Keys, timeout int) (*Session, error) {
|
||||
client := &http.Client{
|
||||
Transport: &http.Transport{
|
||||
func NewSession(domain string, keys *Keys, proxy string, timeout int) (*Session, error) {
|
||||
Transport := &http.Transport{
|
||||
MaxIdleConns: 100,
|
||||
MaxIdleConnsPerHost: 100,
|
||||
TLSClientConfig: &tls.Config{
|
||||
InsecureSkipVerify: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// Add proxy
|
||||
if proxy != "" {
|
||||
proxyUrl, _ := url.Parse(proxy)
|
||||
if proxyUrl == nil {
|
||||
// Log warning but continue anyways
|
||||
gologger.Warning().Msgf("Invalid proxy '%s' provided", proxy)
|
||||
} else {
|
||||
Transport.Proxy = http.ProxyURL(proxyUrl)
|
||||
}
|
||||
}
|
||||
|
||||
client := &http.Client{
|
||||
Transport: Transport,
|
||||
Timeout: time.Duration(timeout) * time.Second,
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue