This commit is contained in:
evilsocket 2018-04-26 12:25:35 +02:00
commit 813ae0a5e9
No known key found for this signature in database
GPG key ID: 1564D7F30393A456
3 changed files with 12 additions and 13 deletions

View file

@ -38,7 +38,7 @@ func DHCP6For(what dhcp6.MessageType, to dhcp6.Packet, duid []byte) (err error,
}
var rawCID []byte
if raw, found := to.Options[dhcp6.OptionClientID]; found == false || len(raw) < 1 {
if raw, found := to.Options[dhcp6.OptionClientID]; !found || len(raw) < 1 {
return ErrNoCID, p
} else {
rawCID = raw[0]

View file

@ -107,7 +107,7 @@ func Dot11Parse(packet gopacket.Packet) (ok bool, radiotap *layers.RadioTap, dot
return
}
radiotap, ok = radiotapLayer.(*layers.RadioTap)
if ok == false || radiotap == nil {
if !ok || radiotap == nil {
return
}
@ -165,7 +165,7 @@ func Dot11ParseEncryption(packet gopacket.Packet, dot11 *layers.Dot11) (bool, st
auth = rsn.AuthKey.Suites[i].Type.String()
}
}
} else if enc == "" && info.ID == layers.Dot11InformationElementIDVendor && info.Length >= 8 && bytes.Compare(info.OUI, wpaSignatureBytes) == 0 && bytes.HasPrefix(info.Info, []byte{1, 0}) {
} else if enc == "" && info.ID == layers.Dot11InformationElementIDVendor && info.Length >= 8 && bytes.Equal(info.OUI, wpaSignatureBytes) && bytes.HasPrefix(info.Info, []byte{1, 0}) {
enc = "WPA"
vendor, err := Dot11InformationElementVendorInfoDecode(info.Info)
if err == nil {
@ -195,7 +195,7 @@ func Dot11IsDataFor(dot11 *layers.Dot11, station net.HardwareAddr) bool {
return false
}
// packet going to this specific BSSID?
return bytes.Compare(dot11.Address1, station) == 0
return bytes.Equal(dot11.Address1, station)
}
func Dot11ParseDSSet(packet gopacket.Packet) (bool, int) {

View file

@ -1,7 +1,6 @@
package packets
import (
"bytes"
"fmt"
"net"
"sync"
@ -104,7 +103,7 @@ func (q *Queue) trackProtocols(pkt gopacket.Packet) {
q.Lock()
name := proto.String()
if _, found := q.Protos[name]; found == false {
if _, found := q.Protos[name]; !found {
q.Protos[name] = 1
} else {
q.Protos[name] += 1
@ -126,7 +125,7 @@ func (q *Queue) trackActivity(eth *layers.Ethernet, ip4 *layers.IPv4, address ne
// initialize or update stats
addr := address.String()
if _, found := q.Traffic[addr]; found == false {
if _, found := q.Traffic[addr]; !found {
if isSent {
q.Traffic[addr] = &Traffic{Sent: pktSize}
} else {
@ -165,7 +164,7 @@ func (q *Queue) TrackError() {
func (q *Queue) worker() {
for pkt := range q.srcChannel {
if q.active == false {
if !q.active {
return
}
@ -188,16 +187,16 @@ func (q *Queue) worker() {
// we manage to sniff
// something coming from someone on the LAN
isFromMe := bytes.Compare(q.iface.IP, ip4.SrcIP) == 0
isFromMe := q.iface.IP.Equal(ip4.SrcIP)
isFromLAN := q.iface.Net.Contains(ip4.SrcIP)
if isFromMe == false && isFromLAN {
if !isFromMe && isFromLAN {
q.trackActivity(eth, ip4, ip4.SrcIP, pktSize, true)
}
// something going to someone on the LAN
isToMe := bytes.Compare(q.iface.IP, ip4.DstIP) == 0
isToMe := q.iface.IP.Equal(ip4.DstIP)
isToLAN := q.iface.Net.Contains(ip4.DstIP)
if isToMe == false && isToLAN {
if !isToMe && isToLAN {
q.trackActivity(eth, ip4, ip4.DstIP, pktSize, false)
}
}
@ -208,7 +207,7 @@ func (q *Queue) Send(raw []byte) error {
q.Lock()
defer q.Unlock()
if q.active == false {
if !q.active {
return fmt.Errorf("Packet queue is not active.")
}