IPv6 with scapy (NETLAB)

Purpose

To practice networking and packet crafting with IPv6 using static addresses.

Starting your Sender Machine

Open the Kali32 virtual machine. This is your Sender machine. Log in as root with the password toor

Assigning a Static IPv6 Address on the Sender Machine

On the Sender machine, open a Terminal window and execute these commands:
ifconfig eth0 add 2100::101/64

ip -6 route add default via 2100::1

ifconfig eth0

The first command assigns a static IPv6 address to the interface, and the second one assigns an IPv6 default route.

Your network adapter now has three addresses, as shown below.

The "Link" scope address is automatically configured by the adapter, and only works for traffic on the local network segment, like a MAC address.

The "Global" scope address could be used for communication over the Internet, if it were in a range provided to you by an ISP.

In IPv4, the most common address classes are /8, /16, and /24, also called classes A, B, and C. In IPv6, the addresses are 128 bits long, and the most commmon address type is /64.

Starting your Receiver Machine

Open the Kali64 virtual machine. This is your Receiver machine. Log in as root with the password toor

Assigning a Static IPv6 Address on the Receiver Machine

On the Receiver machine, open a Terminal window and execute these commands:
ifconfig eth0 add 2100::102/64

ip -6 route add default via 2100::1

ifconfig eth0

Your network adapter now has three addresses, as shown below.

Testing IPv6 Connectivity from the Sender Machine

On the Sender machine, execute this command:
ping6 2100::102
You should see replies, as shown below.

Press Ctrl+C to stop the pings.

Creating an IPv6 Object with Scapy

In the Sender machine, execute these commands to create an IPv6 packet and examine it:
scapy

i = IPv6()

i.display()

As you can see, the "version" is now 6, as shown below on this page. The "src" and "dst" addresses are both set to "::1", which is the IPv6 loopback address, analogous to 127.0.0.1 in IPv4.

If the colors are difficult to see, adjust them by clicking Edit, "Profile Preferences", Colors. I used "Black on light yellow".

In the Sender machine, execute these commands to assign the IPv6 destination address,

i.dst = "2100::102"

i.display()

As shown below, the src address automatically fills in.

Creating an ICMPv6EchoRequest object

In the Sender machine, in the Terminal window, at the >>> prompt, execute these commands to create an ICMPv6EchoRequest packet and examine it:
ic = ICMPv6EchoRequest()

ic.display()

As shown below, this is a very simple packet, analogous to a normal IPv4-style ICMP ping:

Sending the ICMPv6EchoRequest packet

Use this command to send the packet and look at the reply:
sr1(i/ic)
You should see a response with type=Echo Reply, as shown below on this page.

Use these commands to send a packet with your name in it, and look at the reply:

ic.data = "YOUR NAME"

sr1(i/ic)

You should see a response with your name in it, as shown below on this page.

Sending a UDP Packet

Preparing the Receiver Machine

On your Receiver Machine, execute this command to start scapy listening, and cause it to collect the first packet that comes in on on UDP port 4444, and put it in an object named p:
scapy

p = sniff(filter="udp and dst port 4444", count=1)

The Terminal waits for network traffic, as shown below on this page.

Sending an UDP Packet from scapy

In the Sender machine, in the Terminal window, at the >>> prompt, type these commands, and then press the Enter key:
u = UDP()

u.dport = 4444

u.display()

This creates an object named u of type UDP, directed at port 4444, and displays its properties, as shown below.

Execute this command to send an UDP packet to the Windows machine:

send(i/u/"YOUR NAME SENT VIA IPv6 UDP\n")
On the Receiver Machine, execute this command to see the received UDP packet.
p[0]
You should windows like those shown below. The Sender Machine is in the left window, and the Receiver Machine is on the right


Sources

http://packetstorm.Sendersecurity.com/papers/general/blackmagic.txt

http://www.secdev.org/projects/scapy/

http://ipv6hawaii.org/?p=143

Last modified 5-1-12
Update for NETLAB 6-11-16