|
@@ -25,10 +25,10 @@ Need to work with with a database schema in mind, and revolve functionality arou
|
|
*/
|
|
*/
|
|
|
|
|
|
type Host struct {
|
|
type Host struct {
|
|
- Fqdn string // The FQDN of the address targeted as per the systems default resolver
|
|
|
|
- IpAddress string // the IPv4 address (no ipv6 support yet)
|
|
|
|
- PingResponse bool // boolean value representing if the host responded to ICMP
|
|
|
|
- ListeningPorts []map[int]string // list of maps depicting a port number -> service name
|
|
|
|
|
|
+ Fqdn string // The FQDN of the address targeted as per the systems default resolver
|
|
|
|
+ IpAddress string // the IPv4 address (no ipv6 support yet)
|
|
|
|
+ PingResponse bool // boolean value representing if the host responded to ICMP
|
|
|
|
+ ListeningPorts map[int]string // list of maps depicting a port number -> service name
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -41,8 +41,7 @@ func PortWalk(addr string, portmap map[int]string) *Host {
|
|
wg := &sync.WaitGroup{}
|
|
wg := &sync.WaitGroup{}
|
|
out := []*PortScanResult{}
|
|
out := []*PortScanResult{}
|
|
|
|
|
|
- ports := RetrieveScanDirectives()
|
|
|
|
- for p, s := range ports.Pairs {
|
|
|
|
|
|
+ for p, s := range portmap {
|
|
wg.Add(1)
|
|
wg.Add(1)
|
|
go func(target string, p int, s string) {
|
|
go func(target string, p int, s string) {
|
|
defer wg.Done()
|
|
defer wg.Done()
|
|
@@ -50,13 +49,12 @@ func PortWalk(addr string, portmap map[int]string) *Host {
|
|
}(addr, p, s)
|
|
}(addr, p, s)
|
|
}
|
|
}
|
|
wg.Wait()
|
|
wg.Wait()
|
|
- host := &Host{IpAddress: addr, ListeningPorts: []map[int]string{}}
|
|
|
|
|
|
+ host := &Host{IpAddress: addr, ListeningPorts: map[int]string{}}
|
|
for i := range out {
|
|
for i := range out {
|
|
if out[i].Listening {
|
|
if out[i].Listening {
|
|
- host.ListeningPorts = append(host.ListeningPorts, map[int]string{
|
|
|
|
- out[i].PortNumber: out[i].Service,
|
|
|
|
- })
|
|
|
|
|
|
+ host.ListeningPorts[out[i].PortNumber] = out[i].Service
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
return host
|
|
return host
|
|
|
|
|