SlideShare une entreprise Scribd logo
1  sur  10
Date of delivery:                   Supervisor:
00-00-2011                    Morten Bo Nielsen
School:                                 Group:
Erhvervsakademiet Lillebælt              Victor

1st semester IT Networking                Flaviu
                                         Lucian
Table of Contents
Introduction..........................................................................................................................................1
System overview..................................................................................................................................2
   Basic overview.................................................................................................................................2
   Creating-sending-sniffing schematics..............................................................................................3
Packet crafting......................................................................................................................................4
Sending, receving and sniffing.............................................................................................................5
Conclusion............................................................................................................................................8
Networking                                     Scapy – Communication on Layer 2




                           Introduction

     The purpose of this exercise is to make our PCs communicate on the
second layer (Data-Link). For this, the manual creation of a ethernet
package, sending it, receiveing it and sniffing it, was required. Also, the
only programs used must be Scapy and eventually Wireshark.




                                     1
Networking                                                      Scapy – Communication on Layer 2




                               System overview

                                    Basic overview




        The two pc's that are part of this exercise are sharing the same subnet, as we can se in the
picture above.




                                                   2
Networking                                                    Scapy – Communication on Layer 2




             Creating-sending-sniffing schematics

       The diagram bellow explains for itself the main operations in this exercise – creating,
sending and sniffing packets.




       Details for each operations can be found in the next pages.




                                                  3
Networking                                                    Scapy – Communication on Layer 2




                                Packet crafting

       This is how an ethernet packet looks like :




      When manually building an ethernet package we should consider adding those elements
manually, like in the picture bellow:




   –   a is a variable which we've made it into an ethernet frame
   –   a.src represents the source mac address , in this case Victors'
   –   a.dst represents the destination macc address, in this case Flavius'
   –   a.type represents the ethertype, in this case being 0x8088 due to a common class decision
   –   data is the data we want to send, in this case the "blablabla" text
   –   b is another variable in which we join our initial variable (a) with the data we want to send


                                                     4
Networking                                                      Scapy – Communication on Layer 2




             Sending, receving and sniffing

       To send a package the sendp command is required, with the following parameters:

   –   b : the packet we want to send
   –   count : how many times we want to send that packet
   –   iface : this is how to specifiy through which interface the packet should be sent – by default
       it's eth0


       To locate the sent packages we use the sniff command, which does as it says, it "sniffs", as
we can see in the following picture:




       The parameters used are :

   –   count : this will make it sniff the last X packages that are being sent or received, in this case
       20
   –   prn : is the print function, it will print what it will sniff like in the picture
   –   x:x.summary(): is a scapy function that together with the prn parameters prints in a
       predefined format




                                                   5
Networking                                                    Scapy – Communication on Layer 2


        When using the lambda x:x.show() function instead of lambda x:x.summary(), the result
looks like in the picture bellow :




      As we can see, the manually added data ("blablabla" – see page4) is is named "load", under
the Raw section of the packet.


       The same thing we can see in wireshark :




        By filtering using the destination mac address, we can easily spot the sent packages, source
and destination mac addresses and the data, in this case "blablabla" (highlighted in the bottom-right
of the picture).


                                                  6
Networking                                                      Scapy – Communication on Layer 2


       In order to print the content of the packets we can use two methods. One may be with
creating a python script, like the one in the picture bellow.




       The output for the script will look like the picture bellow :




       The other method is through the lfilter parameter of the sniff command.




       The whole command is :
sniff(prn=lambda x: "from %s : %s" %(x.src, x['Raw'].load), lfilter=lambda x:
x.haslayer(Ether) and x.fields['type'] == 0x8088)
       A lambda function was used to filter the sniffed packet, so that it will print only the packets
with an Ether layer (haslayer(Ether)) and with the 0x8088 data type.




                                                   7
Networking                                     Scapy – Communication on Layer 2




                           Conclusion

      Scapy is a very powerfull packet-manipulation tool, and with its help
we have demonstrated that almost any kind of data can be inserted into an
ethernet packet. In this case we have inserted a simple string("blablabla").
For larger chunks of data, it is required to "chop" the data into smaller
pieces that could fit into a packet.




                                     8

Contenu connexe

Tendances

Tendances (20)

Linux Linux Traffic Control
Linux Linux Traffic ControlLinux Linux Traffic Control
Linux Linux Traffic Control
 
Ip tables
Ip tablesIp tables
Ip tables
 
Iptables presentation
Iptables presentationIptables presentation
Iptables presentation
 
Wireshark
Wireshark Wireshark
Wireshark
 
Introduction to Vim
Introduction to VimIntroduction to Vim
Introduction to Vim
 
Linux Basic Networking Command
Linux Basic Networking CommandLinux Basic Networking Command
Linux Basic Networking Command
 
Network Monitoring Tools
Network Monitoring ToolsNetwork Monitoring Tools
Network Monitoring Tools
 
Engage 2020 - HCL Notes V11 Performance Boost
Engage 2020 - HCL Notes V11 Performance BoostEngage 2020 - HCL Notes V11 Performance Boost
Engage 2020 - HCL Notes V11 Performance Boost
 
Database Firewall with Snort
Database Firewall with SnortDatabase Firewall with Snort
Database Firewall with Snort
 
Linux Performance Profiling and Monitoring
Linux Performance Profiling and MonitoringLinux Performance Profiling and Monitoring
Linux Performance Profiling and Monitoring
 
CCNAv5 - S3: Chapter9 IOS Images and Licensing
CCNAv5 - S3: Chapter9 IOS Images and LicensingCCNAv5 - S3: Chapter9 IOS Images and Licensing
CCNAv5 - S3: Chapter9 IOS Images and Licensing
 
Linux Network Stack
Linux Network StackLinux Network Stack
Linux Network Stack
 
Understanding DPDK
Understanding DPDKUnderstanding DPDK
Understanding DPDK
 
Wireshark Inroduction Li In
Wireshark Inroduction  Li InWireshark Inroduction  Li In
Wireshark Inroduction Li In
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
 
Tutorial WiFi driver code - Opening Nuts and Bolts of Linux WiFi Subsystem
Tutorial WiFi driver code - Opening Nuts and Bolts of Linux WiFi SubsystemTutorial WiFi driver code - Opening Nuts and Bolts of Linux WiFi Subsystem
Tutorial WiFi driver code - Opening Nuts and Bolts of Linux WiFi Subsystem
 
Radius1
Radius1Radius1
Radius1
 
Linux Kernel vs DPDK: HTTP Performance Showdown
Linux Kernel vs DPDK: HTTP Performance ShowdownLinux Kernel vs DPDK: HTTP Performance Showdown
Linux Kernel vs DPDK: HTTP Performance Showdown
 
Namespaces and cgroups - the basis of Linux containers
Namespaces and cgroups - the basis of Linux containersNamespaces and cgroups - the basis of Linux containers
Namespaces and cgroups - the basis of Linux containers
 
Implementation of FIFO in Linux
Implementation of FIFO in LinuxImplementation of FIFO in Linux
Implementation of FIFO in Linux
 

Similaire à Scapy - communication on Layer2

Wireshark Lab Getting Started v6.0 Supplement to Co.docx
Wireshark Lab  Getting Started v6.0  Supplement to Co.docxWireshark Lab  Getting Started v6.0  Supplement to Co.docx
Wireshark Lab Getting Started v6.0 Supplement to Co.docx
ambersalomon88660
 
Report of TCP/IP
Report of TCP/IPReport of TCP/IP
Report of TCP/IP
Mannu Khani
 

Similaire à Scapy - communication on Layer2 (20)

OSI model (Tamil)
OSI model (Tamil)OSI model (Tamil)
OSI model (Tamil)
 
Fundamentals of Internet and Communication Competition
Fundamentals of Internet and Communication CompetitionFundamentals of Internet and Communication Competition
Fundamentals of Internet and Communication Competition
 
Network simulator 2 a simulation tool for linux
Network simulator 2 a simulation tool for linuxNetwork simulator 2 a simulation tool for linux
Network simulator 2 a simulation tool for linux
 
Nic bonding
Nic bonding Nic bonding
Nic bonding
 
N ns 1
N ns 1N ns 1
N ns 1
 
Introduction to NS2 - Cont..
Introduction to NS2 - Cont..Introduction to NS2 - Cont..
Introduction to NS2 - Cont..
 
An ntutorial[1]
An ntutorial[1]An ntutorial[1]
An ntutorial[1]
 
Wireshark
WiresharkWireshark
Wireshark
 
Neural Networks on Steroids (Poster)
Neural Networks on Steroids (Poster)Neural Networks on Steroids (Poster)
Neural Networks on Steroids (Poster)
 
Stefano Giordano
Stefano GiordanoStefano Giordano
Stefano Giordano
 
Stefano Giordano
Stefano  GiordanoStefano  Giordano
Stefano Giordano
 
Wireshark lab getting started one’s unde
Wireshark lab  getting started     one’s undeWireshark lab  getting started     one’s unde
Wireshark lab getting started one’s unde
 
Plenzogan technology
Plenzogan technologyPlenzogan technology
Plenzogan technology
 
maXbox Starter87
maXbox Starter87maXbox Starter87
maXbox Starter87
 
Wireshark Lab Getting Started v6.0 Supplement to Co.docx
Wireshark Lab  Getting Started v6.0  Supplement to Co.docxWireshark Lab  Getting Started v6.0  Supplement to Co.docx
Wireshark Lab Getting Started v6.0 Supplement to Co.docx
 
IRJET- Tracking Communication Quality Degrading Events for Link Quality E...
IRJET-  	  Tracking Communication Quality Degrading Events for Link Quality E...IRJET-  	  Tracking Communication Quality Degrading Events for Link Quality E...
IRJET- Tracking Communication Quality Degrading Events for Link Quality E...
 
Deep learning (2)
Deep learning (2)Deep learning (2)
Deep learning (2)
 
WiMAX implementation in ns3
WiMAX implementation in ns3WiMAX implementation in ns3
WiMAX implementation in ns3
 
Report of TCP/IP
Report of TCP/IPReport of TCP/IP
Report of TCP/IP
 
Cisco doc
Cisco docCisco doc
Cisco doc
 

Dernier

call Now 9811711561 Cash Payment乂 Call Girls in Dwarka Mor
call Now 9811711561 Cash Payment乂 Call Girls in Dwarka Morcall Now 9811711561 Cash Payment乂 Call Girls in Dwarka Mor
call Now 9811711561 Cash Payment乂 Call Girls in Dwarka Mor
vikas rana
 

Dernier (15)

call Now 9811711561 Cash Payment乂 Call Girls in Dwarka Mor
call Now 9811711561 Cash Payment乂 Call Girls in Dwarka Morcall Now 9811711561 Cash Payment乂 Call Girls in Dwarka Mor
call Now 9811711561 Cash Payment乂 Call Girls in Dwarka Mor
 
The Selfspace Journal Preview by Mindbrush
The Selfspace Journal Preview by MindbrushThe Selfspace Journal Preview by Mindbrush
The Selfspace Journal Preview by Mindbrush
 
2k Shots ≽ 9205541914 ≼ Call Girls In Palam (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Palam (Delhi)2k Shots ≽ 9205541914 ≼ Call Girls In Palam (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Palam (Delhi)
 
2k Shots ≽ 9205541914 ≼ Call Girls In Dashrath Puri (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Dashrath Puri (Delhi)2k Shots ≽ 9205541914 ≼ Call Girls In Dashrath Puri (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Dashrath Puri (Delhi)
 
(Anamika) VIP Call Girls Navi Mumbai Call Now 8250077686 Navi Mumbai Escorts ...
(Anamika) VIP Call Girls Navi Mumbai Call Now 8250077686 Navi Mumbai Escorts ...(Anamika) VIP Call Girls Navi Mumbai Call Now 8250077686 Navi Mumbai Escorts ...
(Anamika) VIP Call Girls Navi Mumbai Call Now 8250077686 Navi Mumbai Escorts ...
 
WOMEN EMPOWERMENT women empowerment.pptx
WOMEN EMPOWERMENT women empowerment.pptxWOMEN EMPOWERMENT women empowerment.pptx
WOMEN EMPOWERMENT women empowerment.pptx
 
Top Rated Pune Call Girls Tingre Nagar ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Tingre Nagar ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Tingre Nagar ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Tingre Nagar ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
2k Shots ≽ 9205541914 ≼ Call Girls In Jasola (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Jasola (Delhi)2k Shots ≽ 9205541914 ≼ Call Girls In Jasola (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Jasola (Delhi)
 
8377087607 Full Enjoy @24/7-CLEAN-Call Girls In Chhatarpur,
8377087607 Full Enjoy @24/7-CLEAN-Call Girls In Chhatarpur,8377087607 Full Enjoy @24/7-CLEAN-Call Girls In Chhatarpur,
8377087607 Full Enjoy @24/7-CLEAN-Call Girls In Chhatarpur,
 
LC_YouSaidYes_NewBelieverBookletDone.pdf
LC_YouSaidYes_NewBelieverBookletDone.pdfLC_YouSaidYes_NewBelieverBookletDone.pdf
LC_YouSaidYes_NewBelieverBookletDone.pdf
 
2k Shots ≽ 9205541914 ≼ Call Girls In Mukherjee Nagar (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Mukherjee Nagar (Delhi)2k Shots ≽ 9205541914 ≼ Call Girls In Mukherjee Nagar (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Mukherjee Nagar (Delhi)
 
(Aarini) Russian Call Girls Surat Call Now 8250077686 Surat Escorts 24x7
(Aarini) Russian Call Girls Surat Call Now 8250077686 Surat Escorts 24x7(Aarini) Russian Call Girls Surat Call Now 8250077686 Surat Escorts 24x7
(Aarini) Russian Call Girls Surat Call Now 8250077686 Surat Escorts 24x7
 
9892124323, Call Girls in mumbai, Vashi Call Girls , Kurla Call girls
9892124323, Call Girls in mumbai, Vashi Call Girls , Kurla Call girls9892124323, Call Girls in mumbai, Vashi Call Girls , Kurla Call girls
9892124323, Call Girls in mumbai, Vashi Call Girls , Kurla Call girls
 
$ Love Spells^ 💎 (310) 882-6330 in West Virginia, WV | Psychic Reading Best B...
$ Love Spells^ 💎 (310) 882-6330 in West Virginia, WV | Psychic Reading Best B...$ Love Spells^ 💎 (310) 882-6330 in West Virginia, WV | Psychic Reading Best B...
$ Love Spells^ 💎 (310) 882-6330 in West Virginia, WV | Psychic Reading Best B...
 
Pokemon Go... Unraveling the Conspiracy Theory
Pokemon Go... Unraveling the Conspiracy TheoryPokemon Go... Unraveling the Conspiracy Theory
Pokemon Go... Unraveling the Conspiracy Theory
 

Scapy - communication on Layer2

  • 1. Date of delivery: Supervisor: 00-00-2011 Morten Bo Nielsen School: Group: Erhvervsakademiet Lillebælt Victor 1st semester IT Networking Flaviu Lucian
  • 2. Table of Contents Introduction..........................................................................................................................................1 System overview..................................................................................................................................2 Basic overview.................................................................................................................................2 Creating-sending-sniffing schematics..............................................................................................3 Packet crafting......................................................................................................................................4 Sending, receving and sniffing.............................................................................................................5 Conclusion............................................................................................................................................8
  • 3. Networking Scapy – Communication on Layer 2 Introduction The purpose of this exercise is to make our PCs communicate on the second layer (Data-Link). For this, the manual creation of a ethernet package, sending it, receiveing it and sniffing it, was required. Also, the only programs used must be Scapy and eventually Wireshark. 1
  • 4. Networking Scapy – Communication on Layer 2 System overview Basic overview The two pc's that are part of this exercise are sharing the same subnet, as we can se in the picture above. 2
  • 5. Networking Scapy – Communication on Layer 2 Creating-sending-sniffing schematics The diagram bellow explains for itself the main operations in this exercise – creating, sending and sniffing packets. Details for each operations can be found in the next pages. 3
  • 6. Networking Scapy – Communication on Layer 2 Packet crafting This is how an ethernet packet looks like : When manually building an ethernet package we should consider adding those elements manually, like in the picture bellow: – a is a variable which we've made it into an ethernet frame – a.src represents the source mac address , in this case Victors' – a.dst represents the destination macc address, in this case Flavius' – a.type represents the ethertype, in this case being 0x8088 due to a common class decision – data is the data we want to send, in this case the "blablabla" text – b is another variable in which we join our initial variable (a) with the data we want to send 4
  • 7. Networking Scapy – Communication on Layer 2 Sending, receving and sniffing To send a package the sendp command is required, with the following parameters: – b : the packet we want to send – count : how many times we want to send that packet – iface : this is how to specifiy through which interface the packet should be sent – by default it's eth0 To locate the sent packages we use the sniff command, which does as it says, it "sniffs", as we can see in the following picture: The parameters used are : – count : this will make it sniff the last X packages that are being sent or received, in this case 20 – prn : is the print function, it will print what it will sniff like in the picture – x:x.summary(): is a scapy function that together with the prn parameters prints in a predefined format 5
  • 8. Networking Scapy – Communication on Layer 2 When using the lambda x:x.show() function instead of lambda x:x.summary(), the result looks like in the picture bellow : As we can see, the manually added data ("blablabla" – see page4) is is named "load", under the Raw section of the packet. The same thing we can see in wireshark : By filtering using the destination mac address, we can easily spot the sent packages, source and destination mac addresses and the data, in this case "blablabla" (highlighted in the bottom-right of the picture). 6
  • 9. Networking Scapy – Communication on Layer 2 In order to print the content of the packets we can use two methods. One may be with creating a python script, like the one in the picture bellow. The output for the script will look like the picture bellow : The other method is through the lfilter parameter of the sniff command. The whole command is : sniff(prn=lambda x: "from %s : %s" %(x.src, x['Raw'].load), lfilter=lambda x: x.haslayer(Ether) and x.fields['type'] == 0x8088) A lambda function was used to filter the sniffed packet, so that it will print only the packets with an Ether layer (haslayer(Ether)) and with the 0x8088 data type. 7
  • 10. Networking Scapy – Communication on Layer 2 Conclusion Scapy is a very powerfull packet-manipulation tool, and with its help we have demonstrated that almost any kind of data can be inserted into an ethernet packet. In this case we have inserted a simple string("blablabla"). For larger chunks of data, it is required to "chop" the data into smaller pieces that could fit into a packet. 8