Network Packet Analysis and Scapy Introduction

Similar documents
Python Scripting with Scapy

Network Forensics Network Traffic Analysis

Introduction to Websites & Dynamic Content

Network Attacks. Blossom Hands-on exercises for computer forensics and security

Lab Conducting a Network Capture with Wireshark

Why use Scapy? Blue Team. Red Team. Test IDS/IPS Test Firewall Learn more about TCP/IP (down and dirty) Application response(fuzzing)

A Research Study on Packet Sniffing Tool TCPDUMP

Make a folder named Lab3. We will be using Unix redirection commands to create several output files in that folder.

CS197U: A Hands on Introduction to Unix

Packet Sniffing with Wireshark and Tcpdump

Assignment 3 Firewalls

Safe network analysis

Wireshark Lab: Assignment 1w (Optional)

EKT 332/4 COMPUTER NETWORK

Ethereal: Getting Started

Intrusion Detection and Prevention: Network and IDS Configuration and Monitoring using Snort

Introduction to Network Security Lab 1 - Wireshark

TCP Packet Tracing Part 1

EXPLORER. TFT Filter CONFIGURATION

USING WIRESHARK TO CAPTURE AND ANALYZE NETWORK DATA

Modern snoop lab lite version

Host Fingerprinting and Firewalking With hping

Cisco Configuring Commonly Used IP ACLs

School of Information Science (IS 2935 Introduction to Computer Security, 2003)

Customer Tips. Network Packet Analyzer Tips. for the user. Purpose. Introduction to Packet Capture. Xerox Multifunction Devices.

Introduction to Passive Network Traffic Monitoring

Tcpdump Lab: Wired Network Traffic Sniffing

Basic Firewall Lab. Lab Objectives. Configuration

SQL Injection. Blossom Hands-on exercises for computer forensics and security

Lab Objectives & Turn In

Forensic Imaging and Artifacts analysis of Linux & Mac (EXT & HFS+)

Packet Sniffing and Spoofing Lab

Lab 1: Packet Sniffing and Wireshark

Wireshark Tutorial INTRODUCTION

Network Traffic Analysis

ΕΠΛ 674: Εργαστήριο 5 Firewalls

CS 326e F2002 Lab 1. Basic Network Setup & Ethereal Time: 2 hrs

Attack Lab: Attacks on TCP/IP Protocols

Homework 3 TCP/IP Network Monitoring and Management

Network Security. Network Packet Analysis

Lab 2. CS-335a. Fall 2012 Computer Science Department. Manolis Surligas

QualNet 4.5 Network Emulation Interface Model Library

INTERNET SECURITY: THE ROLE OF FIREWALL SYSTEM

Firewall Testing. Cameron Kerr Telecommunications Programme University of Otago. May 16, 2005

co Characterizing and Tracing Packet Floods Using Cisco R

Large-Scale TCP Packet Flow Analysis for Common Protocols Using Apache Hadoop

ΕΠΛ 475: Εργαστήριο 9 Firewalls Τοίχοι πυρασφάλειας. University of Cyprus Department of Computer Science

finger, ftp, host, hostname, mesg, rcp, rlogin, rsh, scp, sftp, slogin, ssh, talk, telnet, users, w, walla, who, write,...

Lab VI Capturing and monitoring the network traffic

Packet Sniffing on Layer 2 Switched Local Area Networks

Attacking the TCP Reassembly Plane of Network Forensics Tools

1. The Web: HTTP; file transfer: FTP; remote login: Telnet; Network News: NNTP; SMTP.

UPPER LAYER SWITCHING

Classic IOS Firewall using CBACs Cisco and/or its affiliates. All rights reserved. 1

Snoopy. Objective: Equipment Needed. Background. Procedure. Due Date: Nov 1 Points: 25 Points

Appendix A: Configuring Firewalls for a VPN Server Running Windows Server 2003

Practical Network Forensics

Network Address Translation (NAT)

LAB THREE STATIC ROUTING

Stateful Firewalls. Hank and Foo

Figure 1. Wireshark Menu Bar

Overview. Protocol Analysis. Network Protocol Examples. Tools overview. Analysis Methods

Hands-on Network Traffic Analysis Cyber Defense Boot Camp

ReadyNAS Remote White Paper. NETGEAR May 2010

Introduction To Computer Networking

How To Set Up An Ip Firewall On Linux With Iptables (For Ubuntu) And Iptable (For Windows)

Linux Network Security

Internet Protocol: IP packet headers. vendredi 18 octobre 13

Internet Firewall CSIS Packet Filtering. Internet Firewall. Examples. Spring 2011 CSIS net15 1. Routers can implement packet filtering

Network Traffic Evolution. Prof. Anja Feldmann, Ph.D. Dr. Steve Uhlig

Pre-lab and In-class Laboratory Exercise 10 (L10)

Lecture 2-ter. 2. A communication example Managing a HTTP v1.0 connection. G.Bianchi, G.Neglia, V.Mancuso

1. LAB SNIFFING LAB ID: 10

ZEN LOAD BALANCER EE v3.04 DATASHEET The Load Balancing made easy

Track 2 Workshop PacNOG 7 American Samoa. Firewalling and NAT

IP Filter/Firewall Setup

Project Overview and Setup. CS155: Computer and Network Security. Project Overview. Goals of the assignment. Setup (2) Setup

Introduction to Analyzer and the ARP protocol

Scapy. On-the-fly Packet Generation by Dienstag, 10. Januar 12

Lab 7: Introduction to Pen Testing (NMAP)

EE984 Laboratory Experiment 2: Protocol Analysis

Chapter 11 Cloud Application Development

Using IPM to Measure Network Performance

Wireshark Tutorial. Figure 1: Packet sniffer structure

Information Security Training. Assignment 1 Networking

Voice over IP. Demonstration 1: VoIP Protocols. Network Environment

New York University Computer Science Department Courant Institute of Mathematical Sciences

Scanning Tools. Scan Types. Network sweeping - Basic technique used to determine which of a range of IP addresses map to live hosts.

Firewall VPN Router. Quick Installation Guide M73-APO09-380

How To Understand The Internet Of S (Netware)

EventSentry Overview. Part I About This Guide 1. Part II Overview 2. Part III Installation & Deployment 4. Part IV Monitoring Architecture 13

Multi-Homing Dual WAN Firewall Router

Chapter 11 Phase 5: Covering Tracks and Hiding

Dynamic Host Configuration Protocol (DHCP) 02 NAT and DHCP Tópicos Avançados de Redes

Firewalls. Chien-Chung Shen

Protecting and controlling Virtual LANs by Linux router-firewall

Lab exercise: Working with Wireshark and Snort for Intrusion Detection

Firewalls and Software Updates

Introduction to Network. Topics

CS155: Computer and Network Security

Transcription:

Copyright: The development of this document is funded by Higher Education of Academy. Permission is granted to copy, distribute and /or modify this document under a license compliant with the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/. Network Packet Analysis and Scapy Introduction BLOSSOM Manchester Metropolitan University (Funded by Higher Education Academy) l.han@mmu.ac.uk

1. Learning Objectives This lab aims to understand network packet and how to use Scapy for network packet analysis 2. Preparation 1) Under Linux environment 2) Some files that you will need from /home/user/blossomfiles/introtoscapy: 'SecLab1.zip SimplePacketParser.py' 'SwitchCase.py' 3) Some documents that you may need to refer to: 3. Tasks 'Virtual-MachineGuide.pdf' Linux-Guide.pdf BLOSSOM-UserGuide.pdf Setup & Installation: Start two virtual machines as you have done with previous exercises (see Virtual Machine Guide): # kvm -cdrom /var/tmp/blossomfiles/blossom-0.98.iso -m 512 -net nic,macaddr=52:54:00:12:34:57 -net vde -name node-one Unzip the file SecLab1.zip as it contains all the files required for this lab: # unzip SecLab1.zip

Task 1 Network Traffic Analysis: 1.1 Download the Python and Trace files 1.2 Store all of the files in a single folder 1.3 Run each of the Python files one at a time through command prompt using the command: #python SimplePacketParser.py <trace_filename> 1.4 Follow the simple instructions that should be displayed in order to discover packet header information for Ethernet, IP, ARP, TCP and ICMP headers. Questions: What are the sources and destination ports of the TCP Header? What are the source and target hardware addresses of the ARP Header? What are the source and destination addresses of the Ethernet Header? What is the sequence number of the ICMP Header? What are the source and destination addresses of the IP Header?

Task 2 Scapy Introduction 2.1 Scapy is a packet manipulation tool written in Python. It provides an python interface to libpcap. We can use it to create, send and receive packets. We can also create our own network monitor tool based on Scapy. Please refer to Scapy (http://www.secdev.org/projects/scapy/doc/) for more information. After scapy has been successfully installed on both of the virtual machines, packets can now be sent between both of them using scapy. Run scapy using the following command: #scapy 2.2 Scapy can create many different packets and send them between machines on a network. There are two useful commands to remember, which are: #ls() #ls(protocol) The first command lists all of the available protocols, and the second command lists all of the details relevant to a specific protocol. For instance, if you type ls(ip), you will see all of the details that can be edited when creating an IP packet. 2.3 In order to create a basic IP packet and send it to the other machine, an IP packet must be created with the destination address set to that of the other machine, so if the first machines IP address is 10.0.2.16 and the second machines IP address is 10.0.2.17, the following command must be used to create and send the packet: #send(ip(dst= 10.0.2.17 )) This will send an IP packet from machine 1 to machine 2, and if we were watching the network traffic, we would see the packet being transferred. 2.4 In order to create a basic ARP packet and send it to the other machine, the process is very similar to that of an IP packet, except with a few minor differences. The command used is: #send(arp(pdst= 10.0.2.17 )) The packet name is listed as ARP instead of IP, and pdst is used instead of dst. Each packet in scapy has different variable names, so if you wish to find out about any other packets, it s important to bear in mind the ls(protocol) command mentioned previously.

2.5 In order to create a basic TCP packet and send it to the other machine, the process is again very similar to that of an ARP and IP packet. The command used is: #topt=[( Timestamp, (10,0))] #send(tcp(dport=22, options=topt)) TCP packets make use of destination ports as opposed to IP addresses, so the requirement of a destination address isn t necessary, except for specifying the type of TCP communication that is to be created (ie, port 22 for SSH connections). The timestamp option must be added when sending TCP packets over a virtual network to ensure that the packets are not dropped instantly. Question: What would the command be to create a UDP packet and send it across a network? This should be very similar to creating and sending a TCP packet.

Task 3 Protocols / Layers HTTP/FTP 3.1 Scapy has the ability to layer packets, as well as the ability to create sets of packets that mimic specific protocol sessions, such as HTTP and FTP communication sessions. Start off with a standard IP packet with the source and destination addresses set accordingly: #packet = IP(src= 10.0.2.16, dst= 10.0.2.17 ) 3.2 Now that the initial packet has been created, an extra layer can be added on to the packet, such as a TCP layer: #packet = packet/tcp() This will add a TCP layer to the IP packet. Each detail of the packet can be edited as well, by using such commands as the following: #packet.ttl = 10 #packet[tcp].sport = 1025 The first command will change the time to live of the IP packet, whereas the second packet specifies that the source port of the TCP layer will be changed to 1025. This can be done to any detail at any layer of the packet. Question: What would the list of commands be to create a packet with two layers, IP and TCP, with the IP source address of 192.168.0.1 and the IP destination address of 192.168.0.2, and the TCP source port of 22. 3.3 In order to simulate a HTTP session, a payload must also be layered inside the packet by doing the following: #HTTPpacket=packet/ GET HTTP/1.1\r\n\r\n This will add the payload of a GET HTTP request to the packet, creating a makeshift HTTP packet. Question: In a similar fashion to the HTTPpacket created previously, can you create an FTP packet? HINT: Look up FTP packet payloads, and the FTP TCP port number.

Task 4 Scapy - Sniffing 4.1 Scapy can also be used to sniff packets on a network very easily. When scapy is running, use the following command: #sniff() 4.2 After running the sniff() command on one virtual machine, go to the other virtual machine and send a few packets to across the virtual network using the commands from task 2. After a few packets have been sent, press CTRL+C. A brief summary of the types of packets that have been sniffed should be displayed. 4.3 In order to display the packets that have been sent in more detail, the following two commands must be used: #a=_ #a.nsummary() In python, the underscore displays the latest result, so the first command stores the latest result as the variable, a. The second command displays a summary of the packets that have been sniffed in more detail. If even more detail is required for each packet, the following command can be used: #a[0] The above command will display the full information for the first packet 4.4 The sniff() command can also have filters applied to it, allowing for the amount of packets that will be sniffed to be significantly reduced. Use the following command: #sniff(iface= eth0, filter= ip, count=5) After using the above command, send some IP and ARP packets across the virtual network and then view the summary as discussed in 3.3. The iface option specifies the interface to listen on, for which we chose eth0. The filter option specifies the type of packet to listen for, for which we chose ip, and count specifies how many packets should be listened to before the sniffing stops. The result of the previous command should result in only 5 IP packets being displayed in the summary, with the ARP packets being filtered out. Question: What command would you use to sniff 100 ARP packets on the interface eth0?