49 lines
942 B
Go
49 lines
942 B
Go
package host
|
|
|
|
import (
|
|
"sync"
|
|
|
|
"git.loafle.net/overflow_scanner/probe/discovery/protocol/arp"
|
|
"git.loafle.net/overflow_scanner/probe/discovery/protocol/icmp"
|
|
"git.loafle.net/overflow_scanner/probe/discovery/session"
|
|
)
|
|
|
|
func Scan(discoverySession session.DiscoverySession) error {
|
|
targetHosts := discoverySession.TargetHosts()
|
|
if nil == targetHosts || 0 == len(targetHosts) || nil == discoverySession.DiscoverHost() {
|
|
return nil
|
|
}
|
|
|
|
if nil != discoverySession.PCapScanner() {
|
|
return privilegedScan(discoverySession)
|
|
}
|
|
|
|
return unprivilegedScan(discoverySession)
|
|
}
|
|
|
|
func privilegedScan(discoverySession session.DiscoverySession) error {
|
|
var wg sync.WaitGroup
|
|
|
|
wg.Add(1)
|
|
go func() {
|
|
defer wg.Done()
|
|
|
|
arp.Scan(discoverySession)
|
|
}()
|
|
|
|
wg.Add(1)
|
|
go func() {
|
|
defer wg.Done()
|
|
|
|
icmp.Scan(discoverySession)
|
|
}()
|
|
|
|
wg.Wait()
|
|
return nil
|
|
}
|
|
|
|
func unprivilegedScan(discoverySession session.DiscoverySession) error {
|
|
|
|
return nil
|
|
}
|