Python Forum
creating new layer with scapy
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
creating new layer with scapy
#1
hi i tried to create a new layer in scapy but when i send the packet to another computer and ask to print it ,y new layer got lost the class of the new layer appers in both computers on first i wrote creating and sending packets functions and on the another i wrote sniff function. here is the code on the sending computer



import sys
i, o, e = sys.stdin, sys.stdout, sys.stderr
from scapy.all import *
sys.stdin, sys.stdout, sys.stderr = i, o, e
from scapy.packet import *
from scapy.fields import *
from scapy.layers.inet import UDP, IP
from scapy.layers.dns import DNS
from scapy.layers.l2 import Ether

vxlanmagic = "0x8"


class Vxlan(Packet):
name = "Virtual eXtensible Local Area Network"
fields_desc = [ByteField("flag", 8),
X3BytesField("reserved1", 0),
X3BytesField("vni", 0),
ByteField("reserved2", 0)]

def guess_payload_class(self, payload):
if self.flag == vxlanmagic:
return Vxlan
else:
return Packet.guess_payload_class(self, payload)

def mysummary(self):
return self.sprintf("VXLAN (vni=%VXLAN.vni%)")

split_layers(UDP, DNS, sport=53)
bind_layers(UDP, Vxlan, dport=4789)
bind_layers(Vxlan, Ether)
packet = IP(dst='192.168.1.28')/Vxlan()
packet.show()
send(packet)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Permission issue when using scapy jao 3 9,854 Feb-05-2022, 06:14 PM
Last Post: snippsat
  error in scapy attribute 'haslayer' evilcode1 5 6,556 Mar-02-2021, 11:19 AM
Last Post: evilcode1
  lambda layer size issue lambdabeginer 1 1,959 Aug-26-2019, 07:23 PM
Last Post: Larz60+
  Help Importing Protocol Library Into Scapy joedirgy 0 2,070 May-02-2019, 07:31 PM
Last Post: joedirgy
  run scapy from python script .. evilcode1 13 14,053 Sep-13-2018, 01:45 AM
Last Post: ichabod801
  save the output from scapy to txt file evilcode1 11 10,876 Oct-10-2017, 02:44 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020