2019 oplossingen labo 4 - Lars Lemmens

Met dank aan de Github van Martijn en natuurlijk Lars Lemmens

Labo 4

What is the IP address of the client and what IP address is used by the server?

Which protocol was used to find the IP address of the FTP server.

Does FTP use UDP or TCP? Why?

Is the session using active or passive FTP?

Who chooses the FTP version, active or passive? Is it the client or the server?

Sketch the three-way handshake used to negotiate the initial sequence numbers. Do this both for the relative and the real sequence numbers.

What is the benefit in using relative sequence numbers in Wireshark/Tshark?

Which credentials were used to login to the FTP service?

'user@:~$' • tshark -r Cnw2_ftp.pcap -Y "tcp.srcport == $(tshark -r Cnw2_ftp.pcap -Y 'ftp.response.code == 230' -T fields -e tcp.dstport) && ftp.request.command == USER" -T -e ftp.request.arg

"Step 1:

When a user's login attempt is successful, the FTP server answers with FTP response code 230 <- Response code: User logged in, proceed (230).

This message is sent to the client using it's chosen TCP port. This very same TCP port is used by the client for every packet sent in the control connection.

So we know the client will use this port as TCP source port when profiding the FTP username. Thus the first step is to find this TCP port:

See Cnw2 theory - Chapter 2: Application Layer: Active vs Passive FTP

'user@:~$' • tshark -r Cnw2_ftp.pcap -Y 'ftp.response.code == 230' -T fields -e tcp.dstport

Step 2:

The port we just found is the TCP port the client uses for the FTP control connection.

When using this port as TCP source port in our display filter, we'll only list packets sent from client to FTP server

'user@:~$' • tshark -r Cnw2_ftp.pcap -Y "tcp.srcport == $(tshark -r Cnw2_ftp.pcap -Y 'ftp.response.code == 230' -T fields -e tcp.dstport)"

Step 3:

We're only interested in the packet containing the username, so let's add 'ftp.request.command == USER' to the display filter:

'user@:~$' • tshark -r Cnw2_ftp.pcap -Y "tcp.srcport == $(tshark -r Cnw2_ftp.pcap -Y 'ftp.response.code == 230' -T fields -e tcp.dstport) && ftp.request.command == USER"

Step 4:

And finally use the tshark fields option to only display the username used:

'user@:~$' • tshark -r Cnw2_ftp.pcap -Y "tcp.srcport == $(tshark -r Cnw2_ftp.pcap -Y 'ftp.response.code == 230' -T fields -e tcp.dstport) && ftp.request.command == USER" -T fields -e ftp.request.arg debbie

Which file was downloaded/uploaded from/to the FTP server? (delete as appropriate)

'user@~$' • tshark -r Cnw2_ftp.pcap -Y 'ftp.request.command == RETR' | grep -Po 'RETR \K.*'

Can you reconstruct this file from the Wireshark packet dump? Open the file to verify it's contents are intact.

How many packets have their destination port set to 21?

'user@~$' • tshark -r Cnw2_ftp_bruteforce.pcap -Y 'tcp.dstport == 21' | wc -l

List all packets which have the PUSH bit set. What is the benefit in setting this bit?

'user@~$' • tshark -r Cnw2_ftp_bruteforce.pcap -Y 'tcp.flags.push == 1'

How can you manually calculate the actual port advertised by the PASV/PORT command?

'user@~$' • tshark -r Cnw2_ftp.pcap -Y 'ftp.response.code == 227' | awk -F ',' '{print $5*256+$6}'

How many L4 sessions were created in the FTP session? Note: passive FTP was used in this session.

'user@~$' • tshark -r Cnw2_ftp.pcap -Y 'ftp.response.code == 230 || ftp.response.code == 227' | wc -l

Try to answer these questions with 'cnw2_ftp_bruteforce.pcap: (file)'

How many password guesses were made?

'user@~$' • tshark -r Cnw2_ftp_bruteforce.pcap -Y 'ftp.request.command == PASS' -T fields -e ftp.request.arg | wc -l

Did the attacker finally get in?

'user@~$' • tshark -r Cnw2_ftp_bruteforce.pcap -Y 'ftp.response.code == 230' | grep -q 'Response: 230' && echo YES || echo NO

Which usernames did he/she try?

'user@~$' • tshark -r Cnw2_ftp_bruteforce.pcap -Y 'ftp.request.command == USER' -T fields -e ftp.request.arg | sort -u

Revision #1
Created 17 June 2021 14:14:22 by Jasper G.
Updated 3 December 2021 22:13:09 by Jasper G.