Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Scapy / operator, | pipe in types

Tags:

python

scapy

With scapy we can to this :

p = Ether() / IP()

What kind of operation does '/' really do ? What kind of object does it return ? If I type p in a python interpreter it returns this

<Ether  ... | IP ...>

What does '|' mean in this case ?

I was trying to change the field dst of IP after creating p without recreating the object entirely, but I didn't manage to do it as I don't know what kind of object I am facing.

Thank you.

like image 805
x4rkz Avatar asked Jan 16 '16 21:01

x4rkz


1 Answers

The div / operator is used in Scapy to stack layers:

The / operator has been used as a composition operator between two layers. When doing so, the lower layer can have one or more of its defaults fields overloaded according to the upper layer.

The | in your printing output is just a text separator to help you distinguish between stacked layers.

like image 117
Assem Avatar answered Sep 18 '22 22:09

Assem