Skip to content
This repository has been archived by the owner on Jan 13, 2023. It is now read-only.

Added User-Agent header option #260

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion agents/url_requester.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 9 additions & 1 deletion agents/url_screenshotter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Expand Down
2 changes: 2 additions & 0 deletions core/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type Options struct {
ChromePath *string
Resolution *string
Ports *string
UserAgent *string
ScanTimeout *int
HTTPTimeout *int
ScreenshotTimeout *int
Expand All @@ -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"),
Expand Down