mirror of
https://github.com/bettercap/bettercap
synced 2025-08-21 05:53:20 -07:00
fix: gracefully handle packets that would crash gopacket (fixes #1184)
This commit is contained in:
parent
948756208a
commit
fed98adffa
1 changed files with 8 additions and 0 deletions
|
@ -201,6 +201,14 @@ func (mod *ZeroGod) logDNS(src net.IP, dns layers.DNS, isLocal bool) {
|
|||
func (mod *ZeroGod) onPacket(pkt gopacket.Packet) {
|
||||
mod.Debug("%++v", pkt)
|
||||
|
||||
// sadly the latest available version of gopacket has an unpatched bug :/
|
||||
// https://github.com/bettercap/bettercap/issues/1184
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
mod.Error("unexpected error while parsing network packet: %v\n\n%++v", err, pkt)
|
||||
}
|
||||
}()
|
||||
|
||||
netLayer := pkt.NetworkLayer()
|
||||
if netLayer == nil {
|
||||
mod.Warning("not network layer in packet %+v", pkt)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue