Transcription of IPv6 Packet Creation With Scapy Documentation - …
1 IPv6 Packet Creation with ScapyDocumentationRelease EggertJanuary 19, 2012 CONTENTS1 of this document .. Scapy Usage ..12 The Standard IPv6 Header33 The IPv6 Extension Hop-By-Hop Extension Header .. Destination Extension Header .. Routing Extension Header .. Fragment Extension Header .. Options ..74 The ICMPv6 Unreachable .. too Big .. Exceeded .. Problem .. Request and Echo Reply (Ping-Pong) ..125 Neighbor Solicitation .. Advertisement .. Solicitation .. Advertisement ..176 Multicast Router Router Solicitation .. Router Advertisement .. Router Termination.
2 207 Multicast Listener ..21iCHAPTERONEINTRODUCTIONW elcome to IPv6 Packet Creation with Scapy . This guide provides a list of some of the most often used IPv6-relatedheader types and how to build them with assume the reader has some familarity with IPv6 and related protocols, such as ICMPv6 or Neighbor won t explain the meaning ofeveryheader guide is being written as part of the project IPv6 Intrusion Detection System, funded by Structure of this documentIPv6 is a very complex thing made up of various components. To give this guide some structure, we ll first explainthe very core of IP, that is the basic IPv6-Header, the Extension-Headers and the ICMPv6-Headers.
3 We then examinethe rest of the IPv6 protocol suitefeature-by-feature, rather thanstack-by-stackorprotocol-by-protocol (for example,Neighbor Discovery is technically speaking part ICMPv6 as well). We hope this keeps the guide more each feature, we provide a link to the RFC in which that feature is specified in and show the header structures (the ascii-art tables from that RFC). We also show how Scapy maps the header fields to class features of IPv6 are not within the scope of the project and are therefore not included in this document. Basic Scapy UsageScapy is a tool written in python that allows you to easily create, manipulate, send and receive network packets.
4 Weassume the reader has a basic understanding of what Scapy is and how to use it, so we won t go into too much a more thorough introduction consider reading the official , we d like to outline some of the more important features: Different protocols and header types are represented by different classes, such asIPv6orICMP. You can stack protocols on top of each other, just like a real network stack would, by using the Slash-Operator(/):IPv6()/TCP()creates a TCP-over-IPv6- Packet . Packets can be viewed with theshow()andshow2()functions. They can be sent with thesend(),sendp(),sr(),sr1(),srp()functi ons.
5 Most, if not all, header options can be manipulated. They are class members and can be accessed either in theconstructor or via normal member access, like this:1 IPv6 Packet Creation with Scapy Documentation , Release (ttl=64) " " Scapy can fill header options. You don t need to provideallthe information. To see what options are available, youcoulduse thels()function orlook them up in this Basic Scapy Usage2 CHAPTERTWOTHE STANDARD IPV6 HEADERThe IPv6 Header is defined in RFC2460 and looks like this:+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+|Version| Traffic Class | Flow Label |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -+-+-+-+-+-+-+-+-+-+-+-+-+| Payload Length | Next Header | Hop Limit |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -+-+-+-+-+-+-+-+-+-+-+-+-+||++||+ Source Address +||++||+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+||++||+ Destination Address
6 +||++||+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+In Scapy IPv6 packets are represented by theIPv6-class. Scapy maps the header fields to the following class members:>>>ls(IPv6)version : BitField = (6)tc : BitField = (0)fl : BitField = (0)plen : ShortField = (None)nh : ByteEnumField = (59)hlim : ByteField = (64)src : SourceIP6 Field = (None)dst : IP6 Field = ( ::1 )Note the default values in the brackets. For example, the version -field should have the value 6 for IPv6.
7 Emptyfields will be filled by Scapy when passed to one of thesend()functions. As stated in the previous chapter, you canmanipulate the options in the constructor or via normal member access.:x = IPv6(src= fe80::0123:4567 ) IPV6 EXTENSION HEADERSC ompared with IPv4, the IPv6 header has duplicated in size. To not increase the size further, the basic header holdsonly those fields that are absolutley neccessary. Optional data has to be provided in extension defines 4 Extension Headers: theHop-By-Hop,Destination, of these headers (and the basic IPv6 header as well) has a fieldnext header.
8 It contains a number that specifieswhich header will follow. These values are: Hop-By-Hop: 0 Routing: 43 Fragment: 44 Destination: 60If the next header is part of another protocol ( TCP or UDP) then you have to use their protocol numbers (6 or 17,respectively). For a list of all protocol numbers, see no next header follow, an IPv6 Packet with no payload, then the value ofnext headershould be The Hop-By-Hop Extension HeaderThe Hop-By-Hop header is represented by theIPv6 ExtHdrHopByHop-class and looks like this:+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| Next Header | Hdr Ext Len | |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +||.
9 Options ..||+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+The class members are:>>>ls(IPv6 ExtHdrHopByHop)nh : ByteEnumField = (59)len : FieldLenField = (None)autopad : _PhantomAutoPadField = (1)options : _HopByHopOptionsField = ([])See sectionVariable Optionsbelow for a list of possible Packet Creation with Scapy Documentation , Release The Destination Extension HeaderThe Destination Header is represented by the class :py:class IPv6 ExtHdrDestOpt -class and looks like this:+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| Next Header | Hdr Ext Len | |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +||.
10 Options ..||+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+The class members are:>>>ls(IPv6 ExtHdrDestOpt)nh : ByteEnumField = (59)len : FieldLenField = (None)autopad : _PhantomAutoPadField = (1)options : _HopByHopOptionsField = ([])See sectionVariable Optionsbelow for a list of possible The Routing Extension HeaderThe Routing header is represented by theIPv6 ExtHdrRouting-class and looks like this:+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| Next Header | Hdr Ext Len | Routing Type | Segments Left |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -+-+-+-+-+-+-+-+-+-+-+-+-+||.