✨ Stats command
Added stats command (Broken)
This commit is contained in:
parent
d3744a9dff
commit
632466a022
43
internal/shodan/stats.go
Normal file
43
internal/shodan/stats.go
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user