Qualification Round iHack 2024 — Capture The Flag (CTF)

Team: CYBERHAX from Universiti Teknologi Petronas

In the Qualification Round of iHack 2024 CTF, one of the challenges involved analysing log data using Splunk. The goal was to identify suspicious activities and potential security breaches based on the provided log files. This write-up details my approach to solving the challenge, the techniques I used, and the insights I gained.

Splunk logo from my original writeup

The challenge provided a set of log files from a simulated network environment. The task was to use Splunk to analyze the logs and identify any indicators of compromise (IOCs) or unusual activities that might suggest a security incident. Specifically, we needed to find instances of brute force attacks, suspicious login attempts, and any other anomalies.

iHack 2024 is the second CTF competition I have ever participated in. What makes this experience even more special is that it is also my debut in writing a CTF write-up. Alright, let’s see what I’ve got!

Digital Forensics and Incident Response (DFIR) Challenge

Happy SPLUNKing #2

text
What is IP of the attacker that successfully login into the victim machine?
Flag format: ihack24{ip_attacker}
text
Happy SPLUNKing #1 challenge
TodakX SOC has reported that their machine was RDP-brute forced where
the incident happenend on 23 July 2024. As a security analyst, you are
responsible to analyze further the incident via Splunk. Here is the
file of the challenge: https://drive.google.com/file/d/1UE5WkChAMjERB6lL9NKjZBJRIEO0n7nu/view?usp=sharing

Password zip file: ihacksplunk2024

Ubuntu credentials (hostname:root)
Username: ihack24
Password: root

Splunk credential
Username: player
Password: beg_to_dfir

I unzipped the provided file (Happy_SPLUNKing.zip) using the given password on the first challenge for DFIR category which is Password: ihacksplunk2024.

The Happy SPLUNKing ZIP archive listed at 5.25 GB

Inside the zip file was an .ovf file and I opened in VMWare.

I logged into the Ubuntu VM with the following credentials Username: ihack24 Password: root.

To find the Splunk IP address, I ran the ifconfig command which showed inet - 192.168.92.129.

Ubuntu terminal showing the lab VM and loopback addresses in ifconfig output

To query the data, I opened Splunk with the IP address 192.168.92.129:8000 and navigated to Search & Reporting app. Remember to also set the time to “All time”. Then, I ran the search query using this spl query:

text
index=* earliest="07/23/2024:00:00:00" latest="07/23/2024:23:59:59"
(EventCode=4625 OR EventCode=4624)

Splunk search for Windows event IDs 4625 and 4624, returning 14,268 events

EventCode 4625 indicates failed login attempts while EventCode 4624 indicates successful login attempts. This means that I can correlate failed and successful attempts to see if there are patterns indicating a successful brute force attack.

Next, I needed to search for the source IP address that attempted the RDP- brute forced attack. There are several IP addresses shown here so I took out 192.168.92.129 since this is the Splunk IP address and 127.0.0.1 represents localhost.

Splunk source address counts showing 192.168.8.41 at the top

Therefore, the potential external source IP attempting the attack appears to be 192.168.8.41 with the highest count of attempts at 76.177%.

text
Flag: ihack24{192.168.8.41}

Note: This question is actually related to the first challenge (Happy SPLUNKing #1). Unfortunately, I submitted the wrong flag for the first challenge and failed to get it correct. However, by following the steps outlined above, I successfully identified the IP address of the attacker for Happy SPLUNKing #2.

Happy SPLUNKing #3

text
What is the timestamp attacker success login into victim machine?
Flag format: ihack24{mm/dd/yy hh:mm:ss AM/PM} / ihack24{mm/dd/yyyy
hh:mm:ss AM/PM}

Example flag:
Flag format: ihack24{05/21/23 12:12:12 PM} /
ihack24{05/21/2023 12:12:12 PM}

To identify successful logins from the attacker, I ran a query to filter the data for events where the attacker successfully logged into the victim machine. The specific query used is:

  • index=*: This searches across all indexes in Splunk to ensure no relevant data is missed.
  • earliest=”07/23/2024:00:00:00" latest=”07/23/2024:23:59:59": This sets the time range to only include events from 23 July 2024.
  • EventCode=4624: This filters the results to only include events with EventCode 4624 that indicates a successful login.
  • Source_Network_Address=”192.168.8.41": This further filters the results to only include events where the source IP address is 192.168.8.41 and the IP address identified as the attacker in the brute force attempt.
text
index=* earliest="07/23/2024:00:00:00" latest="07/23/2024:23:59:59"
EventCode=4624 Source_Network_Address="192.168.8.41"

Splunk search narrowed to nine successful logon events from 192.168.8.41

Expanded results showing successful logons at 09:55:52 PM on 23 July 2024

The results show a total of 9 event logs that indicates successful logins from the attacker. These logs only have two different timestamps which are:

  • 07/23/24 09:55:58 PM
  • 07/23/24 09:55:52 PM

We see that 07/23/24 09:55:52PM is the earliest time for the attacker’s successful login so I just submitted this flag right away:

text
Flag: ihack24{07/23/24 09:55:52 PM}

Happy SPLUNKing #4

text
What is the attacker's first command after successfully enter
the victim machine?
Flag format: ihack24{command}

Using the same event log from 9 event logs indicating successful logins from the attacker, I started with a detailed look at the provided log that captures a successful logon event:

text
LogName=Security
EventCode=4624
EventType=0
ComputerName=DESKTOP-9O75B7U
SourceName=Microsoft Windows security auditing.
Type=Information
RecordNumber=126043
Keywords=Audit Success
TaskCategory=Logon
OpCode=Info
Message=An account was successfully logged on.

Subject:
 Security ID:  S-1-0-0
 Account Name:  -
 Account Domain:  -
 Logon ID:  0x0

Logon Information:
 Logon Type:  3
 Restricted Admin Mode: -
 Virtual Account:  No
 Elevated Token:  No

Impersonation Level:  Impersonation

New Logon:
 Security ID:  S-1-5-21-2496820411-3641734560-467521945-1002
 Account Name:  admin
 Account Domain:  DESKTOP-9O75B7U
 Logon ID:  0x532719
 Linked Logon ID:  0x0
 Network Account Name: -
 Network Account Domain: -
 Logon GUID:  {00000000-0000-0000-0000-000000000000}

Process Information:
 Process ID:  0x0
 Process Name:  -

Network Information:
 Workstation Name: kali
 Source Network Address: 192.168.8.41
 Source Port:  0

Detailed Authentication Information:
 Logon Process:  NtLmSsp
 Authentication Package: NTLM
 Transited Services: -
 Package Name (NTLM only): NTLM V2
 Key Length:  128

Interpretation:

  1. EventCode 4624: This code indicates a successful logon event.
  2. Logon Type 3: This logon type is a network logon, which typically means the access was made over a network connection.
  3. Source Network Address: The IP address 192.168.8.41 indicates the source of the logon attempt, which is a machine named kali. After gaining access, attackers usually want to understand the environment they’re in. This involves gathering system information to identify the OS version, hardware details, and installed updates. One of the most common commands for this purpose is systeminfo.

After a successful logon, attackers usually execute commands to gather information about the system they have accessed. One common command used for this purpose is systeminfo.

Why systeminfo?

  • systeminfo Command: This command provides detailed information about the system, including the operating system version, configuration, memory, network adapters, and more.
  • Attacker Behavior: Attackers often run systeminfo immediately after gaining access to understand the environment they have compromised.
text
Flag: ihack24{systeminfo}

Happy SPLUNKing #5

text
What folder path is being excluded from detection of Microsoft Defender?
Flag format: ihack24{path}

This challenge requires identifying the folder path that has been excluded from Microsoft Defender’s detection. I ran a search with:

text
index=*  "ExclusionPath"

Splunk showing 16 results for ExclusionPath

Upon running the query, I found results in two source:

  • WinEventLog:Microsoft-Windows-PowerShell/Operational (15 logs)
  • powershell:transcript (1 log)

Source breakdown with 15 PowerShell Operational entries and one transcript

The WinEventLog:Microsoft-Windows-PowerShell/Operational logs may contain PowerShell operational events but they might not have the detailed output of the commands.

The powershell:transcript log will contain a transcript of the PowerShell session which should include the exact command used to set the exclusion path and the output of that command.

I chose to focus on the powershell:transcript log because it provides a detailed transcript of the PowerShell session which likely includes the exact command for setting the exclusion path and its output.

Searched for the powershell:transcript log entry:

Splunk returning one PowerShell transcript for the exclusion search

As I was going through the transcript, I found the command that set the exclusion path for Microsoft Defender. The key part of the transcript showed:

PowerShell transcript showing the Defender exclusion command and folder path

This shows that the folder path C:\Windows\microsoft is being excluded from detection by Microsoft Defender.

text
PS C:\Windows> Add-MpPreference -ExclusionPath "C:\Windows\microsoft"

The flag:

text
Flag: ihack24{C:\Windows\microsoft}

Happy SPLUNKing #6

text
Backdoor IP address.
Flag format: ihack24{ip_address}

In the same PowerShell transcript where I found the exclusion path, there was a command that attempted to download a file from a remote server using Invoke-WebRequest:

PowerShell transcript showing the attempted remote download and connection error

This command shows that an attempt was made to download nmap.exe from the IP address 157.230.33.7 on port 8080. This IP address is likely being used as a backdoor for malicious activities.

text
Flag: ihack24{157.230.33.7}

Happy SPLUNKing #8

text
Tool that has been dropped by attacker to find other host.
Flag format: ihack24{toolname.fileextension}

In the same PowerShell transcript log, there was a command that attempted to download a file from a remote server using Invoke-WebRequest:

PowerShell download command with nmap.exe as the requested file and output name

This command shows that the attacker attempted to download a tool named nmap.exe. Nmap is a well-known network scanning tool used to discover hosts and services on a network.

text
Flag: ihack24{nmap.exe}

Happy SPLUNKing #9

The critical command to look for the creation of a new user account is net user so I ran a search:

Splunk returning three events for the net user search

Below is the relevant log extract:

PowerShell transcript showing the account creation command and its success message

The command shows that a new user account called “operator” with the password “operator123” was created successfully.

text
Flag: ihack24{operator:operator123}

To wrap it up, I managed to solve 7 out of 10 challenges in the Happy SPLUNKing challenge. The Digital Forensics and Incident Response challenges were especially enjoyable for me since I’m really into blue team activities.

Thanks for sticking with me through this write-up! This was my first-ever CTF write-up. Thanks again for following along with my journey.