mirror of
https://github.com/bettercap/bettercap
synced 2025-08-19 13:09:49 -07:00
Small improvements
This commit is contained in:
parent
3606c121c5
commit
eb3a4ecfca
1 changed files with 16 additions and 9 deletions
|
@ -151,7 +151,7 @@ func (p *ArpSpoofer) pktRouter(eth *layers.Ethernet, ip4 *layers.IPv4, pkt gopac
|
||||||
targetMAC, err := p.getMAC(target, true)
|
targetMAC, err := p.getMAC(target, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Error retrieving target MAC address for %s", target.String(), err)
|
log.Error("Error retrieving target MAC address for %s", target.String(), err)
|
||||||
return
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// If SRC_MAC is different from both TARGET(s) & GW ignore
|
// If SRC_MAC is different from both TARGET(s) & GW ignore
|
||||||
|
@ -175,29 +175,36 @@ func (p *ArpSpoofer) pktRouter(eth *layers.Ethernet, ip4 *layers.IPv4, pkt gopac
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Craft packet
|
// TODO Craft packet
|
||||||
craftedEth := eth
|
var craftedEth = new(layers.Ethernet)
|
||||||
|
craftedEth.BaseLayer = eth.BaseLayer
|
||||||
|
craftedEth.EthernetType = eth.EthernetType
|
||||||
|
craftedEth.Length = eth.Length
|
||||||
|
|
||||||
if bytes.Compare(eth.SrcMAC, targetMAC) == 0 {
|
if bytes.Compare(eth.SrcMAC, targetMAC) == 0 {
|
||||||
|
// TODO Delete this debug
|
||||||
log.Error("[Reinject] [(%s) %s] ===> [%s (%s)]", eth.SrcMAC, ip4.SrcIP, ip4.DstIP, eth.DstMAC)
|
log.Error("[Reinject] [(%s) %s] ===> [%s (%s)]", eth.SrcMAC, ip4.SrcIP, ip4.DstIP, eth.DstMAC)
|
||||||
// TODO Fix Layers
|
|
||||||
craftedEth.SrcMAC = p.Session.Interface.HW
|
craftedEth.SrcMAC = p.Session.Interface.HW
|
||||||
craftedEth.DstMAC = p.Session.Gateway.HW
|
craftedEth.DstMAC = p.Session.Gateway.HW
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
// TODO Delete this debug
|
||||||
log.Warning("[Reinject] [(%s) %s] <=== [%s (%s)]", eth.SrcMAC, ip4.SrcIP, ip4.DstIP, eth.DstMAC)
|
log.Warning("[Reinject] [(%s) %s] <=== [%s (%s)]", eth.SrcMAC, ip4.SrcIP, ip4.DstIP, eth.DstMAC)
|
||||||
// TODO Fix Layers
|
|
||||||
craftedEth.SrcMAC = p.Session.Interface.HW
|
craftedEth.SrcMAC = p.Session.Interface.HW
|
||||||
craftedEth.DstMAC = targetMAC
|
craftedEth.DstMAC = targetMAC
|
||||||
}
|
}
|
||||||
|
|
||||||
err, serial := packets.Serialize(craftedEth);
|
err, serial := packets.Serialize(craftedEth)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Error while ReInjecting: [%s] ==> [%s]", craftedEth.SrcMAC, craftedEth.DstMAC, )
|
log.Error("Error Serializing the crafted packet!")
|
||||||
return
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Warning("[Injectin] [(%s) %s] ===> [%s (%s)] - %v+", craftedEth.SrcMAC, ip4.SrcIP, ip4.DstIP, craftedEth.DstMAC, craftedEth.EthernetType.String())
|
if err := p.Session.Queue.Send(serial); err != nil {
|
||||||
p.Session.Queue.Send(serial)
|
log.Error("Error ReInjecting: [%s] ==> [%s]", craftedEth.SrcMAC, craftedEth.DstMAC)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Info("[INJECTED] [(%s) %s] ===> [%s (%s)]\n", craftedEth.SrcMAC, ip4.SrcIP, ip4.DstIP, craftedEth.DstMAC)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue