将有效负载类型的scapy RTP数据包写入pcap时出错

时间:2015-10-12 19:09:49

标签: python scapy

当我使用以下代码在scapy中创建RTP数据包时,我收到一个错误:“TypeError:clone_with()获得了关键字参数'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)

但删除有效负载有效。

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

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

完整输出

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'

我做错了什么......?有解决方法吗?错误发生在666行......嗯......

谢谢!

1 个答案:

答案 0 :(得分:1)

更改https://bitbucket.org/secdev/scapy/pull-requests/110/changed-rtp-field-name-from-payload-to中建议的行可通过将字段名称从payload更改为payload_type来解决问题。