CyberDefenders / ARTICLE

Hammered Lab

Lab solution ahead. This writeup contains answers and investigation steps for a CyberDefenders training challenge.

بسم الله والصلاة والسلام على رسول الله
اللهم علمنا ما ينفعنا وانفعنا بما علمتنا وقنا عذاب النار

challenge link :

https://cyberdefenders.org/blueteam-ctf-challenges/hammered/


Scenario : This challenge takes you into virtual systems and confusing log data. In this challenge, as a SOC Analyst figure out what happened to this webserver honeypot using the logs from a possibly compromised server.


In this lab, I was given a large set of logs, so I decided to use Splunk.\
I’ll first show you how to download, install, and run it, and then how to upload the log files so I can start analyzing them.

Step One: Installing Splunk on linux

Go to :

Splunk | The Key to Enterprise Resilience\
Build digital resilience in the AI era with Splunk, the leading security, observability, and machine data platform …www.splunk.com

┌──(kali㉿Anas404)-[~/Desktop]
└─$ ls    
anas  Hammered  images  NEXT "splunk-10.0.0-e8eb0c4654f8-linux-amd64.tgz"  UNADJUSTEDNONRAW_thumb_4859.jpg  Veriarty

sudo tar xvzf splunk-10.0.0-e8eb0c4654f8-linux-amd64.tgz -C /opt

cd /opt/splunk/bin

sudo ./splunk start --accept-license

open the Browser :
127.0.0.1:8000 

sudo ./splunk enable boot-start

sudo ./splunk enable status

Upload The Log Files ( You’ll repeat the same steps for each log file.\
I created a separate index for every file- that was easier for me. )

Our Log Files

we Upload : \
user.log , secure , kern.log , dmesg.log , debug , daemon.log , auth.log , apache logs [ access.log , error.log , media.log ] , apt logs “ term.log”


Which service did the attackers use to gain access to the system?

list all indexes

The first thing we notice is that the auth logs are very large. We’ll take a look at the auth logs.

When I looked at the TTY, I found around 20,000 SSH attempts, which is brute-force behavior , trying to use SSH repeatedly to connect to the victim.

And we found a huge number of authentication failures and more than 30 different users, so without a doubt, the attacker was using SSH to connect to the system.

ans → ssh


What is the operating system version of the targeted system?

When I searched through the dmesg logs to understand their function and format, I found that the OS along with its version appears in the log entries.

The dmesg command is a Linux utility that displays kernel-related messages retrieved from the kernel ring buffer. The ring buffer stores information about hardware, device driver initialization, and kernel module messages during system startup.

How to View Kernel Messages in Linux | dmesg Command – GeeksforGeeks\
Your All-in-One Learning Portal: GeeksforGeeks is a comprehensive educational platform that empowers learners across…www.geeksforgeeks.org
Linux dmesg Command: Syntax, Options, Examples\
This tutorial shows how to use the dmesg Linux command to examine the kernel ring buffer and troubleshoot device…phoenixnap.com

Log Format :

to get operating system version :

ans → 4.2.4–1ubuntu3


What is the name of the compromised account?

After we identified that the attacker used SSH around 20,000 times to connect to the victim, we will now try to display the users with their attempt counts to determine the targeted victim.\
The targeted user will have the highest number of attempts.

from auth.log

5476 attempts on the root user.\
ans → root


How many attackers, represented by unique IP addresses, were able to 
successfully access the system after initial failed attempts?

→ This question took me some time because I didn’t use any scripts, as I wanted to extract the result manually.\
→ It’s very important to note that the IP must have a failure first and then an accepted attempt, since you might find an IP that has an accepted login without any failures at all.

Step 1: Extract all IPs with authentication failures.\
Step 2: Extract all IPs with authentication accepted.\
Step 3: Identify the intersection between both sets.\
Step 4: Using a query in Splunk, verify whether the intersected IPs had failures before being accepted.\
Step 5 : We can check this by analyzing the failure counts. If the count is very low (e.g., 1 or 2), it’s likely that no actual brute-force failure occurred, or it requires deeper investigation. In that case, we capture it and review its logs in detail.

  • This is the structure of the failure log, and we need to extract the IP section, which is field number 14.

It’s possible that an IP had failures but no accepted attempts, and vice versa. That’s why we will display all the accepted ones.

## 10.0.1.4 → Accepted: 4 , Failure: 1 \
61.168.227.12 → Accepted: 1 , Failure: 213\
## 65.88.2.5 → Accepted: 6 , Failure: 1\
## 76.191.195.140 → Accepted: 19 , Failure: 1\
## 94.52.185.9 → Accepted: 2 , Failure: 1\
121.11.66.70 → Accepted: 2 , Failure: 1435\
122.226.202.12 → Accepted: 2 , Failure: 513\
## 188.131.23.37 → Accepted: 4 , Failure: 2\
## 190.166.87.164 → Accepted: 23 , Failure: 2\
## 208.80.69.74 → Accepted: 7 , Failure: 1\
219.150.161.20 → Accepted: 4 , Failure: 9259\
222.169.224.197 → Accepted: 1 , Failure: 646\
222.66.204.246 → Accepted: 1 , Failure: 1573

The IPs with a low number of failures usually don’t have failed attempts followed by accepted ones. We will test this on one IP with a low failure count and verify.

If we look at the remaining IPs, we can see that they have a very high number of failure attempts.\
When we display the accepted attempts, we find they are relatively lowwith the highest number of accepted logins being only 4.

61.168.227.12 → Accepted: 1\
121.11.66.70 → Accepted: 2\
122.226.202.12 → Accepted: 2\
219.150.161.20 → Accepted: 4 \
222.169.224.197 → Accepted: 1\
222.66.204.246 → Accepted: 1

ans → 6


Which attacker's IP address successfully logged into the system the most number of times?

ans → 219.150.161.20


How many requests were sent to the Apache Server?

from apache logs “access.log”

ans → 365


How many rules have been added to the firewall?

Firewall activity and changes are often logged in system files like auth.log

The firewall service is usually named firewalld or iptables, and we will try both.

ans → 6


When was the last login from the attacker with IP 219.150.161.20? 

ans → 2010–04–19 05:56


The database showed two warning messages. Please provide the most critical and potentially dangerous one.

Database warnings are often logged in system logs, such as daemon.log.

ans → mysql.user contains 2 root accounts without password!


Multiple accounts were created on the target system. Which account was created on April 26 at 04:43:15?

from auth.log


Few attackers were using a proxy to run their scans. What is the corresponding user-agent used by this proxy?

we look at access logs for abnormal user-agent


سبحانك اللهم وبحمدك أشهد أن لا إله إلا أنت أستغفرك وأتوب إليك
← All journal articles
Scroll to Top
Home