Scapy generating STP(Spanning Tree Protocol) packe

2019-07-20 00:11发布

I am trying to generate STP packet and to capture it with wireshark.Basically what I do is >>> send(STP()) from Scapy and the result from wireshark is: 53918 2671.938356000 00.00.00 00.00.00 FC 49 [Malformed Packet] My question is how to configure the STP packet, the result from wireshark to be STP packet not FC.Please help :)

标签: scapy
2条回答
forever°为你锁心
2楼-- · 2019-07-20 00:55

The send function is used to send packets in layer 3, while STP is a layer 2 protocol:

In [1]: from scapy.all import STP

In [2]: STP
Out[2]: scapy.layers.l2.STP

Therefore, you should use the sendp function.

See scapy's docs for further information:

The send() function will send packets at layer 3. That is to say it will handle routing and layer 2 for you. The sendp() function will work at layer 2. It’s up to you to choose the right interface and the right link layer protocol.

The official API documentation states this as well:

send(pkts, inter=0, loop=0, verbose=None)

Send packets at layer 3, using the conf.L3socket supersocket.

sendp(pkts, inter=0, loop=0, iface=None, iface hint=None, verbose=None)

Send packets at layer 2 using the conf.L2socket supersocket.

查看更多
SAY GOODBYE
3楼-- · 2019-07-20 01:03

You need to use the sendp() function instead of send(), and you also need to add the Ether() and LLC() layers before STP(). For instance:

sendp(Ether(dst="01:80:c2:00:00:00")/LLC()/STP(), iface=“eth0”)
查看更多
登录 后发表回答