mint linux 17.1 中的 Scapy pdfdump 错误

Scapy pdfdump error in mint linux 17.1

我正在尝试为 class 分配作业以使用 scapy 伪造网络数据包。我是运行宁薄荷linux17.1肉桂。我在 python 中安装了 latex、PyX、scapy 和 gnuplot。这是数据包的样子,也是我在 运行 pdfdump 函数时得到的错误。谁能告诉我我需要做什么才能使该功能正常工作?

mint@mint ~ $ scapy
WARNING: No route found for IPv6 destination :: (no default route?)
Welcome to Scapy (2.2.0)

loot=Ether(dst = "d8:eb:97:17:5e:f3" , src = "ac:81:12:92:07:06")/IP(version = "4L" , ihl = "5L" , tos = "0xc0" , len = "106" , id = "22859" ,       frag = "0L" , ttl = "64" , proto = "icmp" , chksum = "0x8acf" , src = "192.168.10.103" , dst = "192.168.10.1")/ICMP(type = "dest-unreach" , code = "host-prohibited" , chksum = "0x92fa" , unused = "0")/IP(version = "4L" , ihl = "5L" , tos = "0x0" , len = "78" , id = "0" , flags = "DF" , frag = "0L" , ttl = "64" , proto = "udp" , chksum = "0xa4e6" , src = "192.168.10.1" , dst = "192.168.10.103")/UDP(sport = "netbios_ns" , dport = "netbios_ns" , len = "58" , chksum = "0xc88f")/NBNSQueryRequest(NAME_TRN_ID = "25062" , FLAGS = "0" , QDCOUNT = "1" , ANCOUNT = "0" , NSCOUNT = "0" , ARCOUNT =  "0" , QUESTION_NAME = "'*'" , SUFFIX = "workstation" , NULL = "0" , QUESTION_TYPE = "NBSTAT" , QUESTION_CLASS = "INTERNET")

loot.show()

###[ Ethernet ]###
  dst= d8:eb:97:17:5e:f3
  src= ac:81:12:92:07:06
  type= 0x800
###[ IP ]###
 version= '4L'
 ihl= '5L'
 tos= 0xc0
 len= '106'
 id= '22859'
 flags= 
 frag= '0L'
 ttl= '64'
 proto= icmp
 chksum= 0x8acf
 src= 192.168.10.103
 dst= 192.168.10.1
 \options\
###[ ICMP ]###
    type= dest-unreach
    code= host-prohibited
    chksum= 0x92fa
    unused= '0'
###[ IP ]###
       version= '4L'
       ihl= '5L'
       tos= 0x0
       len= '78'
       id= '0'
       flags= DF
       frag= '0L'
       ttl= '64'
       proto= udp
       chksum= 0xa4e6
       src= 192.168.10.1
       dst= 192.168.10.103
       \options\
###[ UDP ]###
          sport= netbios_ns
          dport= netbios_ns
          len= '58'
          chksum= 0xc88f
###[ NBNS query request ]###
             NAME_TRN_ID= '25062'
             FLAGS= '0'
             QDCOUNT= '1'
             ANCOUNT= '0'
             NSCOUNT= '0'
             ARCOUNT= '0'
             QUESTION_NAME= "'*'"
             SUFFIX= workstation
             NULL= '0'
             QUESTION_TYPE= NBSTAT
             QUESTION_CLASS= INTERNET

loot.pdfdump("loot.pdf")

Traceback (most recent call last):
File "<console>", line 1, in <module>

File "/usr/lib/python2.7/dist-packages/scapy/packet.py", line 376, in    pdfdump canvas = self.canvas_dump(**kargs)

File "/usr/lib/python2.7/dist-packages/scapy/packet.py", line 388, in canvas_dump p,t = self.__class__(str(self)).build_ps()

File "/usr/lib/python2.7/dist-packages/scapy/packet.py", line 261, in __str__return self.build()

File "/usr/lib/python2.7/dist-packages/scapy/packet.py", line 319, in buildp = self.do_build()

File "/usr/lib/python2.7/dist-packages/scapy/packet.py", line 311, in do_buildpay = self.do_build_payload()

File "/usr/lib/python2.7/dist-packages/scapy/packet.py", line 303, in do_build_payloadreturn self.payload.do_build()

File "/usr/lib/python2.7/dist-packages/scapy/packet.py", line 308, in do_buildpkt = self.self_build()

File "/usr/lib/python2.7/dist-packages/scapy/packet.py", line 299, in self_buildp = f.addfield(self, p, val)

File "/usr/lib/python2.7/dist-packages/scapy/fields.py", line 644, in addfield v |= val & ((1L<<self.size) - 1)

TypeError: unsupported operand type(s) for &: 'str' and 'long'

用于构建数据包的值不应该针对每个字段都是 string 类型,而应该只针对选定的几个字段。表示数字的字段,例如 lenchksum 应该是 intlong:

loot=Ether(dst = "d8:eb:97:17:5e:f3", src = "ac:81:12:92:07:06")/IP(version = 4L, ihl = 5L, tos = 0xc0, len = 106, id = 22859, frag = 0L, ttl = 64, proto = "icmp", chksum = 0x8acf, src = "192.168.10.103" , dst = "192.168.10.1")/ICMP(type = "dest-unreach", code = "host-prohibited", chksum = 0x92fa, unused = 0)/IP(version = 4L, ihl = 5L, tos = 0x0, len = 78, id = 0, flags = "DF", frag = 0L, ttl = 64, proto = "udp", chksum = 0xa4e6, src = "192.168.10.1", dst = "192.168.10.103")/UDP(sport = "netbios_ns", dport = "netbios_ns", len = 58, chksum = 0xc88f)/NBNSQueryRequest(NAME_TRN_ID = 25062, FLAGS = 0, QDCOUNT = 1, ANCOUNT = 0, NSCOUNT = 0, ARCOUNT = 0, QUESTION_NAME = "*", SUFFIX = "workstation", NULL = 0, QUESTION_TYPE = "NBSTAT", QUESTION_CLASS = "INTERNET")

请注意,并非必须为所有字段指定值:

  • scapy 可以设法自动填写某些字段的值,例如 lenchksum(当有足够的信息时)。
  • scapy 还假定某些未提供的字段的默认值,例如 flagstos.