Snort Logger
Snort Logger
Snort Logger
com/room/snort
•
Dashboard
•
Learn
•
Compete
Leaderboards
Platform Rankings
King of the Hill
Attack & Defend
Workspace
Compete & Collaborate
•
Other
Resources Buy Vouchers Develop Rooms For Business For Education Swag Shop
•
•
• Go Premium
• 4
951
Learn how to use Snort to detect real-time threats, analyse recorded traffic files and identify anomalies.
Difficulty: Medium
32%
Task 1 Introduction
1 of 5 2/18/24, 18:05
TryHackMe | Snort https://tryhackme.com/room/snort
Parameter Description
-l Logger mode, target log and alert output directory. Default output folder is /var/log/snort
-n Specify the number of packets that will process/read. Snort will stop after reading the specified number of packets.
Let's start using each parameter and see the difference between them. Snort needs active traffic on your interface, so we need to
generate traffic to see Snort in action.
Logfile Ownership
Before generating logs and investigating them, we must remember the Linux file ownership and permissions. No need to deep
dive into user types and permissions. The fundamental file ownership rule; whoever creates a file becomes the owner of the
corresponding file.
Snort needs superuser (root) rights to sniff the traffic, so once you run the snort with the "sudo" command, the "root" account will
own the generated log files. Therefore you will need "root" rights to investigate the log files. There are two different approaches to
investigate the generated log files;
• Elevation of privileges - You can elevate your privileges to examine the files. You can use the "sudo" command to execute
your command as a superuser with the following command sudo command . You can also elevate the session privileges
and switch to the superuser account to examine the generated log files with the following command: sudo su
• Changing the ownership of files/directories - You can also change the ownership of the file/folder to read it as your user:
sudo chown username file or sudo chown username -R directory The "-R" parameter helps recursively process the
files and directories.
Once the traffic is generated, Snort will start showing the packets and log them in the target directory. You can configure the
default output directory in snort.config file. However, you can use the "-l" parameter to set a target directory. Identifying the default
log directory is useful for continuous monitoring operations, and the "-l" parameter is much more useful for testing purposes.
The -l . part of the command creates the logs in the current directory. You will need to use this option to have the logs for each
exercise in their folder.
logging with -l
Now, let's check the generated log file. Note that the log file names will be different in your case.
user@ubuntu$ ls .
snort.log.1638459842
As you can see, it is a single all-in-one log file. It is a binary/tcpdump format log. This is what it looks like in the folder view.
Now run the traffic-generator script as sudo and start ICMP/HTTP traffic. Once the traffic is generated, Snort will start showing
the packets in verbosity mode as follows;
2 of 5 2/18/24, 18:05
TryHackMe | Snort https://tryhackme.com/room/snort
user@ubuntu$ ls .
The logs created with "-K ASCII" parameter is entirely different. There are two folders with IP address names. Let's look into them.
user@ubuntu$ ls ./192.168.175.129/
Once we look closer at the created folders, we can see that the logs are in ASCII and categorised format, so it is possible to read
them without using a Snort instance.
In a nutshell, ASCII mode provides multiple files in human-readable format, so it is possible to read the logs easily by using a text
editor. By contrast with ASCII format, binary format is not human-readable and requires analysis using Snort or an application like
tcpdump.
Let's compare the ASCII format with the binary format by opening both of them in a text editor. The difference between the binary
log file and the ASCII log file is shown below. (Left side: binary format. Right side: ASCII format).
3 of 5 2/18/24, 18:05
TryHackMe | Snort https://tryhackme.com/room/snort
Note that Snort can read and handle the binary like output (tcpdump and Wireshark also can handle this log format). However, if
you create logs with "-K ASCII" parameter, Snort will not read them. As you can see in the above output, Snort read and displayed
the log file just like in the sniffer mode.
Investigate the traffic with the default configuration file with ASCII mode.
sudo ./traffic-generator.sh
Now, you should have the logs in the current directory. Navigate to folder "145.254.160.237". What is the source port used to
connect port 53?
Use snort.log.1640048004
Read the snort.log file with Snort; what is the IP ID of the 10th packet?
snort -r snort.log.1640048004 -n 10
Read the "snort.log.1640048004" file with Snort; what is the referer of the 4th packet?
Read the "snort.log.1640048004" file with Snort; what is the Ack number of the 8th packet?
Read the "snort.log.1640048004" file with Snort; what is the number of the "TCP port 80" packets?
Task 11 Conclusion
4 of 5 2/18/24, 18:05
TryHackMe | Snort https://tryhackme.com/room/snort
ujohn
This is a free room, which means anyone can deploy virtual machines in the room (without being subscribed)! 40480 users are in
here and this room is 706 days old.
5 of 5 2/18/24, 18:05