Error writing scapy RTP packet with payload type to pcap

南笙酒味 提交于 2020-01-05 19:45:12

问题


When I create an RTP packet in scapy with the following code, I get an error: "TypeError: clone_with() got multiple values for keyword argument 'payload'"

from scapy.all import IP, UDP, RTP, Ether
from scapy.utils import PcapWriter

pktdump = PcapWriter("banana.pcap", append=False, sync=True)

rtp = { 
        "sequence": 1,
        "timestamp": 1,
        "marker": 1,
        "payload": 17
    }

pkt = Ether()/IP()/UDP(sport=12345,dport=12346)/RTP(**rtp)
pktdump.write(pkt)

but removing payload works.

rtp = { 
        "sequence": 1,
        "timestamp": 1,
        "marker": 1
    }

pkt = Ether()/IP()/UDP(sport=12345,dport=12346)/RTP(**rtp)
pktdump.write(pkt)

The full output is

Traceback (most recent call last):
  File "test.py", line 23, in <module>
    pktdump.write(pkt)
  File "/home/eisamar/devel/rtp2pcap/local/lib/python2.7/site-packages/scapy/utils.py", line 657, in write
    for p in pkt:
  File "/home/eisamar/devel/rtp2pcap/local/lib/python2.7/site-packages/scapy/packet.py", line 661, in loop
    for payl in payloads:
  File "/home/eisamar/devel/rtp2pcap/local/lib/python2.7/site-packages/scapy/packet.py", line 661, in loop
    for payl in payloads:
  File "/home/eisamar/devel/rtp2pcap/local/lib/python2.7/site-packages/scapy/packet.py", line 654, in loop
    for x in loop(todo[:], done):
  File "/home/eisamar/devel/rtp2pcap/local/lib/python2.7/site-packages/scapy/packet.py", line 654, in loop
    for x in loop(todo[:], done):
  File "/home/eisamar/devel/rtp2pcap/local/lib/python2.7/site-packages/scapy/packet.py", line 661, in loop
    for payl in payloads:
  File "/home/eisamar/devel/rtp2pcap/local/lib/python2.7/site-packages/scapy/packet.py", line 654, in loop
    for x in loop(todo[:], done):
  File "/home/eisamar/devel/rtp2pcap/local/lib/python2.7/site-packages/scapy/packet.py", line 654, in loop
    for x in loop(todo[:], done):
  File "/home/eisamar/devel/rtp2pcap/local/lib/python2.7/site-packages/scapy/packet.py", line 654, in loop
    for x in loop(todo[:], done):
  File "/home/eisamar/devel/rtp2pcap/local/lib/python2.7/site-packages/scapy/packet.py", line 654, in loop
    for x in loop(todo[:], done):
  File "/home/eisamar/devel/rtp2pcap/local/lib/python2.7/site-packages/scapy/packet.py", line 666, in loop
    pkt = self.clone_with(payload=payl, **done2)
TypeError: clone_with() got multiple values for keyword argument 'payload'

What am I doing wrong...? Is there a workaround? The error is on line 666... hmm...

Thanks!


回答1:


Changing the line suggested in https://bitbucket.org/secdev/scapy/pull-requests/110/changed-rtp-field-name-from-payload-to fixes the problem by changing the name of the field from payload to payload_type.



来源:https://stackoverflow.com/questions/33088484/error-writing-scapy-rtp-packet-with-payload-type-to-pcap

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!