mirror of
https://github.com/bettercap/bettercap
synced 2025-08-19 21:13:18 -07:00
and more
This commit is contained in:
parent
1afab5d7be
commit
813ae0a5e9
3 changed files with 12 additions and 13 deletions
|
@ -38,7 +38,7 @@ func DHCP6For(what dhcp6.MessageType, to dhcp6.Packet, duid []byte) (err error,
|
||||||
}
|
}
|
||||||
|
|
||||||
var rawCID []byte
|
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
|
return ErrNoCID, p
|
||||||
} else {
|
} else {
|
||||||
rawCID = raw[0]
|
rawCID = raw[0]
|
||||||
|
|
|
@ -107,7 +107,7 @@ func Dot11Parse(packet gopacket.Packet) (ok bool, radiotap *layers.RadioTap, dot
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
radiotap, ok = radiotapLayer.(*layers.RadioTap)
|
radiotap, ok = radiotapLayer.(*layers.RadioTap)
|
||||||
if ok == false || radiotap == nil {
|
if !ok || radiotap == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ func Dot11ParseEncryption(packet gopacket.Packet, dot11 *layers.Dot11) (bool, st
|
||||||
auth = rsn.AuthKey.Suites[i].Type.String()
|
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"
|
enc = "WPA"
|
||||||
vendor, err := Dot11InformationElementVendorInfoDecode(info.Info)
|
vendor, err := Dot11InformationElementVendorInfoDecode(info.Info)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
@ -195,7 +195,7 @@ func Dot11IsDataFor(dot11 *layers.Dot11, station net.HardwareAddr) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
// packet going to this specific BSSID?
|
// 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) {
|
func Dot11ParseDSSet(packet gopacket.Packet) (bool, int) {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package packets
|
package packets
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"sync"
|
"sync"
|
||||||
|
@ -104,7 +103,7 @@ func (q *Queue) trackProtocols(pkt gopacket.Packet) {
|
||||||
|
|
||||||
q.Lock()
|
q.Lock()
|
||||||
name := proto.String()
|
name := proto.String()
|
||||||
if _, found := q.Protos[name]; found == false {
|
if _, found := q.Protos[name]; !found {
|
||||||
q.Protos[name] = 1
|
q.Protos[name] = 1
|
||||||
} else {
|
} else {
|
||||||
q.Protos[name] += 1
|
q.Protos[name] += 1
|
||||||
|
@ -126,7 +125,7 @@ func (q *Queue) trackActivity(eth *layers.Ethernet, ip4 *layers.IPv4, address ne
|
||||||
|
|
||||||
// initialize or update stats
|
// initialize or update stats
|
||||||
addr := address.String()
|
addr := address.String()
|
||||||
if _, found := q.Traffic[addr]; found == false {
|
if _, found := q.Traffic[addr]; !found {
|
||||||
if isSent {
|
if isSent {
|
||||||
q.Traffic[addr] = &Traffic{Sent: pktSize}
|
q.Traffic[addr] = &Traffic{Sent: pktSize}
|
||||||
} else {
|
} else {
|
||||||
|
@ -165,7 +164,7 @@ func (q *Queue) TrackError() {
|
||||||
|
|
||||||
func (q *Queue) worker() {
|
func (q *Queue) worker() {
|
||||||
for pkt := range q.srcChannel {
|
for pkt := range q.srcChannel {
|
||||||
if q.active == false {
|
if !q.active {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,16 +187,16 @@ func (q *Queue) worker() {
|
||||||
// we manage to sniff
|
// we manage to sniff
|
||||||
|
|
||||||
// something coming from someone on the LAN
|
// 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)
|
isFromLAN := q.iface.Net.Contains(ip4.SrcIP)
|
||||||
if isFromMe == false && isFromLAN {
|
if !isFromMe && isFromLAN {
|
||||||
q.trackActivity(eth, ip4, ip4.SrcIP, pktSize, true)
|
q.trackActivity(eth, ip4, ip4.SrcIP, pktSize, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// something going to someone on the LAN
|
// 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)
|
isToLAN := q.iface.Net.Contains(ip4.DstIP)
|
||||||
if isToMe == false && isToLAN {
|
if !isToMe && isToLAN {
|
||||||
q.trackActivity(eth, ip4, ip4.DstIP, pktSize, false)
|
q.trackActivity(eth, ip4, ip4.DstIP, pktSize, false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -208,7 +207,7 @@ func (q *Queue) Send(raw []byte) error {
|
||||||
q.Lock()
|
q.Lock()
|
||||||
defer q.Unlock()
|
defer q.Unlock()
|
||||||
|
|
||||||
if q.active == false {
|
if !q.active {
|
||||||
return fmt.Errorf("Packet queue is not active.")
|
return fmt.Errorf("Packet queue is not active.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue