AndAsh
AndAsh

Reputation: 21

How to get an Ether frame in bytes

I am capturing a single package using scapy:

from scapy.all import *

while True:
    data = sniff(iface = 'lo', count = 1)

Then I try to convert the resulting object into bytes:

print(raw(data))

And I'm getting an error: TypeError: 'Ether' object cannot be interpreted as an integer

I need to capture a packet and store it in a variable as bytes.

I tried it this way:

from scapy.all import *

while True:
    data = sniff(iface = 'lo', count = 1)
    print(raw(data))

and this:

from scapy.all import *

while True:
    data = sniff(iface = 'lo', count = 1,  prn = lambda x: raw(x))
    print(data)

Upvotes: 0

Views: 36

Answers (0)

Related Questions