python - scapy "TypeError: ' IP'对象不可调用”

标签 python ip scapy

在我的 Scapy 脚本中出现错误,我找不到原因。

#!/usr/bin/python
from scapy.all import *
from settings import *

#Create  Layer-2 Frame. 
l2 = Ether( dst=dst, src=src, type=2048) #dst and src from settings
pkt = IP(dst=dst)/ICMP(type=8)/Raw(load=("X"*10000))
#Create some big pings:
for i in range(10000,10020):
    frags = fragment(pkt) #create Fragments    
    for fragment in frags:
        sendp(l2/fragment, iface=iface)
    print("i: " + str(i))

Scapy 发送一整个数据包,之后,我就变成了错误消息:

TypeError: 'IP' object is not callable

有人可以告诉我如何解决这个问题吗?

最佳答案

您正在使用 for 循环变量覆盖 fragment 函数,因此 fragment 在下一次迭代中成为不可调用的对象外循环。

您应该将 fragment 变量重命名为其他名称:

for frag in frags:
    sendp(l2/frag, iface=iface)

关于python - scapy "TypeError: ' IP'对象不可调用”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52736851/

相关文章:

python - 导入 pandas.plotting 的问题

比较两个ip子网

python - 根据另一个类的字段动态获取字段类型(使用 Scapy 工具 - Python)

python - MYSQL 数据插入查询在 Python 中不起作用

python - Python 中 FFT 峰值下的面积

javascript - 使用 JavaScript 获取域的 IP

linux - 在 VM 上设置 2 节点 Hadoop 集群

Scapy - 数据包后的随机预告片

python - Scapy:使用 PacketListField 剖析一个数据包中包含的多个数据包

python - 在Python中解析独占组