From 632466a0222b73b45cfdeded8b4f601bd1d4bbef Mon Sep 17 00:00:00 2001 From: perp Date: Wed, 2 Aug 2023 04:59:26 +0100 Subject: [PATCH] :sparkles: Stats command Added stats command (Broken) --- internal/shodan/stats.go | 43 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 internal/shodan/stats.go diff --git a/internal/shodan/stats.go b/internal/shodan/stats.go new file mode 100644 index 0000000..d74bde5 --- /dev/null +++ b/internal/shodan/stats.go @@ -0,0 +1,43 @@ +package shodan + +import ( + "context" + "fmt" + + "github.com/ns3777k/go-shodan/v4/shodan" + + "git.tcp.direct/perp/shogo/internal/utils" +) + +// Stats query +type Stats struct { + Query string // Search query + Page int // Current page + Results chan string // Results channel +} + +// Return facet stats on a search +func (s *Stats) Stats() { + // Setup options + options := &shodan.HostQueryOptions{ + Query: s.Query, + Facets: "US", + Page: s.Page, + } + + // Get results + results, err := utils.Client.GetHostsForQuery(context.Background(), options) + if err != nil { + fmt.Printf("%s: %s\n", utils.Red("Error"), err.Error()) + s.Results <- "" + return + } + + // Print results + for host := range results.Matches { + fmt.Println(results.Matches[host]) + } + s.Results <- "" +} + +// Todo: Fix this