Room Banner

Linux Server Forensics

Learn about digital forensics artefacts found on Linux servers by analysing a compromised server

medium

75 min

Room progress ( 0% )

To access material, start machines and answer questions login.

Task 1Deploy the first VM
You have been hired to investigate a data breach at ACME web design. Log in to the target machine using SSH with the following credentials:
  • MACHINE_IP
  • Username - 'fred'
  • Password - 'FredRules!'
Answer the questions below
Q1 Deploy the machine and log in to the VM using the provided credentials.
The most significant attack surface on the server is probably the web service; fortunately, the Apache access log keeps a history of all of the requests sent to the webserver and includes:

1. source address
2. response code and length
3. user-agent

Every request from a modern browser should contain a user-agent string that can be used to identify it roughly. The content of the user-agent string is then used to modify the experience by displaying the mobile version of a site or disabling features not supported on older browsers.

We can also use this string to identify traffic from potentially malicious tools as scanning tools like Nmap, SQLmap, DirBuster and Nikto leak their identity's through default user-agent strings.

Answer the questions below
Navigate to /var/log/apache2

How many different tools made requests to the server?

Name a path requested by Nmap.
Web scanners are run against servers pretty much all the time, so this traffic is not out of the ordinary.
Have a look around the site for potential attack vectors.
Answer the questions below
What page allows users to upload files?

What IP uploaded files to the server?

Who left an exposed security notice on the server?
It looks like our attacker got in via Remote File Inclusion (RFI). It's best to look around the system itself now for any evidence of persistence mechanisms that could lead to a payload. There are multiple ways to maintain persistence in most Linux distributions including but not limited to:

  1. cron
  2. Services/systemd
  3. bashrc
  4. Kernel modules
  5. SSH keys

Cron is one of the more common methodologies, so it's probably best to start there.


Answer the questions below
What command and option did the attacker use to establish a backdoor?

It looks like the command from the previous task was set up to run under the root2 account. This account doesn't make any sense as there should only be one root account. Wonder how it got there?

There are a couple of locations where account information is stored on Linux distributions, including:

  1. /etc/passwd  - contains the names of most of the accounts on the system.  Should have open read permissions and should not contain password hashes. 
  2. /etc/shadow -  contains names but should also contain password hashes.  Should have strict permissions.
Answer the questions below
What is the password of the second root account?

Wow, it looks like they got hacked again! Better have another look; the credentials are the same as last time:

  1. MACHINE_IP
  2. 'fred'
  3. 'FredRules!'
Answer the questions below
 Deploy the second machine and log in to the VM using the provided credentials.

The log file is a lot smaller this time around, so it looks like our attacker was a little more subtle. There also don't appear to be obvious user agents anymore. Fortunately, there are a few other ways of identifying traffic originating from scanners. The time between each request is a good metric for most tools. You can also identify individual tools from signatures left in the requests; for example, Nmap will send HTTP requests with a random non-standard method when performing certain enumeration tasks. More aggressive tools can also be identified simply from the number of requests sent during any given attack; directory brute-forcing tools are a perfect example of this and are likely to fall foul of banning systems like fail2ban.

A poorly designed site may also freely grant valuable information without the need for aggressive tools. In this case, the site uses sequential IDs for all of the products making. It easily scrapes every single product or finds the total size of the product database by simply increasing the product ID until a 404 error occurs.

Answer the questions below
Name one of the non-standard HTTP Requests.

At what time was the Nmap scan performed? (format: HH:MM:SS)

The adversary has been a little smarter this time around. If any backdoor exists, it's likely to be more subtle. SSH-keys are another excellent way of maintaining access, so it might be worth looking for additions to the authorized_keys file. 
Answer the questions below
What username and hostname combination can be found in one of the authorized_keys files? (format: username@hostname)

Of course, adding a public key to root's authorized_keys requires root-level privileges so, it may be best to look for more evidence of privilege escalation. In general, Linux stores a tiny amount of programme execution history when compared to Windows but, there are still a few valuable sources, including:

  1. bash_history - Contains a history of commands run in bash; this file is well known, easy to edit and sometimes disabled by default.
  2. auth.log - Contains a history of all commands run using sudo.
  3. history.log (apt) - Contains a history of all tasks performed using apt - is useful for tracking programme installation and removal.

systemd services also keep logs in the journald system; these logs are kept in a binary format and have to be read by a utility like journalctl. This binary format comes with some advantages; however, each journal is capable of validating itself and is harder to modify.

Answer the questions below
What is the first command present in root's bash_history file?

This is getting a little annoying now. The credentials are still the same:

  1. MACHINE_IP
  2. 'fred'
  3. 'FredRules!'
Answer the questions below

Deploy the final machine and log in to the VM using the provided credentials.

Malware can also maintain persistence using systemd as scripts run under systemd can run in the background and restart whenever the system is booted or whenever the script crashes. It is also relatively easy to conceal malicious scripts as they can blend in with other services. systemd services are defined in .service files which can contain:


  1. The command that runs whenever the service starts
  2. The user the service runs as
  3. An optional description 

In this case, the malware is pretty obvious as it seems to be printing errors to the screen so, there is no way that it is dormant. Running systemctl will list all of the services loaded into the system. And much like Windows, there's usually a lot of them. It might be worth adding --type=service --state=active to the command as it will reduce the list to services that are running. Once the name of a suspicious service is found, more information can then be extracted by running systemctl status <service name> . 

Answer the questions below
Figure out what's going on and find the flag.

Room Type

Free Room. Anyone can deploy virtual machines in the room (without being subscribed)!

Users in Room

9,897

Created

1537 days ago

Ready to learn Cyber Security? Create your free account today!

TryHackMe provides free online cyber security training to secure jobs & upskill through a fun, interactive learning environment.

Already have an account? Log in

We use cookies to ensure you get the best user experience. For more information contact us.

Read more