Signed-off-by: Jess Frazelle <acidburn@microsoft.com>
This commit is contained in:
Jess Frazelle 2018-07-06 09:48:28 -04:00
parent ae31e7f249
commit d57f4f0145
No known key found for this signature in database
GPG Key ID: C0B444E6A3EFD4C1

View File

@ -60,30 +60,7 @@ func main() {
go func(ip string) {
defer wg.Done()
for port := beginPort; port <= endPort; port++ {
// Check if the port is open.
ok := portOpen(ip, port)
if !ok {
return
}
// Check if it's a kubernetes dashboard.
ok = isKubernetesDashboard(ip, port)
if !ok {
return
}
fmt.Printf("%s:%d\n", ip, port)
// Get the info for the ip address.
info, err := getIPInfo(ip)
if err != nil {
logrus.Warnf("ip info err: %v", err)
return
}
fmt.Printf("%s:%d\t%s\t%s\t%s\n",
ip, port,
info.Net.Organization.Handle, info.Net.Organization.Name, info.Net.Organization.Reference)
}
scanIP(ip)
}(ip.String())
}
@ -93,6 +70,33 @@ func main() {
logrus.Infof("Scan took: %s", since.String())
}
func scanIP(ip string) {
for port := beginPort; port <= endPort; port++ {
// Check if the port is open.
ok := portOpen(ip, port)
if !ok {
return
}
// Check if it's a kubernetes dashboard.
ok = isKubernetesDashboard(ip, port)
if !ok {
return
}
fmt.Printf("%s:%d\n", ip, port)
// Get the info for the ip address.
info, err := getIPInfo(ip)
if err != nil {
logrus.Warnf("ip info err: %v", err)
return
}
fmt.Printf("%s:%d\t%s\t%s\t%s\n",
ip, port,
info.Net.Organization.Handle, info.Net.Organization.Name, info.Net.Organization.Reference)
}
}
func portOpen(ip string, port int) bool {
c, err := net.DialTimeout("tcp", fmt.Sprintf("%s:%d", ip, port), 2*time.Second)
if err != nil {