| 1 | = Capture and Analise Packets = |
| 2 | |
| 3 | In this lab session, we will use tcpdump and Wireshark to capture packets. To analyze them we will use Wireshark. |
| 4 | |
| 5 | == Packet Capturing using tcpdump == |
| 6 | |
| 7 | - Go to the ubuntu VM |
| 8 | |
| 9 | - use tcpdump command to capture packets |
| 10 | {{{ |
| 11 | tcpdump -nn |
| 12 | }}} |
| 13 | |
| 14 | - you will get outputs like following |
| 15 | {{{ |
| 16 | IP 199.59.148.139.443 > 192.168.1.8.54343: Flags [P.], seq 53:106, |
| 17 | ack 1, win 67, options [nop,nop,TS val 854797891 ecr 376933204], |
| 18 | length 53 |
| 19 | }}} |
| 20 | |
| 21 | - You can try tcpdump with different attributes |
| 22 | {{{ |
| 23 | tcpdump –nni eth0 host 10.10.10.10 |
| 24 | tcpdump –nni eth0 dst host 10.10.10.10 and tcp |
| 25 | tcpdump –nni eth0 src net 10.10.10.0/24 and tcp and portrange 1-1024 |
| 26 | tcpdump –nni eth0 –s0 |
| 27 | tcpdump –nni eth0 not port 22 –s0 –c 1000 |
| 28 | tcpdump –nni eth0 not port 22 and dst host 10.10.10.10 and not src net 10.20.30.0/24 |
| 29 | |
| 30 | -nn = don’t use DNS to resolve IPs and display port no |
| 31 | -i = interface to watch |
| 32 | dst = watch only traffic des0ned to a net, host or port |
| 33 | src = watch only traffic whose src is a net, host or port |
| 34 | net = specifies network |
| 35 | host = specifies host |
| 36 | port = specifies a port |
| 37 | proto = protocol ie tcp or udp |
| 38 | -s0 = seIng samples length to 0 m |
| 39 | -c = number of packets |
| 40 | }}} |
| 41 | |
| 42 | - You can capture packets and save them to a file |
| 43 | {{{ |
| 44 | # tcpdump –nni eth0 -w capture.pcap –vv –c 1000 |
| 45 | # tcpdump –nni eth0 –r capture.pcap port 80 |
| 46 | |
| 47 | -w capture.pcap = save capture packet to capture.pcap |
| 48 | –vv = display number of packet captured |
| 49 | -r capture.pcap = read capt |
| 50 | }}} |
| 51 | |
| 52 | - You can open the created file and see the captured packets |
| 53 | |
| 54 | == Wireshark == |
| 55 | |
| 56 | Download Wireshark from [https://www.wireshark.org/download.html here] and install Wireshark. Installation is very simple. |
| 57 | |
| 58 | === Captureing Packets from wireshark === |
| 59 | |
| 60 | Once you open the Wireshark you will get the following interface. |
| 61 | [[Image(https://ws.learn.ac.lk/raw-attachment/wiki/netsec2018wireshark/welcome.png)]] |
| 62 | |
| 63 | You can select the interface that you want to capture packets by clicking on the interface listed there. Then you can click the '''Start Capture''' to capture the packets. |
| 64 | [[Image(https://ws.learn.ac.lk/raw-attachment/wiki/netsec2018wireshark/start.png)]] |
| 65 | |
| 66 | You will see the packets capturing. Click the '''Stop Capture''' button when you want to stop the capturing. |
| 67 | [[Image(https://ws.learn.ac.lk/raw-attachment/wiki/netsec2018wireshark/stop.png)]] |
| 68 | |
| 69 | |
| 70 | You can save the captured packets by clicking '''File>Save as...''' and Clicking '''Save''' after you select a Location |
| 71 | |
| 72 | You can change the interface and add or remove the filter by clicking the '''Options''' button. |
| 73 | [[Image(https://ws.learn.ac.lk/raw-attachment/wiki/netsec2018wireshark/options.png)]] |
| 74 | |
| 75 | === Filters === |
| 76 | |
| 77 | Wireshark has a lot of filters. Let's try a simple filter. Let's capture only the packets that are using ICMP protocol. |
| 78 | |
| 79 | You will the filter text field in the Wireshark interface. Type '''icmp''' there and start capturing. You can try different filters. |
| 80 | |
| 81 | - '''ip.addr == <Your IP address>''' [Sets a filter for any packet with 10.0.0.1, as either the source or dest] |
| 82 | - '''ip.addr==<Your IP address> && ip.addr==<neighbors IP address>''' [sets a conversation filter between the two defined IP addresses] |
| 83 | - '''http or dns''' [sets a filter to display all http and dns] |
| 84 | - '''tcp.port==53''' [sets a filter for any TCP packet with 4000 as a source or dest port] |
| 85 | - '''http.request''' [displays all HTTP GET requests] |
| 86 | - '''!(arp or icmp or dns)''' [masks out arp, icmp, dns, or whatever other protocols may be background noise. Allowing you to focus on the traffic of interest] |
| 87 | |
| 88 | === Analysing === |
| 89 | |
| 90 | Download the sample packet capture files from here. Open them from Wireshark to analyze them. Go to '''File>Open''' and select the pcap file to be open. |
| 91 | |
| 92 | '''Telnet.pcap''' |
| 93 | [https://ws.learn.ac.lk/raw-attachment/wiki/netsec2018wireshark/telnet.pcap download] |
| 94 | |
| 95 | - What is the Username and Password? |
| 96 | - What did the User do after login? |
| 97 | Open the file. Filter all the telnet traffic. Go to Analyse>Follow>TCP Stream. |
| 98 | |
| 99 | '''massivesyn.pcap''' |
| 100 | [https://ws.learn.ac.lk/raw-attachment/wiki/netsec2018wireshark/massivesyn.pcap download] |
| 101 | - Is this an attack? If so what type of an attack? |
| 102 | Open the file, Go to Statistics>Coversation. Check for the type of packet, Source IP and the duration |
| 103 | |
| 104 | '''chat.dmp''' |
| 105 | [https://ws.learn.ac.lk/raw-attachment/wiki/netsec2018wireshark/chat.dmp download] |
| 106 | - What are the email addresses of the chatters? |
| 107 | - What were they planning to do? |
| 108 | Open the file. Go to Analyse>Follow>TCP Stream. |
| 109 | |
| 110 | '''ftp.pcap''' |
| 111 | [https://ws.learn.ac.lk/raw-attachment/wiki/netsec2018wireshark/ftp.pcap download] |
| 112 | - What is the IP address of the FTP server and the Client? |
| 113 | - What is the error code 530? |
| 114 | Open the file. Statistics>Coversation. Click TCP. Check the Statistics. Go to Analyse>Follow>TCP Stream |
| 115 | |
| 116 | '''foobar.pcap''' |
| 117 | [https://ws.learn.ac.lk/raw-attachment/wiki/netsec2018wireshark/foobar.pcap download] |
| 118 | - What is the protocol use TCP 6346? |
| 119 | - What could be this scenario? |
| 120 | Open the file. Statistics>Coversation and check for source and destination IP and port. Go to Statistics>Protocol Hierarchy |
| 121 | |
| 122 | '''covertinfo.pcap''' |
| 123 | [https://ws.learn.ac.lk/raw-attachment/wiki/netsec2018wireshark/covertinfo.pcap download] |
| 124 | - Is this a normal icmp packet? |
| 125 | Open the file. Statistics>Coversation and check for packet length. |
| 126 | |
| 127 | '''sip.pcap''' |
| 128 | [https://ws.learn.ac.lk/raw-attachment/wiki/netsec2018wireshark/sip_chat.pcap download] |
| 129 | - What is the protocol used for media? |
| 130 | - Can you listen to the phone conversation? |
| 131 | Statistics>Protocol Hierarchy check for UDP protocols. Use Telephony>(Protocol) > Analysis |