root před 7 roky
rodič
revize
ce37093261
2 změnil soubory, kde provedl 0 přidání a 283 odebrání
  1. 0
    133
      README-en-bk
  2. 0
    150
      README-es.md-bk

+ 0
- 133
README-en-bk Zobrazit soubor

@@ -1,133 +0,0 @@
1
-# Classes - Simple Sniffer
2
-
3
-##Objectives
4
-
5
-1. Practice Data Structures, Classes and Inheritance
6
-
7
-## Pre-Lab:
8
-
9
-Before you get to the laboratory you should have:
10
-
11
-1. Reviewed C++ classes and structures
12
-2. Studied the concepts and instructions for this laboratory session.
13
-3. Taken the Pre-Lab quiz in Moodle
14
-
15
-## Simple Sniffer
16
-
17
-Computers communicate with each other through the Internet Protocol (IP).  When a computer sends information to another computer it is sent via Internet packets that contain the Internet address of the sender computer (source address), the source port of the application that is sending the message, the Internet address of the receiving computer(destination address), and the port of the application that will receive the message.
18
-
19
-We can compare the Internet address to the address of a house, and the applications to the members of the house. When sending a letter from one house to another, the address on the letter identifies the destination house, and the name on the letter identifies the house member to who it is sent.
20
-
21
-For instance when your lab computer is contacting the department's web server, the packets that carry the information from your computer to the web server contains the source address of the lab computer and the destination address of the web server;  and the source port of your web browser and the destination port of the web server.
22
-
23
-Internet addresses are represented on 4 bytes (32 bits) normally presented to users as strings of 4 decimal values. Each decimal value is the decimal representation of one of the 4 bytes:  "(0-255).(0-255).(0-255).(0-255)". Examples of IP addresses are: 10.0.1.10, 192.168.10.11, 136.145.54.10, and so on.
24
-
25
-Port numbers are composed of 2 bytes or 16 bits.  Therefore port numbers range from 0-65535. There are ports numbers assigned to known application services such as number 22 for ssh, 23 for telnet, 25 smtp, 80 for http, and so on.
26
-
27
-To complicate things a little bit, each computer network card has an unique identifier that is used for the communication between you computer and the network device that routes the network traffic from the Internet and local network to your computer and vice-versa (Ethernet protocol).  This unique identifier is known as the Hardware address (a.k.a Multiple Access Controll (MAC) addres), is represented on 6 bytes (48 bits), and is presented to users as strings of 6 hexadecimal values. Each hex value is the hex representation of the 6 bytes: "(00-ff):(00-ff):(00-ff):(00-ff):(00-ff):(00-ff)".  Examples of MAC addresses are: e0:f8:47:01:e9:90, 70:ad:60:ff:fe:dd:79:d8 , and so on.
28
-
29
-A packet sniffer (a.k.a packet analyzer, protocol analyzer, or network analyzer) is a computer program that can intercept and log traffic passing over a digital network, or network device.  As data flow across the network, the sniffer captures each packet and, if needed decodes the packet's raw data[1].
30
-
31
-
32
-The packets captured by this program follow the following packet structure:
33
-
34
-1. first an Ethernet header which contains the source and destination MAC addresses
35
-2. second a IP header that contains the source and destination IP addresses
36
-3. third a header that contains the source and destination port numbers.
37
-
38
-In this application we create a simple packet sniffer that captures all the IP packets that flow across your lab computer, and for each packet, decodes the IP addresses, the port numbers, and some additional information of the packets.  Additionaly it detects the unencrypted request of images in the web, and displays the images in the GUI.
39
-
40
-See the following snapshot of the application:
41
-![](images/ss.png)
42
-
43
-Each row in the table is the information of each captured packet, the text box under the table presents a ASCII summary of a selected packet from the table, and the list in the right presents the images that have been requested and are seen in you network card.  
44
-
45
-The application that you are about to complete gives the user the ability to analyze the network traffic and monitor the images that are being watched in your network.  
46
-
47
-## Laboratory session:
48
-
49
-To create a packet sniffer you can use the *pcap* library that provides an interface to access the data passing across your network card.  This library contains a function that returns a raw stream of bytes of each packet captured.  It is the task of the sniffer programmer to decode the raw stream into human readable information.  Fortunately this is not your task, but you can learn how to do it, if you want, by reading the source code of this laboratory.  Your task is to follow the exercises below so you provide the packet sniffer with the needed objects (Classes) to process the packets.
50
-
51
-## Exercise 1: Familiriaze your self with the application
52
-
53
-####Instructions
54
-
55
-1. To load this project you need to run qt creator with root privileges.
56
-        ```sudo qtcreator Documents/eip/simplesniffer/SimpleSniffer.pro```
57
-
58
-2. The project `SimpleSniffer` is in the directory `Documents/eip/simplesniffer` of your computer. You can also go to `http://bitbucket.org/eip-uprrp/classes-simplesniffer` to download the folder `classes-simplesniffer` to your computer.
59
-
60
-3. Configure the project.  The project consists of several files.  In this laboratory you will be working with the files `ethernet_hdr.h`, `ethernet_packet.h`, `ethernet_packet.cpp`, `ip_packet.h` and `ip_packet.cpp`
61
-
62
-
63
-## Exercise 2: Complete the class ethernet_packet
64
-
65
-Read the file `ethernet_hdr.h`, it contains the definition of the data structure that represents an Ethernet header.  It is also shown below:
66
-
67
-```
68
-#define ETHER_ADDR_LEN 6
69
-
70
-struct sniff_ethernet {
71
-        u_char  ether_dhost[ETHER_ADDR_LEN];    /* destination host address */
72
-        u_char  ether_shost[ETHER_ADDR_LEN];    /* source host address */
73
-        u_short ether_type;                     /* IP? ARP? RARP? etc */
74
-};
75
-```
76
-
77
-The Ethernet header above is used to decode the ethernet part of the raw data in each packet.  It is composed of the source MAC address (ether_shost, 6 bytes), the destiantion MAC address (ether_dhost, 6 bytes), and the type of Ethernet packet (ether_type, 2 bytes) which is used to determine if the packet is an IP packet.
78
-
79
-As you can see, it is not a good idea to show this information format to a regular user.  Your first task is to define the functions of the C++ class that defines the functions to translate the MAC address information into human readable strings.
80
-
81
-The class header is in file `ethernet_packet.h` and is also shown below:
82
-
83
-```
84
-class ethernet_packet
85
-{
86
-
87
-    sniff_ethernet ethernet ;
88
-    // Returns a 6 bytes MAC address in string representation.
89
-    string mac2string(u_char []) ;
90
-
91
-public:
92
-    ethernet_packet();  // Default constructor
93
-
94
-    // Set the ethernet variable member ether_dhost to the values
95
-    // received in the array
96
-    void setEtherDHost(u_char []) ;
97
-    // Same as above but to the ether_shost
98
-    void setEtherSHost(u_char []) ;
99
-
100
-    // Set the ethernet type to the value received.
101
-    void setEtherType(u_short) ;
102
-
103
-    // returns the string representation of the ethernet addresses
104
-    string getEtherDHost() ;
105
-    string getEtherSHost() ;
106
-
107
-    // Return the ethernet type
108
-    u_short getEtherType() ;
109
-
110
-};
111
-```
112
-
113
-Define the functions in file `ethetnet_packet.cpp`
114
-
115
-## Exercise 3: Construct the header of class ip_packet  
116
-
117
-For Exercise 3 see the definitions of the functions of the class ip_packet found in file `ip_packet.cpp`
118
-
119
-Your task is to define the class header following the functions inside the file.  The member variables are:
120
-* two `string`s to store the source and destination IP addresses
121
-* a one byte (`char`) variable to store the IP protocol
122
-* two `unsigned short` variables to store the source and destination port
123
-* one `string` to store the packet payload.
124
-
125
-This class header that you are defining inherits from the class that you defined in Exercise 2.
126
-
127
-### Deliverables
128
-
129
-Use "Deliverables" in Moodle to upload the files `ethernet_packet.cpp` y `ip_packet.h` that you defined.
130
-
131
-### References
132
-
133
-[1]http://en.wikipedia.org/wiki/Packet_analyzer

+ 0
- 150
README-es.md-bk Zobrazit soubor

@@ -1,150 +0,0 @@
1
-# Clases - Sniffer Simple
2
-
3
-##Objetivos
4
-
5
-1. Practicar la declaración e implementación de clases en C++.
6
-
7
-
8
-## Pre-Lab:
9
-
10
-Antes de llegar al laboratorio debes:
11
-
12
-1. Haber repasado la declaración e implementación de clases en C++.
13
-2. Haber estudiado los conceptos e instrucciones para la sesión de laboratorio.
14
-3. Haber tomado el quiz Pre-Lab que se encuentra en Moodle.
15
-
16
-## Sniffer Simple
17
-
18
-Las computadoras se comunican con otras a través del protocolo de Internet (IP).  Cuando una computadora envia información a otra computadora es via paquetes de Internet que contienen la dirección de Internet de la computadora que envia (computadora fuente), el puerto fuente de la aplicación que está enviando el mensaje, la dirección de Internet de la computadora que recibe (computadora destino), y el puerto de la aplicación que va a recibir el mensaje.
19
-
20
-Podemos comparar las direcciones de Internet a las direcciones de una casa, y las aplicaciones a los miembros de una casa.  Cuando se envia una carta de una casa a otra, la dirección en la carta identifica la casa destino, y el nombre en la carta identifica al miembro de la casa al que se le envía.
21
-
22
-Por ejemplo cuando tu computadora de laboratorio esta contactactando al servidor de web del departamento, los paquetes que cargan la informacion de tu computadora al servidor de web contienen la dirección fuente de la computadora del laboratorio y la dirección destino del servidor de web; y el puerto fuente del tu buscador de web (browser) y el puerto destino del servidor de web.
23
-
24
-Las direcciones de Internet son representados usando 4 bytes (32 bits), y comunmente son presentadas a los usuarios como cadenas de caracteres de 4 valores decimales.  Cada valor decimal es la representacion decimal de uno de los 4 bytes: "(0-255).(0-255).(0-255).(0-255)". Por ejemplo, las siguientes son tres direcciones IP  10.0.1.10, 192.168.10.11, 136.145.54.10.
25
-
26
-Los números de los puertos son enteros sin signo en el rango de [0-65535]. Se representan usando 2 bytes (16 bits). Hay números de puertos que son asignados a servicios de aplicaciones comúnes tales como el número 22 para ssh, 23 para telnet, 25 smtp, y el 80 para http.
27
-
28
-Para complicar las cosas un poco, cada tarjeta de red de computadoras tiene un identificador único que es usado para la comunicación entre tu computadora y el dispositivo de la red que enruta el tráfico de red de Internet y la red local a tu computadora y vice-versa (protocolo Ethernet). Este identificador único es conocido como la dirección de Hardware (también conocido como dirección MAC), es representado usando 6 bytes (48 bits), y es presentado a los usarios como una cadena de caracteres de 6 pares de dígitos hexadecimales (cada par de dígitos hexadecimal corresponde a 1 byte). Por ejemplo, los siguientes son direcciones MAC:  `e0:f8:47:01:e9:90` y  `70:ad:60:ff:fe:dd:79:d8`.
29
-
30
-Un sniffer de paquetes (también conocido como analizador de paquetes, analizador de protocolos, o analizador de red) es un programa de computadora que puede interceptar y registrar tráfico pasando a través de una red digital, o dispositivo de red.  Mientras los datos fluyen a través de la red, el sniffer captura cada paquet, y si es necesario decodifica los datos crudos del paquete[1].
31
-
32
-Cada paquete capturado por este programa tiene la siguiente estructura:
33
-
34
-1. un encabezado de Ethernet que contiene las direcciones MAC fuente y destino
35
-2. un encabezado de IP que contiene las direcciones IP fuente y destino
36
-3. un encabezado que contiene los números de puerto fuente y destino
37
-
38
-En esta experiencia de laboratorio completaremos un sniffer de paquetes sencillo que captura todos los paquetes de IP que fluyen a través de tu computadora de laboratorio, y alguna información adicional de los paquetes.  Adicionalmente detecta las solicitudes no encriptadas de imagenes en la web, y despliega las imágenes en el GUI.
39
-
40
-
41
-
42
-
43
-----
44
-
45
-![](images/ss.png)
46
-
47
-**Figura 1** - La aplicación corriendo.
48
-
49
-----
50
-
51
-La Figura 1 muestra una foto de la aplicación. Cada fila en la tabla es la información de un paquete capturado, la caja de texto bajo la tabla presenta un resumen en ASCII del paquete seleccionado en la tabla, y la lista en el lado derecho presenta las imagenes que han sido solicitadas y se han visto en la tarjeta de red.
52
-
53
-La aplicación que tu estas a punto de completar le da a los usuarios la habilidad de analizar el tráfico de red y monitorear imagenes que estan siendo vistas en tu red.
54
-
55
-
56
-## Sesión de laboratorio
57
-
58
-Para crear un sniffer de paquetes puedes usar la librería de *pcap* que provee una interface para accesar la data que está pasando a través de tu tarjeta de red.  Esta librería contiene una función que devuelve un torrente crudo de los bytes de cada paquete capturado.
59
-
60
-Es la tarea del programador del sniffer decodificar el torrente en crudo a información legible por humanos.  Afortunadamente esta no va a ser tu tarea, pero tu puedes aprender a hacerlo, si quieres, leyendo el código fuente de este laboratorio.  Tu tarea es seguir los ejercicios abajo para que puedas proveerle al sniffer los objetos necesarios (Clases) para procesar los paquetes.
61
-
62
-## Ejercicio 1: Familiriarizate con la aplicación
63
-
64
-**Instrucciones**
65
-
66
-1. Para cargar este proyecto necesitas correr qt creator con privilegios de administrador (root).
67
-        ```sudo qtcreator Documents/eip/simplesniffer/SimpleSniffer.pro```
68
-
69
-2. El proyecto `SimpleSniffer` está en el directorio `Documents/eip/simplesniffer` de tu computadora.  Alternativamente puedes crear un clon del repositorio git `http://bitbucket.org/eip-uprrp/classes-simplesniffer` para descargar el directorio `classes-simplesniffer` a tu computadora.
70
-
71
-3. Configura el proyecto. El proyecto consiste de varios archivos.  En este laboratorio trabajarás con los archivos `ethernet_hdr.h`, `ethernet_packet.h`, `ethernet_packet.cpp`, `ip_packet.h` and `ip_packet.cpp`.
72
-
73
-## Ejercicio 2: Completa la clase ethernet_packet
74
-
75
-Lee el archivo `ethernet_hdr.h`, este contiene la definición de la estructura de datos que representa un encabezado de Ethernet. A continuación mostramos esa definición:
76
-
77
-```
78
-#define ETHER_ADDR_LEN 6
79
-
80
-struct sniff_ethernet {
81
-        u_char  ether_dhost[ETHER_ADDR_LEN];    /* direccion destino */
82
-        u_char  ether_shost[ETHER_ADDR_LEN];    /* direccion fuente */
83
-        u_short ether_type;                     /* IP? ARP? RARP? etc */
84
-};
85
-```
86
-
87
-El encabezado de Ethernet arriba es usado para decodificar la parte Ethernet de los datos crudos en cada paquete.  Este se compone de la dirección MAC fuente (ether_shost, 6 bytes), la dirección MAC destino (ether_dhost, 6 bytes), y el tipo de paquete de Ethernet (ether_type, 2 bytes) que es usado para determinar si el paquete es un paquete de IP.
88
-
89
-Como puedes ver, no es una buena idea enseñar este formato de información a un usario regular.  Tu primer tarea es definir las funciones de la clase de C++ que define las funciones para traducir la información de las direcciones MAC a cadenas de caracteres legibles por humanos.
90
-
91
-El encabezado de la clase está en el archivo `ethernet_packet.h` y también la mostramos a continuación:
92
-
93
-```
94
-class ethernet_packet
95
-{
96
-
97
-    sniff_ethernet ethernet ;
98
-    // Devuelve una direccion de 6 bytes MAC en una cadena de caracteres.
99
-    string mac2string(u_char []) ;
100
-
101
-public:
102
-    ethernet_packet();  // Constructor por defecto
103
-
104
-    // Ajusta la variable miembro ether_host a los valores
105
-    // recibidos en el arreglo
106
-    void setEtherDHost(u_char []) ;
107
-    // Lo mismo que arriba pero al  ether_shost
108
-    void setEtherSHost(u_char []) ;
109
-
110
-    // Ajusta el ethernet type al valor recibido.
111
-    void setEtherType(u_short) ;
112
-
113
-    // Devuelve la representación en cadenas de caracteres de las direcciones
114
-    // Ethernet
115
-    string getEtherDHost() ;
116
-    string getEtherSHost() ;
117
-
118
-    // Devuelve el tipo de ethernet.
119
-    u_short getEtherType() ;
120
-
121
-};
122
-```
123
-
124
-Implementa las funciones en el archivo `ethetnet_packet.cpp`.
125
-
126
-**[Rafa] Puedes sugerir una forma para que validen si han implementado bien la función.**
127
-
128
-## Ejercicio 3: Construye el encabezado de ip_packet
129
-
130
-Para el Ejercicio 3 debes estudiar las definiciones de las funciones de la clase `ip_packet` que se encuentra en el archivo `ip_packet.cpp`
131
-
132
-Tu tarea es definir el **encabezado** de la clase siguiendo las funciones en ese archivo.  Las variables miembro son:
133
-
134
-* dos variables  `string` para almacenar las direcciones de IP fuente y destino
135
-* una variable de un byte (`char`) para almacenar el typo de protocolo IP
136
-* dos variables `unsigned short` para almacenar el puerto fuente y destino
137
-* una variable `string` para almacenar la carga del paquete.
138
-
139
-En la declaración de la clase `ip_packet` debes especificar que es una clase derivada de la clase `ethernet_packet`.
140
-
141
-### Entregas
142
-
143
-Utiliza "Entrega" en Moodle para entregar los archivos `ethernet_packet.cpp` y `ip_packet.h` que definistes.
144
-
145
-### Referencias
146
-
147
-[1]http://en.wikipedia.org/wiki/Packet_analyzer
148
-
149
-
150
-----