mirror of
https://github.com/bettercap/bettercap
synced 2025-07-30 11:40:33 -07:00
misc: small fix or general refactoring i did not bother commenting
This commit is contained in:
parent
d6b9aa7b7f
commit
38d08e4db6
1 changed files with 30 additions and 7 deletions
|
@ -11,16 +11,32 @@ import (
|
|||
"github.com/google/gopacket/layers"
|
||||
)
|
||||
|
||||
func NewDot11Beacon(bssid net.HardwareAddr, ssid string, seq uint16) (error, []byte) {
|
||||
type Dot11EncryptionType int
|
||||
|
||||
const (
|
||||
Dot11Open Dot11EncryptionType = iota
|
||||
Dot11Wep
|
||||
Dot11WpaTKIP
|
||||
Dot11WpaAES
|
||||
)
|
||||
|
||||
type Dot11BeaconConfig struct {
|
||||
SSID string
|
||||
BSSID net.HardwareAddr
|
||||
Channel int
|
||||
Encryption Dot11EncryptionType
|
||||
}
|
||||
|
||||
func NewDot11Beacon(conf Dot11BeaconConfig) (error, []byte) {
|
||||
// TODO: still very incomplete
|
||||
return packets.Serialize(
|
||||
&layers.RadioTap{},
|
||||
&layers.Dot11{
|
||||
Address1: network.BroadcastHw,
|
||||
Address2: bssid,
|
||||
Address3: bssid,
|
||||
Address2: conf.BSSID,
|
||||
Address3: conf.BSSID,
|
||||
Type: layers.Dot11TypeMgmtBeacon,
|
||||
SequenceNumber: seq, // not sure this needs to be a specific value
|
||||
SequenceNumber: 0, // not sure this needs to be a specific value
|
||||
},
|
||||
&layers.Dot11MgmtBeacon{
|
||||
Timestamp: uint64(time.Now().Second()), // not sure
|
||||
|
@ -29,8 +45,8 @@ func NewDot11Beacon(bssid net.HardwareAddr, ssid string, seq uint16) (error, []b
|
|||
},
|
||||
&layers.Dot11InformationElement{
|
||||
ID: layers.Dot11InformationElementIDSSID,
|
||||
Length: uint8(len(ssid) & 0xff),
|
||||
Info: []byte(ssid),
|
||||
Length: uint8(len(conf.SSID) & 0xff),
|
||||
Info: []byte(conf.SSID),
|
||||
},
|
||||
// TODO: Rates n stuff ...
|
||||
&layers.Dot11InformationElement{
|
||||
|
@ -50,7 +66,14 @@ func (w *WiFiModule) sendBeaconPacket(counter int) {
|
|||
w.writes.Add(1)
|
||||
defer w.writes.Done()
|
||||
|
||||
if err, pkt := NewDot11Beacon(w.Session.Interface.HW, "Prova", uint16(counter)); err != nil {
|
||||
conf := Dot11BeaconConfig{
|
||||
SSID: "Prova",
|
||||
BSSID: w.Session.Interface.HW,
|
||||
Channel: 1,
|
||||
Encryption: Dot11Open,
|
||||
}
|
||||
|
||||
if err, pkt := NewDot11Beacon(conf); err != nil {
|
||||
log.Error("Could not create beacon packet: %s", err)
|
||||
} else {
|
||||
w.injectPacket(pkt)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue