I'm missing something while setting eth_boundary option.
>>> eth_boundary=14
>>> pkt=e/i
>>> len(e)
14
>>> len(i)
20
>>>
>>> pkt.show()
###[ Raw ]###
load= '\x00\xa0\xa1\x12\xc2\xc1\x001H\xcd\xe8\x5c\x08\x00E\x00\x00\x11\x00\x01\x00\x00@\x00P\xe2\x11\x01\x01\x02\x14\x01\x01\x01'
>>> pkt[eth_boundary:]
Traceback (most recent call last):
File "/usr/lib/python3.5/code.py", line 91, in runcode
exec(code, self.locals)
File "<console>", line 1, in <module>
File "/home/regress/scapy/scapy/packet.py", line 1171, in __getitem__
raise IndexError("Layer [%s] not found" % lname)
IndexError: Layer [14] not found
>>>
Please help me out on how to fix the above error.
The problem here is that you are accessing pkt
like an array of bytes
when it's actually an array of layers:
>>> pkt=Ether()/IP()
>>> pkt[0]
<Ether type=0x800 |<IP |>>
>>> pkt[1]
<IP |>
>>> pkt[2]
IndexError: Layer [2] not found
The error describes the problem it sees exactly: Layer [14] not found
Use raw(pkt) instead:
>>> eth_boundary = 14
>>> pkt=Ether()/IP()
>>> raw(pkt)
b'\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x08\x00E\x00\x00\x14\x00\x01\x00\x00@\x00|\xe7\x7f\x00\x00\x01\x7f\x00\x00\x01'
>>> raw(pkt)[14:]
b'E\x00\x00\x14\x00\x01\x00\x00@\x00|\xe7\x7f\x00\x00\x01\x7f\x00\x00\x01'