From 963b6a79d73c72bfd4f4be896f6ce893e23983f9 Mon Sep 17 00:00:00 2001 From: caffix Date: Mon, 23 Sep 2024 21:46:12 -0400 Subject: [PATCH] upgraded to OAM v0.8.0 and started pruning the client --- cmd/amass/help.go | 4 - cmd/amass/main.go | 7 +- cmd/amass/subs.go | 2 +- cmd/amass/track.go | 174 -------------------- cmd/amass/viz.go | 202 ------------------------ go.mod | 16 +- go.sum | 53 +++---- net/http/http_test.go | 2 +- viz/d3.go | 360 ------------------------------------------ viz/d3_test.go | 271 ------------------------------- viz/dot.go | 78 --------- viz/dot_test.go | 38 ----- viz/gexf.go | 179 --------------------- viz/gexf_test.go | 55 ------- viz/viz.go | 246 ----------------------------- 15 files changed, 27 insertions(+), 1660 deletions(-) delete mode 100644 cmd/amass/track.go delete mode 100644 cmd/amass/viz.go delete mode 100644 viz/d3.go delete mode 100644 viz/d3_test.go delete mode 100644 viz/dot.go delete mode 100644 viz/dot_test.go delete mode 100644 viz/gexf.go delete mode 100644 viz/gexf_test.go delete mode 100644 viz/viz.go diff --git a/cmd/amass/help.go b/cmd/amass/help.go index 0c194056..7d848bca 100644 --- a/cmd/amass/help.go +++ b/cmd/amass/help.go @@ -25,10 +25,6 @@ func runHelpCommand(clArgs []string) { runSubsCommand(help) case "emails": runEmailsCommand(help) - case "viz": - runVizCommand(help) - case "track": - runTrackCommand(help) default: commandUsage(mainUsageMsg, helpCommand, helpBuf) return diff --git a/cmd/amass/main.go b/cmd/amass/main.go index 729363c9..f9f9bdd7 100644 --- a/cmd/amass/main.go +++ b/cmd/amass/main.go @@ -92,7 +92,6 @@ func commandUsage(msg string, cmdFlagSet *flag.FlagSet, errBuf *bytes.Buffer) { g.Fprintf(color.Error, "\t%-11s - Discover targets for enumerations\n", "amass intel") g.Fprintf(color.Error, "\t%-11s - Perform enumerations and network mapping\n", "amass enum") g.Fprintf(color.Error, "\t%-11s - Analyze subdomain information in the asset-db\n", "amass subs") - g.Fprintf(color.Error, "\t%-11s - Analyze OAM data to generate graph visualizations\n", "amass viz") g.Fprintf(color.Error, "\t%-11s - Analyze OAM data to identify newly discovered assets\n", "amass track") } @@ -137,10 +136,6 @@ func main() { runSubsCommand(os.Args[2:]) case "emails": runEmailsCommand(os.Args[2:]) - case "viz": - runVizCommand(os.Args[2:]) - case "track": - runTrackCommand(os.Args[2:]) case "help": runHelpCommand(os.Args[2:]) default: @@ -338,7 +333,7 @@ func convertScopeToAssets(scope *config.Scope) []*et.Asset { } // Create an asset from the CIDR and append it to the assets slice. - asset := oamnet.Netblock{Cidr: prefix, Type: ipType} + asset := oamnet.Netblock{CIDR: prefix, Type: ipType} data := et.AssetData{ OAMAsset: asset, OAMType: asset.AssetType(), diff --git a/cmd/amass/subs.go b/cmd/amass/subs.go index 430ca2ab..b0f6e5d7 100644 --- a/cmd/amass/subs.go +++ b/cmd/amass/subs.go @@ -419,7 +419,7 @@ func readASPrefixes(db *assetdb.AssetDB, asn int, since time.Time) []string { if a, err := db.FindById(rel.ToAsset.ID, since); err != nil { continue } else if netblock, ok := a.Asset.(*network.Netblock); ok { - prefixes = append(prefixes, netblock.Cidr.String()) + prefixes = append(prefixes, netblock.CIDR.String()) } } } diff --git a/cmd/amass/track.go b/cmd/amass/track.go deleted file mode 100644 index ee094faa..00000000 --- a/cmd/amass/track.go +++ /dev/null @@ -1,174 +0,0 @@ -// Copyright © by Jeff Foley 2017-2024. All rights reserved. -// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. -// SPDX-License-Identifier: Apache-2.0 - -package main - -import ( - "bytes" - "flag" - "io" - "os" - "path" - "time" - - "github.com/caffix/stringset" - "github.com/fatih/color" - assetdb "github.com/owasp-amass/asset-db" - "github.com/owasp-amass/config/config" - oam "github.com/owasp-amass/open-asset-model" - "github.com/owasp-amass/open-asset-model/domain" -) - -const trackUsageMsg = "track [options] [-since '" + timeFormat + "'] " + "-d domain" - -type trackArgs struct { - Domains *stringset.Set - Since string - Options struct { - NoColor bool - Silent bool - } - Filepaths struct { - ConfigFile string - Directory string - Domains string - } -} - -func runTrackCommand(clArgs []string) { - var args trackArgs - var help1, help2 bool - trackCommand := flag.NewFlagSet("track", flag.ContinueOnError) - - args.Domains = stringset.New() - defer args.Domains.Close() - - trackBuf := new(bytes.Buffer) - trackCommand.SetOutput(trackBuf) - - trackCommand.BoolVar(&help1, "h", false, "Show the program usage message") - trackCommand.BoolVar(&help2, "help", false, "Show the program usage message") - trackCommand.Var(args.Domains, "d", "Domain names separated by commas (can be used multiple times)") - trackCommand.StringVar(&args.Since, "since", "", "Exclude all assets discovered before (format: "+timeFormat+")") - trackCommand.BoolVar(&args.Options.NoColor, "nocolor", false, "Disable colorized output") - trackCommand.BoolVar(&args.Options.Silent, "silent", false, "Disable all output during execution") - trackCommand.StringVar(&args.Filepaths.ConfigFile, "config", "", "Path to the YAML configuration file") - trackCommand.StringVar(&args.Filepaths.Directory, "dir", "", "Path to the directory containing the graph database") - trackCommand.StringVar(&args.Filepaths.Domains, "df", "", "Path to a file providing registered domain names") - - var usage = func() { - g.Fprintf(color.Error, "Usage: %s %s\n\n", path.Base(os.Args[0]), trackUsageMsg) - trackCommand.PrintDefaults() - g.Fprintln(color.Error, trackBuf.String()) - } - - if len(clArgs) < 1 { - usage() - return - } - if err := trackCommand.Parse(clArgs); err != nil { - r.Fprintf(color.Error, "%v\n", err) - os.Exit(1) - } - if help1 || help2 { - usage() - return - } - if args.Options.NoColor { - color.NoColor = true - } - if args.Options.Silent { - color.Output = io.Discard - color.Error = io.Discard - } - if args.Filepaths.Domains != "" { - list, err := config.GetListFromFile(args.Filepaths.Domains) - if err != nil { - r.Fprintf(color.Error, "Failed to parse the domain names file: %v\n", err) - os.Exit(1) - } - args.Domains.InsertMany(list...) - } - if args.Domains.Len() == 0 { - r.Fprintln(color.Error, "No root domain names were provided") - os.Exit(1) - } - - var err error - var start time.Time - if args.Since != "" { - start, err = time.Parse(timeFormat, args.Since) - if err != nil { - r.Fprintf(color.Error, "%s is not in the correct format: %s\n", args.Since, timeFormat) - os.Exit(1) - } - } - - cfg := config.NewConfig() - // Check if a configuration file was provided, and if so, load the settings - if err := config.AcquireConfig(args.Filepaths.Directory, args.Filepaths.ConfigFile, cfg); err == nil { - if args.Filepaths.Directory == "" { - args.Filepaths.Directory = cfg.Dir - } - if args.Domains.Len() == 0 { - args.Domains.InsertMany(cfg.Domains()...) - } - } else if args.Filepaths.ConfigFile != "" { - r.Fprintf(color.Error, "Failed to load the configuration file: %v\n", err) - os.Exit(1) - } - // Connect with the graph database containing the enumeration data - db := openGraphDatabase(cfg) - if db == nil { - r.Fprintln(color.Error, "Failed to connect with the database") - os.Exit(1) - } - - for _, name := range getNewNames(args.Domains.Slice(), start, db) { - g.Fprintln(color.Output, name) - } -} - -func getNewNames(domains []string, since time.Time, db *assetdb.AssetDB) []string { - if len(domains) == 0 { - return []string{} - } - - var fqdns []oam.Asset - for _, d := range domains { - fqdns = append(fqdns, &domain.FQDN{Name: d}) - } - - if !since.IsZero() { - since = since.UTC() - } - - assets, err := db.FindByScope(fqdns, since) - if err != nil { - return []string{} - } - - if since.IsZero() { - var latest time.Time - for _, a := range assets { - if _, ok := a.Asset.(*domain.FQDN); ok && a.LastSeen.After(latest) { - latest = a.LastSeen - } - } - since = latest.Truncate(24 * time.Hour) - } - - res := stringset.New() - defer res.Close() - - for _, a := range assets { - if n, ok := a.Asset.(*domain.FQDN); ok && !res.Has(n.Name) && - (a.CreatedAt.Equal(since) || a.CreatedAt.After(since)) && - (a.LastSeen.Equal(since) || a.LastSeen.After(since)) { - res.Insert(n.Name) - } - } - - return res.Slice() -} diff --git a/cmd/amass/viz.go b/cmd/amass/viz.go deleted file mode 100644 index 96098216..00000000 --- a/cmd/amass/viz.go +++ /dev/null @@ -1,202 +0,0 @@ -// Copyright © by Jeff Foley 2017-2024. All rights reserved. -// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. -// SPDX-License-Identifier: Apache-2.0 - -package main - -import ( - "bytes" - "flag" - "io" - "os" - "path" - "path/filepath" - "time" - - "github.com/caffix/stringset" - "github.com/fatih/color" - "github.com/owasp-amass/amass/v4/viz" - "github.com/owasp-amass/config/config" -) - -const ( - timeFormat = "01/02 15:04:05 2006 MST" - vizUsageMsg = "viz -d3|-dot|-gexf [options] -d domain" -) - -type vizArgs struct { - Domains *stringset.Set - Since string - Options struct { - D3 bool - DOT bool - GEXF bool - NoColor bool - Silent bool - } - Filepaths struct { - ConfigFile string - Directory string - Domains string - Output string - AllFilePrefix string - } -} - -func runVizCommand(clArgs []string) { - var args vizArgs - var help1, help2 bool - vizCommand := flag.NewFlagSet("viz", flag.ContinueOnError) - - args.Domains = stringset.New() - defer args.Domains.Close() - - vizBuf := new(bytes.Buffer) - vizCommand.SetOutput(vizBuf) - - vizCommand.BoolVar(&help1, "h", false, "Show the program usage message") - vizCommand.BoolVar(&help2, "help", false, "Show the program usage message") - vizCommand.Var(args.Domains, "d", "Domain names separated by commas (can be used multiple times)") - vizCommand.StringVar(&args.Since, "since", "", "Include only assets validated after (format: "+timeFormat+")") - vizCommand.StringVar(&args.Filepaths.ConfigFile, "config", "", "Path to the YAML configuration file") - vizCommand.StringVar(&args.Filepaths.Directory, "dir", "", "Path to the directory containing the graph database") - vizCommand.StringVar(&args.Filepaths.Domains, "df", "", "Path to a file providing registered domain names") - vizCommand.StringVar(&args.Filepaths.Output, "o", "", "Path to the directory for output files being generated") - vizCommand.StringVar(&args.Filepaths.AllFilePrefix, "oA", "", "Path prefix used for naming all output files") - vizCommand.BoolVar(&args.Options.D3, "d3", false, "Generate the D3 v4 force simulation HTML file") - vizCommand.BoolVar(&args.Options.DOT, "dot", false, "Generate the DOT output file") - vizCommand.BoolVar(&args.Options.GEXF, "gexf", false, "Generate the Gephi Graph Exchange XML Format (GEXF) file") - vizCommand.BoolVar(&args.Options.NoColor, "nocolor", false, "Disable colorized output") - vizCommand.BoolVar(&args.Options.Silent, "silent", false, "Disable all output during execution") - - var usage = func() { - g.Fprintf(color.Error, "Usage: %s %s\n\n", path.Base(os.Args[0]), vizUsageMsg) - vizCommand.PrintDefaults() - g.Fprintln(color.Error, vizBuf.String()) - } - - if len(clArgs) < 1 { - usage() - return - } - if err := vizCommand.Parse(clArgs); err != nil { - r.Fprintf(color.Error, "%v\n", err) - os.Exit(1) - } - if help1 || help2 { - usage() - return - } - if args.Options.NoColor { - color.NoColor = true - } - if args.Options.Silent { - color.Output = io.Discard - color.Error = io.Discard - } - if args.Filepaths.Domains != "" { - list, err := config.GetListFromFile(args.Filepaths.Domains) - if err != nil { - r.Fprintf(color.Error, "Failed to parse the domain names file: %v\n", err) - os.Exit(1) - } - args.Domains.InsertMany(list...) - } - if args.Domains.Len() == 0 { - r.Fprintln(color.Error, "No root domain names were provided") - os.Exit(1) - } - // Make sure at least one graph file format has been identified on the command-line - if !args.Options.D3 && !args.Options.DOT && !args.Options.GEXF { - r.Fprintln(color.Error, "At least one file format must be selected") - os.Exit(1) - } - - var err error - var start time.Time - if args.Since != "" { - start, err = time.Parse(timeFormat, args.Since) - if err != nil { - r.Fprintf(color.Error, "%s is not in the correct format: %s\n", args.Since, timeFormat) - os.Exit(1) - } - } - - cfg := config.NewConfig() - // Check if a configuration file was provided, and if so, load the settings - if err := config.AcquireConfig(args.Filepaths.Directory, args.Filepaths.ConfigFile, cfg); err == nil { - if args.Filepaths.Directory == "" { - args.Filepaths.Directory = cfg.Dir - } - if args.Domains.Len() == 0 { - args.Domains.InsertMany(cfg.Domains()...) - } - } else if args.Filepaths.ConfigFile != "" { - r.Fprintf(color.Error, "Failed to load the configuration file: %v\n", err) - os.Exit(1) - } - // Connect with the graph database containing the enumeration data - db := openGraphDatabase(cfg) - if db == nil { - r.Fprintln(color.Error, "Failed to connect with the database") - os.Exit(1) - } - // Obtain the visualization nodes & edges from the graph - nodes, edges := viz.VizData(args.Domains.Slice(), start, db) - // Get the directory to save the files into - dir := args.Filepaths.Directory - - // Set output file prefix, use 'amass' if '-oA' flag is not specified - prefix := args.Filepaths.AllFilePrefix - if prefix == "" { - prefix = "amass" - } - - if args.Filepaths.Output != "" { - if finfo, err := os.Stat(args.Filepaths.Output); os.IsNotExist(err) || !finfo.IsDir() { - r.Fprintln(color.Error, "The output location does not exist or is not a directory") - os.Exit(1) - } - dir = args.Filepaths.Output - } - if args.Options.D3 { - path := filepath.Join(dir, prefix+".html") - err = writeGraphOutputFile("d3", path, nodes, edges) - } - if args.Options.DOT { - path := filepath.Join(dir, prefix+".dot") - err = writeGraphOutputFile("dot", path, nodes, edges) - } - if args.Options.GEXF { - path := filepath.Join(dir, prefix+".gexf") - err = writeGraphOutputFile("gexf", path, nodes, edges) - } - if err != nil { - r.Fprintf(color.Error, "Failed to write the output file: %v\n", err) - os.Exit(1) - } -} - -func writeGraphOutputFile(t string, path string, nodes []viz.Node, edges []viz.Edge) error { - f, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE, 0644) - if err != nil { - return err - } - defer func() { - _ = f.Sync() - _ = f.Close() - }() - - _ = f.Truncate(0) - _, _ = f.Seek(0, 0) - - switch t { - case "d3": - err = viz.WriteD3Data(f, nodes, edges) - case "dot": - err = viz.WriteDOTData(f, nodes, edges) - case "gexf": - err = viz.WriteGEXFData(f, nodes, edges) - } - return err -} diff --git a/go.mod b/go.mod index 351fb05f..eabc195c 100644 --- a/go.mod +++ b/go.mod @@ -10,15 +10,14 @@ require ( github.com/geziyor/geziyor v0.0.0-20240812061556-229b8ca83ac1 github.com/glebarez/sqlite v1.11.0 github.com/miekg/dns v1.1.62 - github.com/owasp-amass/asset-db v0.7.0 - github.com/owasp-amass/config v0.7.1 - github.com/owasp-amass/engine v0.0.2 - github.com/owasp-amass/open-asset-model v0.7.1 + github.com/owasp-amass/asset-db v0.8.1 + github.com/owasp-amass/config v0.8.0 + github.com/owasp-amass/engine v0.0.3-0.20240923235739-7d115c76590b + github.com/owasp-amass/open-asset-model v0.8.0 github.com/owasp-amass/resolve v0.8.1 github.com/rubenv/sql-migrate v1.7.0 github.com/samber/slog-common v0.17.1 github.com/samber/slog-syslog/v2 v2.5.0 - github.com/stretchr/testify v1.9.0 github.com/tylertreat/BoomFilters v0.0.0-20210315201527-1a82519a3e43 github.com/yl2chen/cidranger v1.0.2 gorm.io/driver/postgres v1.5.9 @@ -36,10 +35,9 @@ require ( github.com/caffix/pipeline v0.2.3 // indirect github.com/caffix/queue v0.1.5 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect - github.com/chromedp/cdproto v0.0.0-20240810084448-b931b754e476 // indirect + github.com/chromedp/cdproto v0.0.0-20240919203636-12af5e8a671f // indirect github.com/chromedp/chromedp v0.10.0 // indirect github.com/chromedp/sysutil v1.0.0 // indirect - github.com/davecgh/go-spew v1.1.1 // indirect github.com/dgraph-io/badger v1.6.2 // indirect github.com/dgraph-io/ristretto v1.0.0 // indirect github.com/dustin/go-humanize v1.0.1 // indirect @@ -50,7 +48,6 @@ require ( github.com/gobwas/httphead v0.1.0 // indirect github.com/gobwas/pool v0.2.1 // indirect github.com/gobwas/ws v1.4.0 // indirect - github.com/golang/glog v1.2.2 // indirect github.com/golang/protobuf v1.5.4 // indirect github.com/google/uuid v1.6.0 // indirect github.com/gorilla/websocket v1.5.3 // indirect @@ -63,7 +60,7 @@ require ( github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/now v1.1.5 // indirect github.com/josharian/intern v1.0.0 // indirect - github.com/klauspost/compress v1.17.9 // indirect + github.com/klauspost/compress v1.17.10 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect @@ -71,7 +68,6 @@ require ( github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/ncruces/go-strftime v0.1.9 // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_golang v1.20.4 // indirect github.com/prometheus/client_model v0.6.1 // indirect github.com/prometheus/common v0.59.1 // indirect diff --git a/go.sum b/go.sum index a3e03804..614c5a74 100644 --- a/go.sum +++ b/go.sum @@ -600,8 +600,8 @@ filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= gioui.org v0.0.0-20210308172011-57750fc8a0a6/go.mod h1:RSH6KIUZ0p2xy5zHDxgAM4zumjgTw83q2ge/PI+yyw8= git.sr.ht/~sbinet/gg v0.3.1/go.mod h1:KGYtlADtqsqANL9ueOFkWymvzUvLMQllU5Ixo+8v3pc= -github.com/99designs/gqlgen v0.17.49 h1:b3hNGexHd33fBSAd4NDT/c3NCcQzcAVkknhN9ym36YQ= -github.com/99designs/gqlgen v0.17.49/go.mod h1:tC8YFVZMed81x7UJ7ORUwXF4Kn6SXuucFqQBhN8+BU0= +github.com/99designs/gqlgen v0.17.54 h1:AsF49k/7RJlwA00RQYsYN0T8cQuaosnV/7G1dHC3Uh8= +github.com/99designs/gqlgen v0.17.54/go.mod h1:77/+pVe6zlTsz++oUg2m8VLgzdUPHxjoAG3BxI5y8Rc= github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96 h1:cTp8I5+VIoKjsnZuH8vjyaysT/ses3EvZeaV/1UkF2M= github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= @@ -612,7 +612,6 @@ github.com/HdrHistogram/hdrhistogram-go v1.1.2/go.mod h1:yDgFjdqOqDEKOvasDdhWNXY github.com/JohnCGriffin/overflow v0.0.0-20211019200055-46fa312c352c/go.mod h1:X0CRv0ky0k6m906ixxpzmDRLvX58TFUKS2eePweuyxk= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= -github.com/PuerkitoBio/goquery v1.9.2 h1:4/wZksC3KgkQw7SQgkKotmKljk0M6V8TUvA8Wb4yPeE= github.com/PuerkitoBio/goquery v1.9.2/go.mod h1:GHPCaP0ODyyxqcNoFGYlAprUFH81NuRPd0GX3Zu2Mvk= github.com/PuerkitoBio/goquery v1.10.0 h1:6fiXdLuUvYs2OJSvNRqlNPoBm6YABE226xrbavY5Wv4= github.com/PuerkitoBio/goquery v1.10.0/go.mod h1:TjZZl68Q3eGHNBA8CWaxAN7rOU1EbDz3CWuolcO5Yu4= @@ -677,7 +676,6 @@ github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInq github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/census-instrumentation/opencensus-proto v0.3.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/census-instrumentation/opencensus-proto v0.4.1/go.mod h1:4T9NM4+4Vw91VeyqjLS6ao50K5bOcLKN6Q42XnYaRYw= -github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= @@ -687,8 +685,9 @@ github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL github.com/cheggaaa/pb/v3 v3.1.5 h1:QuuUzeM2WsAqG2gMqtzaWithDJv0i+i6UlnwSCI4QLk= github.com/cheggaaa/pb/v3 v3.1.5/go.mod h1:CrxkeghYTXi1lQBEI7jSn+3svI3cuc19haAj6jM60XI= github.com/chromedp/cdproto v0.0.0-20240801214329-3f85d328b335/go.mod h1:GKljq0VrfU4D5yc+2qA6OVr8pmO/MBbPEWqWQ/oqGEs= -github.com/chromedp/cdproto v0.0.0-20240810084448-b931b754e476 h1:VnjHsRXCRti7Av7E+j4DCha3kf68echfDzQ+wD11SBU= github.com/chromedp/cdproto v0.0.0-20240810084448-b931b754e476/go.mod h1:GKljq0VrfU4D5yc+2qA6OVr8pmO/MBbPEWqWQ/oqGEs= +github.com/chromedp/cdproto v0.0.0-20240919203636-12af5e8a671f h1:dEjjp+iN34En5Pl9XIi978DmR2/CMwuOxoPWtiHixKQ= +github.com/chromedp/cdproto v0.0.0-20240919203636-12af5e8a671f/go.mod h1:GKljq0VrfU4D5yc+2qA6OVr8pmO/MBbPEWqWQ/oqGEs= github.com/chromedp/chromedp v0.10.0 h1:bRclRYVpMm/UVD76+1HcRW9eV3l58rFfy7AdBvKab1E= github.com/chromedp/chromedp v0.10.0/go.mod h1:ei/1ncZIqXX1YnAYDkxhD4gzBgavMEUu7JCKvztdomE= github.com/chromedp/sysutil v1.0.0 h1:+ZxhTpfpZlmchB58ih/LBHX52ky7w2VhQVKQMucy3Ic= @@ -728,12 +727,11 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/dgraph-io/badger v1.6.2 h1:mNw0qs90GVgGGWylh0umH5iag1j6n/PeJtNvL6KY/x8= github.com/dgraph-io/badger v1.6.2/go.mod h1:JW2yswe3V058sS0kZ2h/AXeDSqFjxnZcRrVH//y2UQE= github.com/dgraph-io/ristretto v0.0.2/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E= -github.com/dgraph-io/ristretto v0.1.1 h1:6CWw5tJNgpegArSHpNHJKldNeq03FQCwYvfMVWajOK8= -github.com/dgraph-io/ristretto v0.1.1/go.mod h1:S1GPSBCYCIhmVNfcth17y2zZtQT6wzkzgwUve0VDWWA= github.com/dgraph-io/ristretto v1.0.0 h1:SYG07bONKMlFDUYu5pEu3DGAh8c2OFNzKm6G9J4Si84= github.com/dgraph-io/ristretto v1.0.0/go.mod h1:jTi2FiYEhQ1NsMmA7DeBykizjOuY88NhKBkepyu1jPc= -github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA= github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= +github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 h1:fAjc9m62+UWV/WAFKLNi6ZS0675eEUC9y3AlwSbQu1Y= +github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= @@ -830,8 +828,6 @@ github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGw github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= github.com/golang/glog v1.1.0/go.mod h1:pfYeQZ3JWZoXTV5sFc986z3HTpwQs9At6P4ImfuP3NQ= -github.com/golang/glog v1.2.2 h1:1+mZ9upx1Dh6FmUTFR1naJ77miKiXgALjWOZ3NVFPmY= -github.com/golang/glog v1.2.2/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -1034,8 +1030,8 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o github.com/klauspost/asmfmt v1.3.2/go.mod h1:AG8TuvYojzulgDAMCnYn50l/5QV3Bs/tp6j0HLHbNSE= github.com/klauspost/compress v1.14.4/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= -github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= -github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= +github.com/klauspost/compress v1.17.10 h1:oXAz+Vh0PMUvJczoi+flxpnBEPxoER1IaAnU/NMPtT0= +github.com/klauspost/compress v1.17.10/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= @@ -1138,18 +1134,14 @@ github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYr github.com/openzipkin/zipkin-go v0.2.5/go.mod h1:KpXfKdgRDnnhsxw4pNIH9Md5lyFqKUa4YDFlwRYAMyE= github.com/orisano/pixelmatch v0.0.0-20220722002657-fb0b55479cde h1:x0TT0RDC7UhAVbbWWBzr41ElhJx5tXPWkIHA2HWPRuw= github.com/orisano/pixelmatch v0.0.0-20220722002657-fb0b55479cde/go.mod h1:nZgzbfBr3hhjoZnS66nKrHmduYNpc34ny7RK4z5/HM0= -github.com/owasp-amass/asset-db v0.7.0 h1:r/f1ukjxjIx9tqXD4BQLLLVcuaPR8JB8B1SR7jD8nK4= -github.com/owasp-amass/asset-db v0.7.0/go.mod h1:wmhf8J8Afy8jPyZeF7HGQ5XBG+Qswg+Qec0+tajT7lQ= -github.com/owasp-amass/config v0.7.0 h1:1OTa7ifnMczEtG1GmFMfjTIwPMWqc3QhjvIjWt4ZOXo= -github.com/owasp-amass/config v0.7.0/go.mod h1:oUQEGKorjuNPMcMBU2abOxJqjy3NWqR15u0v4upPGDI= -github.com/owasp-amass/config v0.7.1 h1:q4jFSxdWnpCAUSqfik6kk3he5v/w0hGOHzKs3XS9hRo= -github.com/owasp-amass/config v0.7.1/go.mod h1:pldBzv51WQCQjyZJGukp4rb7zcM7vJtNVPM+M0+Zbz0= -github.com/owasp-amass/engine v0.0.2 h1:+Xc9GsxnVUM65COUGblIYilioYMC8dNpGmCJm5d6tvY= -github.com/owasp-amass/engine v0.0.2/go.mod h1:qQ0uX+c7C1UDDUQOoC7glY0OYNSXG/rezK44e6lGUn8= -github.com/owasp-amass/open-asset-model v0.7.0 h1:1Iv4Jtn4OUgWwSLnFAacwVZohECIBmcKRxjovVehQ9A= -github.com/owasp-amass/open-asset-model v0.7.0/go.mod h1:DOX+SiD6PZBroSMnsILAmpf0SHi6TVpqjV4uNfBeg7g= -github.com/owasp-amass/open-asset-model v0.7.1 h1:euJMv6CYIcVxLT7cq6Ks6kyR+lfxDAQ4NVhi9T9qv9U= -github.com/owasp-amass/open-asset-model v0.7.1/go.mod h1:DOX+SiD6PZBroSMnsILAmpf0SHi6TVpqjV4uNfBeg7g= +github.com/owasp-amass/asset-db v0.8.1 h1:KMUl88SRsfrycRsV7aC8wm+8IJhfBEWJEqvumjcceK0= +github.com/owasp-amass/asset-db v0.8.1/go.mod h1:E3e4Y6M4ztj/np1wupLaJID9L3muK51NOAKDtWNyQ7k= +github.com/owasp-amass/config v0.8.0 h1:5kVCbRxRtTwRtMSv+CaHIW4GX/DtIMZ1uXPa2dqA5nw= +github.com/owasp-amass/config v0.8.0/go.mod h1:8lB0qf+v19/Bl/z7nsef/JJ0/ii6te949B758aaNlQc= +github.com/owasp-amass/engine v0.0.3-0.20240923235739-7d115c76590b h1:jaDbzstGu3jVjMnDnCoIZWFbz3fnc9jndrWl5DA76XA= +github.com/owasp-amass/engine v0.0.3-0.20240923235739-7d115c76590b/go.mod h1:jl2vs9X16Pb2NBGkl6UopbTYl++Qm1wMYulhODkYoc0= +github.com/owasp-amass/open-asset-model v0.8.0 h1:L0WcKMWzOACgKiBKMcQEKKUFrgIROAnN5iB9TDijrlI= +github.com/owasp-amass/open-asset-model v0.8.0/go.mod h1:DOX+SiD6PZBroSMnsILAmpf0SHi6TVpqjV4uNfBeg7g= github.com/owasp-amass/resolve v0.8.1 h1:CM92zgnLj80pIuDdlbABQzu2G3th2RFbbS7QtyFOTfA= github.com/owasp-amass/resolve v0.8.1/go.mod h1:3rT2jEDEzFvKl/bACBpHTfj94M4ait5VmEAbXILJNbs= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= @@ -1189,8 +1181,6 @@ github.com/prometheus/client_golang v1.15.1/go.mod h1:e9yaBhRPU2pPNsZwE+JdQl0KEt github.com/prometheus/client_golang v1.17.0/go.mod h1:VeL+gMmOAxkS2IqfCq0ZmHSL+LjWfWDUmp1mBz9JgUY= github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho= -github.com/prometheus/client_golang v1.20.2 h1:5ctymQzZlyOON1666svgwn3s6IKWgfbjsejTMiXIyjg= -github.com/prometheus/client_golang v1.20.2/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI= github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= @@ -1215,8 +1205,6 @@ github.com/prometheus/common v0.44.0/go.mod h1:ofAIvZbQ1e/nugmZGz4/qCb9Ap1VoSTIO github.com/prometheus/common v0.45.0/go.mod h1:YJmSTw9BoKxJplESWWxlbyttQR4uaEcGyv9MZjVOJsY= github.com/prometheus/common v0.48.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8= -github.com/prometheus/common v0.58.0 h1:N+N8vY4/23r6iYfD3UQZUoJPnUYAo7v6LG5XZxjZTXo= -github.com/prometheus/common v0.58.0/go.mod h1:GpWM7dewqmVYcd7SmRaiWVe9SSqjf0UrwnYnpEZNuT0= github.com/prometheus/common v0.59.1 h1:LXb1quJHWm1P6wq/U824uxYi4Sg0oGvNeUm1z5dJoX0= github.com/prometheus/common v0.59.1/go.mod h1:GpWM7dewqmVYcd7SmRaiWVe9SSqjf0UrwnYnpEZNuT0= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= @@ -1440,8 +1428,7 @@ golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= -golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0= -golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0= golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1677,7 +1664,6 @@ golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220823224334-20c2bfdbfe24/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220829200755-d48e67d00261/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -1820,8 +1806,7 @@ golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s= golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= -golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24= -golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ= +golang.org/x/tools v0.25.0 h1:oFU9pkj/iJgs+0DT+VMHrx+oBKs/LJMV+Uvg78sl+fE= golang.org/x/tools v0.25.0/go.mod h1:/vtpO8WL1N9cQC3FN5zPqb//fRXskFHbLKk4OW1Q7rg= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -2189,8 +2174,6 @@ modernc.org/libc v1.16.17/go.mod h1:hYIV5VZczAmGZAnG15Vdngn5HSF5cSkbvfz2B7GRuVU= modernc.org/libc v1.16.19/go.mod h1:p7Mg4+koNjc8jkqwcoFBJx7tXkpj00G77X7A72jXPXA= modernc.org/libc v1.17.0/go.mod h1:XsgLldpP4aWlPlsjqKRdHPqCxCjISdHfM/yeWC5GyW0= modernc.org/libc v1.17.1/go.mod h1:FZ23b+8LjxZs7XtFMbSzL/EhPxNbfZbErxEHc7cbD9s= -modernc.org/libc v1.60.1 h1:at373l8IFRTkJIkAU85BIuUoBM4T1b51ds0E1ovPG2s= -modernc.org/libc v1.60.1/go.mod h1:xJuobKuNxKH3RUatS7GjR+suWj+5c2K7bi4m/S5arOY= modernc.org/libc v1.61.0 h1:eGFcvWpqlnoGwzZeZe3PWJkkKbM/3SUGyk1DVZQ0TpE= modernc.org/libc v1.61.0/go.mod h1:DvxVX89wtGTu+r72MLGhygpfi3aUGgZRdAYGCAVVud0= modernc.org/mathutil v1.2.2/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= diff --git a/net/http/http_test.go b/net/http/http_test.go index 01cfa410..29c10056 100644 --- a/net/http/http_test.go +++ b/net/http/http_test.go @@ -135,7 +135,7 @@ func TestRequestWebPage(t *testing.T) { Auth: &BasicAuth{name, pass}, }) if err != nil || resp.StatusCode != 200 || resp.Body != succ { - t.Errorf(resp.Status + ": " + resp.Body) + t.Error(resp.Status + ": " + resp.Body) } ctx, cancel := context.WithCancel(context.Background()) diff --git a/viz/d3.go b/viz/d3.go deleted file mode 100644 index df706393..00000000 --- a/viz/d3.go +++ /dev/null @@ -1,360 +0,0 @@ -// Copyright © by Jeff Foley 2017-2024. All rights reserved. -// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. -// SPDX-License-Identifier: Apache-2.0 - -package viz - -import ( - "io" - "text/template" - - oam "github.com/owasp-amass/open-asset-model" -) - -const d3Template = ` - - - - - OWASP Amass Network Mapping - - - - -
-
- - - - -` - -type d3Edge struct { - Source int - Destination int - Label string -} - -type d3Node struct { - ID int - Num int - Label string - Color string -} - -type d3Graph struct { - Name string - MaxNum int - Nodes []d3Node - Edges []d3Edge -} - -// WriteD3Data generates a HTML file that displays the Amass graph using D3. -func WriteD3Data(output io.Writer, nodes []Node, edges []Edge) error { - colors := map[string]string{ - string(oam.FQDN): "green", - string(oam.IPAddress): "orange", - string(oam.AutnumRecord): "yellow", - string(oam.Netblock): "pink", - string(oam.AutonomousSystem): "blue", - string(oam.SocketAddress): "blueviolet", - string(oam.ContactRecord): "cornsilk", - string(oam.EmailAddress): "chocolate", - string(oam.Location): "darkgray", - string(oam.Phone): "coral", - string(oam.Fingerprint): "red", - string(oam.Organization): "aqua", - string(oam.Person): "bisque", - string(oam.TLSCertificate): "aquamarine", - string(oam.URL): "azure", - string(oam.DomainRecord): "yellow", - string(oam.Source): "burlywood", - } - - graph := &d3Graph{Name: "OWASP Amass - Attack Surface Mapping"} - - for idx, node := range nodes { - graph.Nodes = append(graph.Nodes, d3Node{ - ID: idx, - Label: node.Title, - Color: colors[node.Type], - }) - } - - for _, edge := range edges { - graph.Edges = append(graph.Edges, d3Edge{ - Source: edge.From, - Destination: edge.To, - Label: edge.Title, - }) - graph.Nodes[edge.From].Num++ - graph.Nodes[edge.To].Num++ - } - - for _, node := range graph.Nodes { - if node.Num > graph.MaxNum { - graph.MaxNum = node.Num - } - } - - t := template.Must(template.New("graph").Parse(d3Template)) - return t.Execute(output, graph) -} diff --git a/viz/d3_test.go b/viz/d3_test.go deleted file mode 100644 index 5bf3a5c1..00000000 --- a/viz/d3_test.go +++ /dev/null @@ -1,271 +0,0 @@ -// Copyright © by Jeff Foley 2017-2024. All rights reserved. -// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. -// SPDX-License-Identifier: Apache-2.0 - -package viz - -import ( - "bytes" - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestWriteD3DataHappyPath(t *testing.T) { - buf := bytes.NewBufferString("") - err := WriteD3Data(buf, testNodes(), testEdges()) - assert.Nil(t, err) - - output := buf.String() - assert.Equalf(t, expectedD3Output, output, "Expected output to match") -} - -const expectedD3Output = ` - - - - - OWASP Amass Network Mapping - - - - -
-
- - - - -` diff --git a/viz/dot.go b/viz/dot.go deleted file mode 100644 index 76dc1a6d..00000000 --- a/viz/dot.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright © by Jeff Foley 2017-2024. All rights reserved. -// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. -// SPDX-License-Identifier: Apache-2.0 - -package viz - -import ( - "io" - "strconv" - "text/template" -) - -const dotTemplate = ` -digraph "{{ .Name }}" { - size = "7.5,10"; ranksep="2.5 equally"; ratio=auto; - -{{ range .Nodes }} - node [label="{{ .Label }}",color="{{ .Color }}",type="{{ .Type }}"]; n{{ .ID }}; -{{ end }} - -{{ range .Edges }} - n{{ .Source }} -> n{{ .Destination }} [label="{{ .Label }}"]; -{{ end }} -} -` - -type dotEdge struct { - Source string - Destination string - Label string -} - -type dotNode struct { - ID string - Label string - Color string - Type string -} - -type dotGraph struct { - Name string - Nodes []dotNode - Edges []dotEdge -} - -// WriteDOTData generates a DOT file to display the Amass graph. -func WriteDOTData(output io.Writer, nodes []Node, edges []Edge) error { - colors := map[string]string{ - "FQDN": "green", - "domain": "red", - "IPAddress": "orange", - "RIROrg": "cyan", - "Netblock": "pink", - "ASN": "blue", - } - - graph := &dotGraph{Name: "OWASP Amass Network Mapping"} - - for idx, node := range nodes { - graph.Nodes = append(graph.Nodes, dotNode{ - ID: strconv.Itoa(idx + 1), - Label: node.Label, - Color: colors[node.Type], - Type: node.Type, - }) - } - - for _, edge := range edges { - graph.Edges = append(graph.Edges, dotEdge{ - Source: strconv.Itoa(edge.From + 1), - Destination: strconv.Itoa(edge.To + 1), - Label: edge.Title, - }) - } - - t := template.Must(template.New("graph").Parse(dotTemplate)) - return t.Execute(output, graph) -} diff --git a/viz/dot_test.go b/viz/dot_test.go deleted file mode 100644 index 9bf7da2a..00000000 --- a/viz/dot_test.go +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright © by Jeff Foley 2017-2024. All rights reserved. -// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. -// SPDX-License-Identifier: Apache-2.0 - -package viz - -import ( - "bytes" - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestWriteDOTDataHappyPath(t *testing.T) { - buf := bytes.NewBufferString("") - err := WriteDOTData(buf, testNodes(), testEdges()) - assert.Nil(t, err) - - output := buf.String() - assert.Contains(t, output, "digraph \"OWASP Amass Network Mapping\"") - assert.Equal(t, expectedDotOutput, output, "Expected output to match") -} - -const expectedDotOutput = ` -digraph "OWASP Amass Network Mapping" { - size = "7.5,10"; ranksep="2.5 equally"; ratio=auto; - - - node [label="owasp.org",color="green",type="FQDN"]; n1; - - node [label="205.251.199.98",color="orange",type="IPAddress"]; n2; - - - - n1 -> n2 [label="a_record"]; - -} -` diff --git a/viz/gexf.go b/viz/gexf.go deleted file mode 100644 index 48bf67f1..00000000 --- a/viz/gexf.go +++ /dev/null @@ -1,179 +0,0 @@ -// Copyright © by Jeff Foley 2017-2024. All rights reserved. -// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. -// SPDX-License-Identifier: Apache-2.0 - -package viz - -import ( - "bufio" - "encoding/xml" - "io" - "strconv" - "time" -) - -const ( - xmlNS string = "http://www.gephi.org/gexf" - xmlNSVIZ string = "http://www.gephi.org/gexf/viz" - - classNode string = "node" - - modeStatic string = "static" - - edgeTypeDirected string = "directed" -) - -type gexfAttrValue struct { - For string `xml:"for,attr"` - Value string `xml:"value,attr"` -} - -type gexfAttribute struct { - ID string `xml:"id,attr"` - Title string `xml:"title,attr"` - Type string `xml:"type,attr"` - Default string `xml:"default,omitempty"` -} - -type gexfAttributes struct { - Class string `xml:"class,attr"` - Attrs []gexfAttribute `xml:"attribute"` -} - -type gexfParent struct { - For string `xml:"for,attr"` -} - -type gexfColor struct { - R uint8 `xml:"r,attr"` - G uint8 `xml:"g,attr"` - B uint8 `xml:"b,attr"` -} - -type gexfNode struct { - ID string `xml:"id,attr"` - Label string `xml:"label,attr,omitempty"` - Attrs []gexfAttrValue `xml:"attvalues>attvalue,omitempty"` - Parents []gexfParent `xml:"parents>parent"` - Color *gexfColor `xml:"viz:color,omitempty"` -} - -type gexfEdge struct { - ID string `xml:"id,attr"` - Label string `xml:"label,attr,omitempty"` - Type string `xml:"type,attr,omitempty"` - Source string `xml:"source,attr"` - Target string `xml:"target,attr"` - Weight float64 `xml:"weight,attr,omitempty"` - Attrs []gexfAttrValue `xml:"attvalues>attvalue,omitempty"` -} - -type gexfMeta struct { - LastModified string `xml:"lastmodifieddate,attr"` - Creator string `xml:"creator"` - Keywords string `xml:"keywords,omitempty"` - Desc string `xml:"description"` -} - -type gexfGraph struct { - Mode string `xml:"mode,attr,omitempty"` - EdgeType string `xml:"defaultedgetype,attr,omitempty"` - Attrs gexfAttributes `xml:"attributes,omitempty"` - Nodes []gexfNode `xml:"nodes>node,omitempty"` - Edges []gexfEdge `xml:"edges>edge,omitempty"` -} - -type gexf struct { - XMLName xml.Name - Version string `xml:"version,attr"` - Viz string `xml:"xmlns:viz,attr"` - Meta gexfMeta `xml:"meta"` - Graph gexfGraph `xml:"graph"` -} - -var ( - gexfGreen = &gexfColor{R: 34, G: 153, B: 84} - gexfRed = &gexfColor{R: 242, G: 44, B: 13} - gexfOrange = &gexfColor{R: 243, G: 156, B: 18} - gexfCyan = &gexfColor{R: 26, G: 243, B: 240} - gexfPink = &gexfColor{R: 243, G: 26, B: 188} - gexfBlue = &gexfColor{R: 26, G: 69, B: 243} -) - -// WriteGEXFData generates a GEXF file to display the Amass graph using Gephi. -func WriteGEXFData(output io.Writer, nodes []Node, edges []Edge) error { - bufwr := bufio.NewWriter(output) - - if _, err := bufwr.WriteString("\n"); err != nil { - return err - } - bufwr.Flush() - - doc := &gexf{ - XMLName: xml.Name{ - Space: xmlNS, - Local: "gexf", - }, - Version: "1.3", - Viz: xmlNSVIZ, - Meta: gexfMeta{ - LastModified: time.Now().UTC().Format("2006-01-02"), - Creator: "OWASP Amass - https://github.com/owasp-amass", - Desc: "OWASP Amass Network Mapping", - }, - Graph: gexfGraph{ - Mode: modeStatic, - EdgeType: edgeTypeDirected, - Attrs: gexfAttributes{ - Class: classNode, - Attrs: []gexfAttribute{ - {ID: "0", Title: "Title", Type: "string"}, - {ID: "1", Title: "Type", Type: "string"}, - }, - }, - }, - } - - for idx, n := range nodes { - var color *gexfColor - - switch n.Type { - case "FQDN": - color = gexfGreen - case "domain": - color = gexfRed - case "IPAddress": - color = gexfOrange - case "RIROrg": - color = gexfCyan - case "Netblock": - color = gexfPink - case "ASN": - color = gexfBlue - } - - doc.Graph.Nodes = append(doc.Graph.Nodes, gexfNode{ - ID: strconv.Itoa(idx), - Label: n.Label, - Attrs: []gexfAttrValue{ - {For: "0", Value: n.Title}, - {For: "1", Value: n.Type}, - }, - Color: color, - }) - } - - for idx, e := range edges { - doc.Graph.Edges = append(doc.Graph.Edges, gexfEdge{ - ID: strconv.Itoa(idx), - Label: e.Label, - Source: strconv.Itoa(e.From), - Target: strconv.Itoa(e.To), - }) - } - - enc := xml.NewEncoder(bufwr) - enc.Indent(" ", " ") - defer bufwr.Flush() - return enc.Encode(doc) -} diff --git a/viz/gexf_test.go b/viz/gexf_test.go deleted file mode 100644 index df735197..00000000 --- a/viz/gexf_test.go +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright © by Jeff Foley 2017-2024. All rights reserved. -// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. -// SPDX-License-Identifier: Apache-2.0 - -package viz - -import ( - "bytes" - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestWriteGEXFDataHappyPath(t *testing.T) { - buf := bytes.NewBufferString("") - err := WriteGEXFData(buf, testNodes(), testEdges()) - assert.Nil(t, err) - - output := buf.String() - assert.Contains(t, output, expectedGexfOutput, "Gexf output should contain") -} - -const expectedGexfOutput = `OWASP Amass - https://github.com/owasp-amass - OWASP Amass Network Mapping - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ` diff --git a/viz/viz.go b/viz/viz.go deleted file mode 100644 index 44ba1ed4..00000000 --- a/viz/viz.go +++ /dev/null @@ -1,246 +0,0 @@ -// Copyright © by Jeff Foley 2017-2024. All rights reserved. -// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. -// SPDX-License-Identifier: Apache-2.0 - -package viz - -import ( - "strings" - "time" - - assetdb "github.com/owasp-amass/asset-db" - "github.com/owasp-amass/asset-db/types" - oam "github.com/owasp-amass/open-asset-model" - "github.com/owasp-amass/open-asset-model/contact" - "github.com/owasp-amass/open-asset-model/domain" - oamreg "github.com/owasp-amass/open-asset-model/registration" - "github.com/owasp-amass/open-asset-model/source" -) - -// Edge represents an Amass graph edge in the viz package. -type Edge struct { - From, To int - Label string - Title string -} - -// Node represents an Amass graph node in the viz package. -type Node struct { - ID int - Type string - Label string - Title string -} - -// VizData returns the current state of the Graph as viz package Nodes and Edges. -func VizData(domains []string, since time.Time, db *assetdb.AssetDB) ([]Node, []Edge) { - if len(domains) == 0 { - return []Node{}, []Edge{} - } - - var fqdns []oam.Asset - for _, d := range domains { - fqdns = append(fqdns, &domain.FQDN{Name: d}) - } - - if !since.IsZero() { - since = since.UTC() - } - - next, err := db.FindByScope(fqdns, since) - if err != nil { - return []Node{}, []Edge{} - } - - var idx int - var nodes []Node - var edges []Edge - nodeToIdx := make(map[string]int) - for { - if len(next) == 0 { - break - } - - var assets []*types.Asset - assets = append(assets, next...) - next = []*types.Asset{} - - for _, a := range assets { - n := newNode(idx, a) - if n == nil { - continue - } - // Keep track of which indices nodes were assigned to - id := idx - if nid, found := nodeToIdx[n.Label]; !found { - idx++ - nodeToIdx[n.Label] = id - nodes = append(nodes, *n) - } else { - id = nid - } - // Determine relationship directions to follow on the graph - var in, out bool - var inRels, outRels []string - switch a.Asset.AssetType() { - case oam.FQDN: - out = true - if domainNameInScope(n.Label, domains) { - in = true - } - case oam.IPAddress: - in = true - inRels = append(inRels, "contains") - out = true - case oam.Netblock: - in = true - inRels = append(inRels, "announces") - case oam.AutonomousSystem: - out = true - outRels = append(outRels, "registration") - case oam.AutnumRecord: - out = true - case oam.SocketAddress: - case oam.ContactRecord: - out = true - case oam.EmailAddress: - out = true - case oam.Location: - out = true - case oam.Phone: - out = true - case oam.Fingerprint: - case oam.Organization: - out = true - case oam.Person: - out = true - case oam.TLSCertificate: - case oam.URL: - out = true - case oam.DomainRecord: - out = true - case oam.Source: - default: - } - // Obtain relations to additional assets in the graph - if out { - if rels, err := db.OutgoingRelations(a, since, outRels...); err == nil && len(rels) > 0 { - fromID := id - for _, rel := range rels { - if to, err := db.FindById(rel.ToAsset.ID, since); err == nil { - toID := idx - n2 := newNode(toID, to) - if n2 == nil { - continue - } - - if id, found := nodeToIdx[n2.Label]; !found { - idx++ - nodeToIdx[n2.Label] = toID - nodes = append(nodes, *n2) - next = append(next, to) - } else { - toID = id - } - - edges = append(edges, Edge{ - From: fromID, - To: toID, - Label: rel.Type, - Title: rel.Type, - }) - } - } - } - } - if in { - if rels, err := db.IncomingRelations(a, since, inRels...); err == nil && len(rels) > 0 { - toID := id - for _, rel := range rels { - if from, err := db.FindById(rel.FromAsset.ID, since); err == nil { - fromID := idx - n2 := newNode(fromID, from) - if n2 == nil { - continue - } - - if id, found := nodeToIdx[n2.Label]; !found { - idx++ - nodeToIdx[n2.Label] = fromID - nodes = append(nodes, *n2) - if rel.Type != "ptr_record" { - next = append(next, from) - } - } else { - fromID = id - } - - edges = append(edges, Edge{ - From: fromID, - To: toID, - Label: rel.Type, - Title: rel.Type, - }) - } - } - } - } - } - } - return nodes, edges -} - -func newNode(idx int, a *types.Asset) *Node { - if a == nil || a.Asset == nil { - return nil - } - asset := a.Asset - - key := asset.Key() - if key == "" { - return nil - } - - atype := string(asset.AssetType()) - if atype == string(oam.Source) { - return nil - } - - switch v := asset.(type) { - case *oamreg.AutnumRecord: - key = v.Handle + " - " + key - case *contact.ContactRecord: - key = "Found->" + key - case *contact.Location: - parts := []string{v.BuildingNumber, v.StreetName, v.City, v.Province, v.PostalCode} - key = strings.Join(parts, " ") - case *oamreg.DomainRecord: - key = "WHOIS: " + key - case *source.Source: - return nil - } - title := atype + ": " + key - - return &Node{ - ID: idx, - Type: atype, - Label: key, - Title: title, - } -} - -func domainNameInScope(name string, scope []string) bool { - var discovered bool - - n := strings.ToLower(strings.TrimSpace(name)) - for _, d := range scope { - d = strings.ToLower(d) - - if n == d || strings.HasSuffix(n, "."+d) { - discovered = true - break - } - } - - return discovered -}