unprivileged icmp added
This commit is contained in:
parent
99166af860
commit
5956cae93f
|
@ -1,19 +1,26 @@
|
||||||
package icmp
|
package icmp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
omm "git.loafle.net/overflow/model/meta"
|
"git.loafle.net/overflow_scanner/probe/discovery/protocol/icmp/privileged"
|
||||||
|
"git.loafle.net/overflow_scanner/probe/discovery/protocol/icmp/unprivileged"
|
||||||
"git.loafle.net/overflow_scanner/probe/discovery/session"
|
"git.loafle.net/overflow_scanner/probe/discovery/session"
|
||||||
|
"git.loafle.net/overflow_scanner/probe/internal/pcap"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Scan(discoverySession session.DiscoverySession) error {
|
func Scan(discoverySession session.DiscoverySession) error {
|
||||||
metaIPTypeEnum := omm.ToMetaIPTypeEnum(discoverySession.Zone().MetaIPType)
|
zone := discoverySession.Zone()
|
||||||
|
|
||||||
switch metaIPTypeEnum {
|
var _privileged bool
|
||||||
case omm.MetaIPTypeEnumV4:
|
|
||||||
return scanV4(discoverySession)
|
_, err := pcap.RetainScanner(zone)
|
||||||
case omm.MetaIPTypeEnumV6:
|
if nil == err {
|
||||||
return scanV4(discoverySession)
|
pcap.ReleaseScanner(zone)
|
||||||
|
_privileged = true
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
if _privileged {
|
||||||
|
return privileged.Scan(discoverySession)
|
||||||
|
}
|
||||||
|
|
||||||
|
return unprivileged.Scan(discoverySession)
|
||||||
}
|
}
|
||||||
|
|
19
discovery/protocol/icmp/privileged/icmp.go
Normal file
19
discovery/protocol/icmp/privileged/icmp.go
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
package privileged
|
||||||
|
|
||||||
|
import (
|
||||||
|
omm "git.loafle.net/overflow/model/meta"
|
||||||
|
"git.loafle.net/overflow_scanner/probe/discovery/session"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Scan(discoverySession session.DiscoverySession) error {
|
||||||
|
metaIPTypeEnum := omm.ToMetaIPTypeEnum(discoverySession.Zone().MetaIPType)
|
||||||
|
|
||||||
|
switch metaIPTypeEnum {
|
||||||
|
case omm.MetaIPTypeEnumV4:
|
||||||
|
return scanV4(discoverySession)
|
||||||
|
case omm.MetaIPTypeEnumV6:
|
||||||
|
return scanV4(discoverySession)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package icmp
|
package privileged
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
|
@ -1,4 +1,4 @@
|
||||||
package icmp
|
package privileged
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
|
@ -1,4 +1,4 @@
|
||||||
package icmp
|
package privileged
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
10
discovery/protocol/icmp/unprivileged/icmp.go
Normal file
10
discovery/protocol/icmp/unprivileged/icmp.go
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
package unprivileged
|
||||||
|
|
||||||
|
import (
|
||||||
|
"git.loafle.net/overflow_scanner/probe/discovery/session"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Scan(discoverySession session.DiscoverySession) error {
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
|
@ -133,8 +133,6 @@ func scanV2(target net.IP, discoverySession session.DiscoverySession, credential
|
||||||
meta[val.Oid.String()] = val.Variable.String()
|
meta[val.Oid.String()] = val.Variable.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print(meta)
|
|
||||||
|
|
||||||
h := discoverySession.AddHost(&omd.Host{
|
h := discoverySession.AddHost(&omd.Host{
|
||||||
MetaIPType: discoverySession.Zone().MetaIPType,
|
MetaIPType: discoverySession.Zone().MetaIPType,
|
||||||
Name: "",
|
Name: "",
|
||||||
|
@ -151,12 +149,14 @@ func scanV2(target net.IP, discoverySession session.DiscoverySession, credential
|
||||||
Host: h,
|
Host: h,
|
||||||
})
|
})
|
||||||
|
|
||||||
discoverySession.AddService(&omd.Service{
|
s := discoverySession.AddService(&omd.Service{
|
||||||
MetaCryptoType: omm.ToMetaCryptoType(omm.MetaCryptoTypeEnumNONE),
|
MetaCryptoType: omm.ToMetaCryptoType(omm.MetaCryptoTypeEnumNONE),
|
||||||
Key: "SNMP",
|
Key: "SNMP",
|
||||||
Name: "SNMP V2c",
|
Name: "SNMP V2c",
|
||||||
Port: p,
|
Port: p,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
log.Printf("Host: %v, Port: %v, Service: %v", h, p, s)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ Loop:
|
||||||
wg.Done()
|
wg.Done()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
scanPort(discoverySession, ports, targetHost, port, timeout)
|
tryConnect(discoverySession, ports, targetHost, port, timeout)
|
||||||
}(portNumber)
|
}(portNumber)
|
||||||
|
|
||||||
timer := time.NewTimer(time.Microsecond * 100)
|
timer := time.NewTimer(time.Microsecond * 100)
|
||||||
|
@ -68,7 +68,7 @@ Loop:
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func scanPort(discoverySession session.DiscoverySession, ports map[int]*omd.Port, targetHost *omd.Host, port int, timeout time.Duration) {
|
func tryConnect(discoverySession session.DiscoverySession, ports map[int]*omd.Port, targetHost *omd.Host, port int, timeout time.Duration) {
|
||||||
addr := net.JoinHostPort(targetHost.Address, strconv.Itoa(port))
|
addr := net.JoinHostPort(targetHost.Address, strconv.Itoa(port))
|
||||||
conn, err := net.DialTimeout("tcp", addr, timeout)
|
conn, err := net.DialTimeout("tcp", addr, timeout)
|
||||||
dp := discoverySession.DiscoverPort()
|
dp := discoverySession.DiscoverPort()
|
||||||
|
@ -76,7 +76,7 @@ func scanPort(discoverySession session.DiscoverySession, ports map[int]*omd.Port
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if strings.Contains(err.Error(), "too many open files") {
|
if strings.Contains(err.Error(), "too many open files") {
|
||||||
time.Sleep(timeout)
|
time.Sleep(timeout)
|
||||||
scanPort(discoverySession, ports, targetHost, port, timeout)
|
tryConnect(discoverySession, ports, targetHost, port, timeout)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package upnp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
|
|
||||||
omd "git.loafle.net/overflow/model/discovery"
|
omd "git.loafle.net/overflow/model/discovery"
|
||||||
omu "git.loafle.net/overflow/model/util"
|
omu "git.loafle.net/overflow/model/util"
|
||||||
|
@ -28,6 +29,8 @@ LOOP:
|
||||||
continue LOOP
|
continue LOOP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Print(rd)
|
||||||
|
|
||||||
discoverySession.AddHost(&omd.Host{
|
discoverySession.AddHost(&omd.Host{
|
||||||
MetaIPType: discoverySession.Zone().MetaIPType,
|
MetaIPType: discoverySession.Zone().MetaIPType,
|
||||||
Name: rd.FriendlyName,
|
Name: rd.FriendlyName,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user