KeyError:'iface'

时间:2017-10-25 16:59:34

标签: python-2.7 tcp scapy

from scapy.all import *
ip = IP(dst='127.0.0.1')
tcp = TCP(dport=80, iface='wlan0')

图片中显示的错误为KeyError: 'iface'erro_scapy_iface

1 个答案:

答案 0 :(得分:0)

TCP类的选项为here。没有iface选项。您也可以使用ls

进行检查
>>> ls(IP)
version    : BitField (4 bits)                   = (4)
ihl        : BitField (4 bits)                   = (None)
tos        : XByteField                          = (0)
len        : ShortField                          = (None)
id         : ShortField                          = (1)
flags      : FlagsField (3 bits)                 = (0)
frag       : BitField (13 bits)                  = (0)
ttl        : ByteField                           = (64)
proto      : ByteEnumField                       = (0)
chksum     : XShortField                         = (None)
src        : SourceIPField (Emph)                = (None)
dst        : DestIPField (Emph)                  = (None)
options    : PacketListField                     = ([])
>>> ls(TCP)
sport      : ShortEnumField                      = (20)
dport      : ShortEnumField                      = (80)
seq        : IntField                            = (0)
ack        : IntField                            = (0)
dataofs    : BitField (4 bits)                   = (None)
reserved   : BitField (3 bits)                   = (0)
flags      : FlagsField (9 bits)                 = (2)
window     : ShortField                          = (8192)
chksum     : XShortField                         = (None)
urgptr     : ShortField                          = (0)
options    : TCPOptionsField                     = ({})

sniff, send, sendp(可能还有其他)命令有iface个kwargs,如交互式教程中所述。