From 2fc129b47fbccd66896be289df2d27d812783540 Mon Sep 17 00:00:00 2001 From: Raul Sampedro Date: Thu, 14 Feb 2019 23:09:19 +0100 Subject: [PATCH 1/2] add generic timeout flag. only use nmap open ports. fix #168. fix #169 --- core/options.go | 8 ++++++++ main.go | 6 +++++- parsers/nmap.go | 5 +++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/core/options.go b/core/options.go index 7fc8643..89e145e 100644 --- a/core/options.go +++ b/core/options.go @@ -8,6 +8,7 @@ import ( type Options struct { Threads *int + Timeout *int OutDir *string Proxy *string ChromePath *string @@ -25,6 +26,7 @@ type Options struct { func ParseOptions() (Options, error) { options := Options{ Threads: flag.Int("threads", 0, "Number of concurrent threads (default number of logical CPUs)"), + Timeout: flag.Int("timeout", 0, "Generic timeout for everithing. (specific timeouts will be ignored if set)"), OutDir: flag.String("out", ".", "Directory to write files to"), Proxy: flag.String("proxy", "", "Proxy to use for HTTP requests"), ChromePath: flag.String("chrome-path", "", "Full path to the Chrome/Chromium executable to use. By default, aquatone will search for Chrome or Chromium"), @@ -41,5 +43,11 @@ func ParseOptions() (Options, error) { flag.Parse() + if *options.Timeout != 0{ + *options.ScanTimeout = *options.Timeout + *options.HTTPTimeout = *options.Timeout + *options.ScanTimeout = *options.Timeout + } + return options, nil } diff --git a/main.go b/main.go index 7caf9ef..d2ffe2d 100644 --- a/main.go +++ b/main.go @@ -94,7 +94,11 @@ func main() { sess.Out.Important("Targets : %d\n", len(targets)) sess.Out.Important("Threads : %d\n", *sess.Options.Threads) - sess.Out.Important("Ports : %s\n", strings.Trim(strings.Replace(fmt.Sprint(sess.Ports), " ", ", ", -1), "[]")) + if *sess.Options.Nmap { + sess.Out.Important("Ports : nmap open ports\n") + }else{ + sess.Out.Important("Ports : %s\n", strings.Trim(strings.Replace(fmt.Sprint(sess.Ports), " ", ", ", -1), "[]")) + } sess.Out.Important("Output dir : %s\n\n", *sess.Options.OutDir) for _, target := range targets { diff --git a/parsers/nmap.go b/parsers/nmap.go index d38d06d..0075479 100644 --- a/parsers/nmap.go +++ b/parsers/nmap.go @@ -48,6 +48,11 @@ func (p *NmapParser) isHTTPPort(port int) bool { func (p *NmapParser) hostToURLs(host nmap.Host) []string { var urls []string for _, port := range host.Ports { + + if port.State.State != "open"{ + continue + } + var protocol string if port.Service.Name == "ssl" { protocol = "https" From ccb95b7df1575af88e52873fbfaedd4dbdf08467 Mon Sep 17 00:00:00 2001 From: Raul Sampedro Date: Sun, 24 Feb 2019 18:20:49 +0100 Subject: [PATCH 2/2] go fmt --- core/bindata.go | 2 +- core/options.go | 4 ++-- main.go | 2 +- parsers/nmap.go | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/bindata.go b/core/bindata.go index daca64f..f2318d0 100644 --- a/core/bindata.go +++ b/core/bindata.go @@ -182,6 +182,7 @@ type bintree struct { Func func() (*asset, error) Children map[string]*bintree } + var _bintree = &bintree{nil, map[string]*bintree{ "static": &bintree{nil, map[string]*bintree{ "wappalyzer_fingerprints.json": &bintree{staticWappalyzer_fingerprintsJson, map[string]*bintree{}}, @@ -234,4 +235,3 @@ func _filePath(dir, name string) string { cannonicalName := strings.Replace(name, "\\", "/", -1) return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...) } - diff --git a/core/options.go b/core/options.go index 89e145e..0f15da0 100644 --- a/core/options.go +++ b/core/options.go @@ -26,7 +26,7 @@ type Options struct { func ParseOptions() (Options, error) { options := Options{ Threads: flag.Int("threads", 0, "Number of concurrent threads (default number of logical CPUs)"), - Timeout: flag.Int("timeout", 0, "Generic timeout for everithing. (specific timeouts will be ignored if set)"), + Timeout: flag.Int("timeout", 0, "Generic timeout for everithing. (specific timeouts will be ignored if set)"), OutDir: flag.String("out", ".", "Directory to write files to"), Proxy: flag.String("proxy", "", "Proxy to use for HTTP requests"), ChromePath: flag.String("chrome-path", "", "Full path to the Chrome/Chromium executable to use. By default, aquatone will search for Chrome or Chromium"), @@ -43,7 +43,7 @@ func ParseOptions() (Options, error) { flag.Parse() - if *options.Timeout != 0{ + if *options.Timeout != 0 { *options.ScanTimeout = *options.Timeout *options.HTTPTimeout = *options.Timeout *options.ScanTimeout = *options.Timeout diff --git a/main.go b/main.go index d2ffe2d..f6eeba8 100644 --- a/main.go +++ b/main.go @@ -96,7 +96,7 @@ func main() { sess.Out.Important("Threads : %d\n", *sess.Options.Threads) if *sess.Options.Nmap { sess.Out.Important("Ports : nmap open ports\n") - }else{ + } else { sess.Out.Important("Ports : %s\n", strings.Trim(strings.Replace(fmt.Sprint(sess.Ports), " ", ", ", -1), "[]")) } sess.Out.Important("Output dir : %s\n\n", *sess.Options.OutDir) diff --git a/parsers/nmap.go b/parsers/nmap.go index 0075479..118b667 100644 --- a/parsers/nmap.go +++ b/parsers/nmap.go @@ -49,7 +49,7 @@ func (p *NmapParser) hostToURLs(host nmap.Host) []string { var urls []string for _, port := range host.Ports { - if port.State.State != "open"{ + if port.State.State != "open" { continue }