Skip to content

Commit

Permalink
updated to OAM v0.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
caffix committed Sep 7, 2024
1 parent 0d81b46 commit 422d5b9
Show file tree
Hide file tree
Showing 5 changed files with 223 additions and 87 deletions.
18 changes: 16 additions & 2 deletions cmd/amass/subs.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
oam "github.com/owasp-amass/open-asset-model"
"github.com/owasp-amass/open-asset-model/domain"
"github.com/owasp-amass/open-asset-model/network"
"github.com/owasp-amass/open-asset-model/whois"
)

const subsUsageMsg = "subs [options] -d domain"
Expand Down Expand Up @@ -355,7 +356,7 @@ func addInfrastructureInfo(lookup outLookup, cache *ASNCache) []*Output {

func fillCache(cache *ASNCache, db *graph.Graph) error {
start := time.Now().Add(-730 * time.Hour)
assets, err := db.DB.FindByType(oam.ASN, start)
assets, err := db.DB.FindByType(oam.AutonomousSystem, start)
if err != nil {
return err
}
Expand All @@ -366,7 +367,20 @@ func fillCache(cache *ASNCache, db *graph.Graph) error {
continue
}

desc := db.ReadASDescription(context.Background(), as.Number, start)
var desc string
rels, err := db.DB.OutgoingRelations(a, start, "registration")
if err != nil || len(rels) == 0 {
continue
}

for _, rel := range rels {
if asset, err := db.DB.FindById(rel.ID, start); err == nil && asset != nil {
if autnum, ok := asset.Asset.(*whois.AutnumRecord); ok && autnum != nil {
desc = autnum.Handle + " - " + autnum.Name
break
}
}
}
if desc == "" {
continue
}
Expand Down
12 changes: 5 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module github.com/owasp-amass/amass/v4

go 1.21.3

toolchain go1.21.4
go 1.21.4

require (
github.com/PuerkitoBio/goquery v1.9.2
Expand All @@ -11,10 +9,10 @@ require (
github.com/fatih/color v1.17.0
github.com/geziyor/geziyor v0.0.0-20240812061556-229b8ca83ac1
github.com/miekg/dns v1.1.62
github.com/owasp-amass/asset-db v0.5.2
github.com/owasp-amass/config v0.5.1
github.com/owasp-amass/engine v0.0.0-20240113161848-1f756cf7789d
github.com/owasp-amass/open-asset-model v0.5.1
github.com/owasp-amass/asset-db v0.6.0
github.com/owasp-amass/config v0.6.0
github.com/owasp-amass/engine v0.0.1
github.com/owasp-amass/open-asset-model v0.6.0
github.com/owasp-amass/resolve v0.8.1
github.com/samber/slog-common v0.17.1
github.com/samber/slog-syslog/v2 v2.5.0
Expand Down
28 changes: 14 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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.42 h1:BVWDOb2VVHQC5k3m6oa0XhDnxltLLrU4so7x/u39Zu4=
github.com/99designs/gqlgen v0.17.42/go.mod h1:GQ6SyMhwFbgHR0a8r2Wn8fYgEwPxxmndLFPhU63+cJE=
github.com/99designs/gqlgen v0.17.49 h1:b3hNGexHd33fBSAd4NDT/c3NCcQzcAVkknhN9ym36YQ=
github.com/99designs/gqlgen v0.17.49/go.mod h1:tC8YFVZMed81x7UJ7ORUwXF4Kn6SXuucFqQBhN8+BU0=
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=
Expand Down Expand Up @@ -1133,14 +1133,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.5.2 h1:/BB0VTM6v3dogJXmE1rOEQBqymG7IQlynZvecEJ0KFo=
github.com/owasp-amass/asset-db v0.5.2/go.mod h1:j749jMl9ndqqrn7x08kfyfMj6Brsjb7oCQEUfKGX55U=
github.com/owasp-amass/config v0.5.1 h1:6zbBuak1qSp2QfZt6zy8LosJDwqrgNR7MUEFhGppfVw=
github.com/owasp-amass/config v0.5.1/go.mod h1:k7eRURfFpkaoyL5SjzlMMUm4Y8bA5ZU56oFMAcc0DPs=
github.com/owasp-amass/engine v0.0.0-20240113161848-1f756cf7789d h1:8dff2nEu/VShGpnH1sdv9IhFeYKQN8elYHB4M77vmIc=
github.com/owasp-amass/engine v0.0.0-20240113161848-1f756cf7789d/go.mod h1:vH7vnf4Qe1Mg+J5WQolCm/rtBfvAcGWVfG/fSLol1VY=
github.com/owasp-amass/open-asset-model v0.5.1 h1:NjPExuxNiXa4RkIttHcPBy0m+NRulF/SEZqwjWZOVQc=
github.com/owasp-amass/open-asset-model v0.5.1/go.mod h1:DOX+SiD6PZBroSMnsILAmpf0SHi6TVpqjV4uNfBeg7g=
github.com/owasp-amass/asset-db v0.6.0 h1:UIaWAtNdtQ2AZZHUQw/4cZN73VquhXKbV2nILiescLQ=
github.com/owasp-amass/asset-db v0.6.0/go.mod h1:MdJQWLhi2DG+/vCQX3QTPZrIr/UP+egYlLeAmBqJJSE=
github.com/owasp-amass/config v0.6.0 h1:XpMvEFAf7MbMz0TfiI92edrpWQaPOuPquQInTNN+ERo=
github.com/owasp-amass/config v0.6.0/go.mod h1:AlPiMXpynSE8cpT3C30zPC/8aBvurxREacCQyrL4KqA=
github.com/owasp-amass/engine v0.0.1 h1:7OoSXRyv8S+f0UJWaq76EVB+DgRTWr0fQbcoJKI/+74=
github.com/owasp-amass/engine v0.0.1/go.mod h1:SU2QpQAlFCcXOjtH33wc8xhqpTkRYkpTksVGfCfjoo0=
github.com/owasp-amass/open-asset-model v0.6.0 h1:mfuUKMbcRhdzC1Li8dt7FfBwsOPKjoLi0tozuzRaB+g=
github.com/owasp-amass/open-asset-model v0.6.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=
Expand Down Expand Up @@ -1254,8 +1254,8 @@ github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY=
github.com/sosodev/duration v1.2.0 h1:pqK/FLSjsAADWY74SyWDCjOcd5l7H8GSnnOGEB9A1Us=
github.com/sosodev/duration v1.2.0/go.mod h1:RQIBBX0+fMLc/D9+Jb/fwvVmo0eZvDDEERAikUR6SDg=
github.com/sosodev/duration v1.3.1 h1:qtHBDMQ6lvMQsL15g4aopM4HEfOaYuhWBw3NPTtlqq4=
github.com/sosodev/duration v1.3.1/go.mod h1:RQIBBX0+fMLc/D9+Jb/fwvVmo0eZvDDEERAikUR6SDg=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
Expand Down Expand Up @@ -1296,8 +1296,8 @@ github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqri
github.com/tylertreat/BoomFilters v0.0.0-20210315201527-1a82519a3e43 h1:QEePdg0ty2r0t1+qwfZmQ4OOl/MB2UXIeJSpIZv56lg=
github.com/tylertreat/BoomFilters v0.0.0-20210315201527-1a82519a3e43/go.mod h1:OYRfF6eb5wY9VRFkXJH8FFBi3plw2v+giaIu7P054pM=
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
github.com/vektah/gqlparser/v2 v2.5.10 h1:6zSM4azXC9u4Nxy5YmdmGu4uKamfwsdKTwp5zsEealU=
github.com/vektah/gqlparser/v2 v2.5.10/go.mod h1:1rCcfwB2ekJofmluGWXMSEnPMZgbxzwj6FaZ/4OT8Cc=
github.com/vektah/gqlparser/v2 v2.5.16 h1:1gcmLTvs3JLKXckwCwlUagVn/IlV2bwqle0vJ0vy5p8=
github.com/vektah/gqlparser/v2 v2.5.16/go.mod h1:1lz1OeCqgQbQepsGxPVywrjdBHW2T08PUS3pJqepRww=
github.com/xhit/go-str2duration v1.2.0/go.mod h1:3cPSlfZlUHVlneIVfePFWcJZsuwf+P1v2SRTV4cUmp4=
github.com/xhit/go-str2duration/v2 v2.1.0/go.mod h1:ohY8p+0f07DiV6Em5LKB0s2YpLtXVyJfNt1+BlmyAsU=
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
Expand Down
70 changes: 56 additions & 14 deletions viz/d3.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ package viz
import (
"io"
"text/template"

oam "github.com/owasp-amass/open-asset-model"
)

const d3Template = `
Expand Down Expand Up @@ -68,7 +70,7 @@ var div = d3.select("body").append("div")
.attr("class", "tooltip")
.style("opacity", 0);
var r = 5,
var r = 9,
max = {{ .MaxNum }},
simulation = d3.forceSimulation()
.nodes(graph.nodes)
Expand All @@ -79,7 +81,7 @@ var r = 5,
.id(function(d) { return d.id; }))
.force("charge", d3.forceManyBody()
.strength(nodeChargeStrength)
.distanceMax(graphWidth *2))
.distanceMax(graphWidth))
.force("collide", d3.forceCollide()
.radius(nodeCollideRadius))
.force("center", d3.forceCenter(graphWidth / 2, graphHeight / 2))
Expand All @@ -100,33 +102,61 @@ function nodePercent(n) {
}
function nodeRadius(n) {
return (1.5 * r) + ((3 * r) * nodePercent(n));
var p = nodePercent(n);
if (p > 0.1 && p < 0.5) {
p = p * 2;
}
if (p < 0.1) {
p = 0.1;
}
return (1 * r) + ((3 * r) * p);
}
function nodeCollideRadius(n) {
return nodeRadius(n) + 1;
return nodeRadius(n) * 2.5;
}
function nodeLinkDistance(e) {
var n1 = graph.nodes[e.source.id],
n2 = graph.nodes[e.target.id];
var avg = (nodePercent(n1) + nodePercent(n2)) / 2;
return 60 * avg;
if (avg > 0.7) {
avg = 0.7;
}
if (avg < 0.5) {
avg = 0.5;
}
return 100 * avg;
}
function nodeLinkStrength(e) {
var n1 = graph.nodes[e.source.id],
n2 = graph.nodes[e.target.id];
var avg = (nodePercent(n1) + nodePercent(n2)) / 2;
var fp,
p1 = nodePercent(n1),
p2 = nodePercent(n2);
if (p1 > p2) {
fp = p1;
} else {
fp = p2;
}
return 1 - (1 * avg);
if (fp > 0.7) {
fp = 0.7;
}
if (fp < 0.5) {
fp = 0.5;
}
return 1 - (1 * fp);
}
function nodeChargeStrength(n) {
return -100 + (-300 * nodePercent(n));
return -300 + (-50 * nodePercent(n));
}
function zoomed() {
Expand Down Expand Up @@ -280,11 +310,23 @@ type d3Graph struct {
// 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{
"FQDN": "green",
"IPAddress": "orange",
"RIROrg": "cyan",
"Netblock": "pink",
"ASN": "blue",
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"}
Expand Down
Loading

0 comments on commit 422d5b9

Please sign in to comment.