17
Wireshark wireshark Capturing packets Capture filter Display filter Follow streams Wireshark Jose L. Muñoz, Oscar Esparza, Juanjo Alins, Jorge Mata Telematics Engineering Universitat Politècnica de Catalunya (UPC) 1/17

Wireshark Slides

Embed Size (px)

DESCRIPTION

Primeros pasos y ejercicios para manejar el software de analisis de redes wireshark.

Citation preview

Page 1: Wireshark Slides

Wireshark

wiresharkCapturing packets

Capture filter

Display filter

Follow streams

Wireshark

Jose L. Muñoz, Oscar Esparza, Juanjo Alins, Jorge MataTelematics Engineering

Universitat Politècnica de Catalunya (UPC)

1/17

Page 2: Wireshark Slides

Wireshark

wiresharkCapturing packets

Capture filter

Display filter

Follow streams

Outline

1 wireshark

2/17

Page 3: Wireshark Slides

Wireshark

wiresharkCapturing packets

Capture filter

Display filter

Follow streams

Getting Started I

• Wireshark has become the “defacto”, open-source toolfor protocol analysis.

• It provides low-level packet filtering, analytical capabilityand it can be used to store captured traffic in a file forlater analysis.

• Once installed, you can run the protocol analyzer froma terminal typing wireshark.

• However, if you run Wireshark with an unprivileged useryou can only open pcap files (not capture in real time).

• To run wireshark as root in Linux, type (or login as root):$ sudo wireshark

• In the initial Wireshark screen you have available thelist of all the interfaces of the system.

3/17

Page 4: Wireshark Slides

Wireshark

wiresharkCapturing packets

Capture filter

Display filter

Follow streams

Getting Started II

• Click on one of the network interfaces to start capturingpackets.

4/17

Page 5: Wireshark Slides

Wireshark

wiresharkCapturing packets

Capture filter

Display filter

Follow streams

Capturing Packets I

• To capture packets you have to select a networkinterface.

• When you select an interface, you will be able to seepackets moving through that interface.

• When there are captured packets available, you canselect a packet and view its fields as decoded bywireshark and also in ASCII and hexadecimal.

• Furthermore, in the bottom left corner of the Wiresharkwindow, the protocol analyzer displays the size of thepacket or field selected.

5/17

Page 6: Wireshark Slides

Wireshark

wiresharkCapturing packets

Capture filter

Display filter

Follow streams

Capturing Packets II• In the example of the figure we have selected the IP

source address of a packet that as you see occupies 4bytes as expected.

6/17

Page 7: Wireshark Slides

Wireshark

wiresharkCapturing packets

Capture filter

Display filter

Follow streams

Capture Options I

• You can also select the capture options before staringthe capture.

• In our case, we will unset all the “Name resolution”options and we will set always the ”Capture packets inPromiscuous mode“.

• This mode allows wireshark to capture data link layerframes that are not destined to our host.

• That is to say, frames that have a destination linkaddress that is not the one that has our networkinterface.

7/17

Page 8: Wireshark Slides

Wireshark

wiresharkCapturing packets

Capture filter

Display filter

Follow streams

Capture Options II

• Finally, notice that you can select a ”Capture Filter”.

8/17

Page 9: Wireshark Slides

Wireshark

wiresharkCapturing packets

Capture filter

Display filter

Follow streams

Capture filters I

• Capture filters are used to select the data to record inthe logs.

• They are defined before starting the capture.• The basic syntax for creating capture filters is the

following:

(Parameter Value) Logical_Operation (Parameter Value) ...

9/17

Page 10: Wireshark Slides

Wireshark

wiresharkCapturing packets

Capture filter

Display filter

Follow streams

Examples I

• To capture only traffic to or from IP address 172.18.5.4,you can type the following capture filter:host 172.18.5.4

• To capture traffic to or from a range of IP addresses,you can type the following capture filter (both areequivalent):net 192.168.0.0/24net 192.168.0.0 mask 255.255.255.0

• To capture traffic from a range of IP addresses, you cantype the following capture filter (both are equivalent):src net 192.168.0.0/24src net 192.168.0.0 mask 255.255.255.0

10/17

Page 11: Wireshark Slides

Wireshark

wiresharkCapturing packets

Capture filter

Display filter

Follow streams

Examples II

• To capture traffic to a range of IP addresses, you cantype the following capture filter (both are equivalent):dst net 192.168.0.0/24dst net 192.168.0.0 mask 255.255.255.0

• To capture only HTTP (port 80) traffic, you can type thefollowing capture filter:port 80

• To capture non-HTTP and non-SSH traffic on192.168.0.1, you can type the following capture filter(both are equivalent):host 192.168.0.1 and not (port 80 or port 22)host 192.168.0.1 and not port 80 and not port 22

11/17

Page 12: Wireshark Slides

Wireshark

wiresharkCapturing packets

Capture filter

Display filter

Follow streams

Examples III

• To capture all traffic except ICMP and HTTP traffic, youcan type the following capture filter:port not 80 and not icmp

• To capture traffic within a range of ports, for exampleTCP ports between 2001 and 2500, you can type thefollowing capture filter:tcp portrange 2001-2500

• To capture packets with source IP address 10.4.1.12 orsource network 10.6.0.0/16 and having destination TCPport range from 2001 to 2500 and destination IPnetwork 10.0.0.0/8, you can type the following capturefilter:(src host 10.4.1.12 or src net 10.6.0.0/16) andtcp dst portrange 2001-2500 and dst net 10.0.0.0/8

12/17

Page 13: Wireshark Slides

Wireshark

wiresharkCapturing packets

Capture filter

Display filter

Follow streams

Display Filter I

• Display filters are used to search inside the capturedlogs.

• They can be applied and modified while data is beingcaptured.

• You may wonder if you should use a capture or adisplay filter.

• Notice that the goals of the two filters are different.• The capture filter is used as a first large filter to limit the

size of captured data to avoid generating a log too big.

13/17

Page 14: Wireshark Slides

Wireshark

wiresharkCapturing packets

Capture filter

Display filter

Follow streams

Display Filter II

• The display filter is much more powerful (and complex);it will permit you to search exactly the data you want.

• Wireshark uses display filters for general packetfiltering while viewing and for its coloring rules.

• The basics and the syntax of the display filters aredescribed in the Wireshark User’s Guide and you canalso use the Analyze menu (option Display filters) tobuild your display filter.

14/17

Page 15: Wireshark Slides

Wireshark

wiresharkCapturing packets

Capture filter

Display filter

Follow streams

Examples I

• To display only HTTP (port 80) and ICMP traffic, youcan type the following display filter:tcp.port eq 80 or icmp

• To display only traffic between workstations in the LAN192.168.0.0/16, you can type the following display filter:ip.src==192.168.0.0/16 and ip.dst==192.168.0.0/16

• To match HTTP requests where the last characters inthe URL/URI are the characters “html”, you can typethe following display filter:http.request.uri matches "html$"

• Note: The $ character is a regular expression thatmatches the end of a string, in this case the end ofhttp.request.uri field.

15/17

Page 16: Wireshark Slides

Wireshark

wiresharkCapturing packets

Capture filter

Display filter

Follow streams

Streams I

• Another very useful functionality of Wireshark that weare going to use is the “Follow stream”.

• This feature can be selected from the Analyze menuand it works as follows:

• If you have a TCP or UDP packet selected and youselect “Follow TCP stream” or “Follow UDP stream”, itwill appear in a separate window all the contents of thedata stream to which that packet belongs.

• In addition, the main display of Wireshark will leave thelist of packets in a filtered state, with only those packetsthat are part of that TCP or UDP stream beingdisplayed.

• You can revert to your old view by pressing ENTER inthe display filter text box, thereby invoking your olddisplay filter (or resetting it back to no display filter).

16/17

Page 17: Wireshark Slides

Wireshark

wiresharkCapturing packets

Capture filter

Display filter

Follow streams

Streams II

17/17