diff --git a/README.md b/README.md index ecc1cdf..8ef592d 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,8 @@ If you for some reason don't trust the pre-compiled binaries, you can also compi Directory to write files to (default ".") -ports string Ports to scan on hosts. Supported list aliases: small, medium, large, xlarge (default "80,443,8000,8080,8443") + -user-agent string + User-Agent header -proxy string Proxy to use for HTTP requests -resolution string diff --git a/agents/url_requester.go b/agents/url_requester.go index 9b699a3..4c38956 100644 --- a/agents/url_requester.go +++ b/agents/url_requester.go @@ -31,11 +31,19 @@ func (a *URLRequester) Register(s *core.Session) error { func (a *URLRequester) OnURL(url string) { a.session.Out.Debug("[%s] Received new URL %s\n", a.ID(), url) a.session.WaitGroup.Add() + + var userAgent string + if *a.session.Options.UserAgent != "" { + userAgent = *a.session.Options.UserAgent + } else { + userAgent = RandomUserAgent() + } + go func(url string) { defer a.session.WaitGroup.Done() http := Gorequest(a.session.Options) resp, _, errs := http.Get(url). - Set("User-Agent", RandomUserAgent()). + Set("User-Agent", userAgent). Set("X-Forwarded-For", RandomIPv4Address()). Set("Via", fmt.Sprintf("1.1 %s", RandomIPv4Address())). Set("Forwarded", fmt.Sprintf("for=%s;proto=http;by=%s", RandomIPv4Address(), RandomIPv4Address())).End() diff --git a/agents/url_screenshotter.go b/agents/url_screenshotter.go index 2d70baa..3c52e85 100644 --- a/agents/url_screenshotter.go +++ b/agents/url_screenshotter.go @@ -125,12 +125,20 @@ func (a *URLScreenshotter) locateChrome() { func (a *URLScreenshotter) screenshotPage(page *core.Page) { filePath := fmt.Sprintf("screenshots/%s.png", page.BaseFilename()) + + var userAgent string + if *a.session.Options.UserAgent != "" { + userAgent = *a.session.Options.UserAgent + } else { + userAgent = RandomUserAgent() + } + var chromeArguments = []string{ "--headless", "--disable-gpu", "--hide-scrollbars", "--mute-audio", "--disable-notifications", "--no-first-run", "--disable-crash-reporter", "--ignore-certificate-errors", "--incognito", "--disable-infobars", "--disable-sync", "--no-default-browser-check", "--user-data-dir=" + a.tempUserDirPath, - "--user-agent=" + RandomUserAgent(), + "--user-agent=" + userAgent, "--window-size=" + *a.session.Options.Resolution, "--screenshot=" + a.session.GetFilePath(filePath), } diff --git a/core/options.go b/core/options.go index 3fc4c10..d993841 100644 --- a/core/options.go +++ b/core/options.go @@ -15,6 +15,7 @@ type Options struct { ChromePath *string Resolution *string Ports *string + UserAgent *string ScanTimeout *int HTTPTimeout *int ScreenshotTimeout *int @@ -35,6 +36,7 @@ func ParseOptions() (Options, error) { ChromePath: flag.String("chrome-path", "", "Full path to the Chrome/Chromium executable to use. By default, aquatone will search for Chrome or Chromium"), Resolution: flag.String("resolution", "1440,900", "screenshot resolution"), Ports: flag.String("ports", strings.Trim(strings.Join(strings.Fields(fmt.Sprint(MediumPortList)), ","), "[]"), "Ports to scan on hosts. Supported list aliases: small, medium, large, xlarge"), + UserAgent: flag.String("user-agent", "", "User-Agent header"), ScanTimeout: flag.Int("scan-timeout", 100, "Timeout in miliseconds for port scans"), HTTPTimeout: flag.Int("http-timeout", 3*1000, "Timeout in miliseconds for HTTP requests"), ScreenshotTimeout: flag.Int("screenshot-timeout", 30*1000, "Timeout in miliseconds for screenshots"),