0

I am using scapy as packet decoder tool.
By default it doesn't load certain layers, so I have to specify explicitly in the code:

load_contrib("mpls")
load_contrib("lldp")
load_contrib("ldp")
load_contrib("ospf")
load_contrib("bgp")
load_contrib("igmp")

Is there a way to load all known layers/types?
I tried following but it doesn't work:

#from scapy.layers.l2 import *
from scapy.layers import *
from scapy.contrib import *
brokenfoot
  • 11,083
  • 10
  • 59
  • 80

1 Answers1

1

You can do this to load stuff more cleanly

from scapy.contrib.bgp import *
from scapy.contrib.lldp import *

But you won't be able to load EVERYTHING at once (unless you use a script but that's really not recommended), for several reasons: tha main one being that some protocols can simply not be loaded at the same time. VRRP and CARP for instance.

Remember that layers are already loaded by default, but contrib modules are usually very uncommon. You shouldn't need this

Cukic0d
  • 5,111
  • 2
  • 19
  • 48
  • Thanks for your response! I get your point, loading CARP splits VRRP bindings [github](https://github.com/secdev/scapy/blob/master/scapy/contrib/carp.py#L76). So, loading everything does not mean all layers are loaded in python global environment. I might have to add logic to inspect header and load layer on demand. – brokenfoot May 23 '21 at 16:35
  • Luckily such exceptions seem be rare, i found just 2 instances in Scapy source. `(VRRP, CARP)` & `(IKEv2,ISAKMP)`. – brokenfoot May 23 '21 at 16:39