misc: small fix or general refactoring i did not bother commenting

This commit is contained in:
evilsocket 2018-02-17 06:04:16 +01:00
commit eb5a72a44c
9 changed files with 234 additions and 220 deletions

View file

@ -154,7 +154,7 @@ func (s *DHCP6Spoofer) dhcpAdvertise(pkt gopacket.Packet, solicit dhcp6.Packet,
}
var ip net.IP
if t, found := s.Session.Targets.Targets[target.String()]; found == true {
if t, found := s.Session.Lan.Hosts[target.String()]; found == true {
ip = t.IP
} else {
log.Warning("Address %s not known, using random identity association address.", target.String())
@ -312,7 +312,7 @@ func (s *DHCP6Spoofer) dhcpReply(toType string, pkt gopacket.Packet, req dhcp6.P
addr = net.IP(raw[0])
}
if t, found := s.Session.Targets.Targets[target.String()]; found == true {
if t, found := s.Session.Lan.Hosts[target.String()]; found == true {
log.Info("[%s] IPv6 address %s is now assigned to %s", core.Green("dhcp6"), addr.String(), t)
} else {
log.Info("[%s] IPv6 address %s is now assigned to %s", core.Green("dhcp6"), addr.String(), target)

View file

@ -111,7 +111,7 @@ func (s *DNSSpoofer) dnsReply(pkt gopacket.Packet, peth *layers.Ethernet, pudp *
redir := fmt.Sprintf("(->%s)", s.Address)
who := target.String()
if t, found := s.Session.Targets.Targets[target.String()]; found == true {
if t, found := s.Session.Lan.Hosts[target.String()]; found == true {
who = t.String()
}

View file

@ -71,19 +71,19 @@ func (d Discovery) Author() string {
func (d *Discovery) runDiff(cache network.ArpTable) {
// check for endpoints who disappeared
var rem network.ArpTable = make(network.ArpTable)
for mac, t := range d.Session.Targets.Targets {
for mac, t := range d.Session.Lan.Hosts {
if _, found := cache[mac]; found == false {
rem[mac] = t.IpAddress
}
}
for mac, ip := range rem {
d.Session.Targets.Remove(ip, mac)
d.Session.Lan.Remove(ip, mac)
}
// now check for new friends ^_^
for ip, mac := range cache {
d.Session.Targets.AddIfNew(ip, mac)
d.Session.Lan.AddIfNew(ip, mac)
}
}

View file

@ -53,7 +53,7 @@ func (d *Discovery) getRow(e *network.Endpoint) []string {
addr := e.IpAddress
mac := e.HwAddress
if d.Session.Targets.WasMissed(e.HwAddress) == true {
if d.Session.Lan.WasMissed(e.HwAddress) == true {
// if endpoint was not found in ARP at least once
addr = core.Dim(addr)
mac = core.Dim(mac)
@ -113,7 +113,7 @@ func (d *Discovery) showTable(header []string, rows [][]string) {
}
func (d *Discovery) Show(by string) error {
targets := d.Session.Targets.List()
targets := d.Session.Lan.List()
if by == "seen" {
sort.Sort(BySeenSorter(targets))
} else if by == "sent" {

View file

@ -23,9 +23,9 @@ func vIP(ip net.IP) string {
}
address := ip.String()
host, found := session.I.Targets.Targets[address]
host := session.I.Lan.Get(address)
if found == true {
if host != nil {
if host.Hostname != "" {
return host.Hostname
}