save
This commit is contained in:
parent
5d223c3886
commit
7f83f720d8
|
@ -200,7 +200,7 @@ Node(func: allofterms(full, $a)) {
|
|||
}
|
||||
if len(n.Result) != 0 {
|
||||
time.Sleep(time.Duration(2) * time.Second)
|
||||
logrus.Info("Found match for ", target)
|
||||
logrus.Info("Found paste match for ", target)
|
||||
// TODO: review time and id to be updated on new resulsts
|
||||
|
||||
for _, res := range n.Result {
|
||||
|
@ -372,7 +372,7 @@ func runShodanMatcher(target string, graphClient *dgo.Dgraph) {
|
|||
}
|
||||
if len(n.Result) != 0 {
|
||||
time.Sleep(time.Duration(2) * time.Second)
|
||||
logrus.Info("Found match for ", target)
|
||||
logrus.Info("Found shodan match for ", target)
|
||||
// TODO: review time and id to be updated on new resulsts
|
||||
|
||||
for _, res := range n.Result {
|
||||
|
|
|
@ -72,66 +72,66 @@ func (s *ShodanPlugin) doRun(graphClient *dgo.Dgraph) {
|
|||
|
||||
shodanNode := models.BuildShodanNode(banner)
|
||||
// first filter poc
|
||||
// if shodanNode.Data.HTML != "" {
|
||||
if !filters.RunIPFilters(shodanNode.HostData.IP) {
|
||||
hostnames := shodanNode.HostData.Hostnames
|
||||
var hostNotInFilters, domainNotInFilters bool
|
||||
if len(hostnames) != 0 {
|
||||
for _, hostname := range hostnames {
|
||||
hostNotInFilters = filters.RunDomainFilters(hostname)
|
||||
if hostNotInFilters {
|
||||
// logrus.Info("host", hostname " not in filters")
|
||||
// keep track of new hostnames
|
||||
// saveSingleValues(conn, "shodan_stream", "hostname", shodanNode.ID, hostname)
|
||||
if shodanNode.HostData.HTML != "" {
|
||||
if !filters.RunIPFilters(shodanNode.HostData.IP) {
|
||||
hostnames := shodanNode.HostData.Hostnames
|
||||
var hostNotInFilters, domainNotInFilters bool
|
||||
if len(hostnames) != 0 {
|
||||
for _, hostname := range hostnames {
|
||||
hostNotInFilters = filters.RunDomainFilters(hostname)
|
||||
if hostNotInFilters {
|
||||
logrus.Info("host", hostname, " not in filters")
|
||||
// keep track of new hostnames
|
||||
// saveSingleValues(conn, "shodan_stream", "hostname", shodanNode.ID, hostname)
|
||||
}
|
||||
}
|
||||
}
|
||||
domains := shodanNode.HostData.Domains
|
||||
if len(domains) != 0 {
|
||||
for _, domain := range domains {
|
||||
domainNotInFilters = filters.RunDomainFilters(domain)
|
||||
logrus.Info("domain", domain, "not in filters")
|
||||
// keep trakc of new domains
|
||||
// saveSingleValues(conn, "shodan_stream", "domain", shodanNode.ID, domain)
|
||||
}
|
||||
}
|
||||
if domainNotInFilters && hostNotInFilters {
|
||||
// models.SaveShodanNode("raw_shodan.json", shodanNode)
|
||||
mainNode := models.BuildNode("shodan", "shodan_stream", shodanNode.ID)
|
||||
models.SaveNode("nodes.json", mainNode)
|
||||
// edge := models.BuildEdge("shodan", structs.Map(shodanNode), structs.Map(mainNode))
|
||||
// models.SaveEdge(edge)
|
||||
e := models.Node{
|
||||
ID: mainNode.ID,
|
||||
Type: mainNode.Type,
|
||||
NData: mainNode.NData,
|
||||
Created: mainNode.Created,
|
||||
Modified: mainNode.Modified,
|
||||
ShodanNode: *shodanNode,
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
mu := &api.Mutation{
|
||||
CommitNow: true,
|
||||
}
|
||||
|
||||
pb, err := json.Marshal(e)
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
mu.SetJson = pb
|
||||
|
||||
_, err = graphClient.NewTxn().Mutate(ctx, mu)
|
||||
if err != nil {
|
||||
logrus.Error(err)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
logrus.Info(shodanNode.HostData.IP, "is akamain")
|
||||
}
|
||||
domains := shodanNode.HostData.Domains
|
||||
if len(domains) != 0 {
|
||||
for _, domain := range domains {
|
||||
domainNotInFilters = filters.RunDomainFilters(domain)
|
||||
// logrus.Info("domain", domain, "not in filters")
|
||||
// keep trakc of new domains
|
||||
// saveSingleValues(conn, "shodan_stream", "domain", shodanNode.ID, domain)
|
||||
}
|
||||
}
|
||||
if domainNotInFilters && hostNotInFilters {
|
||||
// models.SaveShodanNode("raw_shodan.json", shodanNode)
|
||||
mainNode := models.BuildNode("shodan", "shodan_stream", shodanNode.ID)
|
||||
models.SaveNode("nodes.json", mainNode)
|
||||
// edge := models.BuildEdge("shodan", structs.Map(shodanNode), structs.Map(mainNode))
|
||||
// models.SaveEdge(edge)
|
||||
e := models.Node{
|
||||
ID: mainNode.ID,
|
||||
Type: mainNode.Type,
|
||||
NData: mainNode.NData,
|
||||
Created: mainNode.Created,
|
||||
Modified: mainNode.Modified,
|
||||
ShodanNode: *shodanNode,
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
mu := &api.Mutation{
|
||||
CommitNow: true,
|
||||
}
|
||||
|
||||
pb, err := json.Marshal(e)
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
mu.SetJson = pb
|
||||
|
||||
_, err = graphClient.NewTxn().Mutate(ctx, mu)
|
||||
if err != nil {
|
||||
logrus.Error(err)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
logrus.Info(shodanNode.HostData.IP, "is akamain")
|
||||
}
|
||||
}
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue