HTB Sherlock Logjammer
HTB Sherlock Logjammer
HTB Sherlock Logjammer
Challenge Info
Name Logjammer
Play on HackTheBox
Difficulty Easy
Category DFIR
Creator
Background
Scenario
Questions
To solve this challenge, I’ll need to answer the following 12 questions:
1. When did user cyberjunkie successfully log into his computer? (UTC)
2. The user tampered with firewall settings on the system. Analyze the
firewall event logs to find out the Name of the firewall rule added?
3. What’s the direction of the firewall rule?
4. The user changed audit policy of the computer. What’s the
Subcategory of this changed policy?
5. The user “cyberjunkie” created a scheduled task. What’s the name
of this task?
6. What’s the full path of the file which was scheduled for the task?
7. What are the arguments of the command?
8. The antivirus running on the system identified a threat and
performed actions on it. Which tool was identified as malware by
antivirus?
9. What’s the full path of the malware which raised the alert?
10. What action was taken by the antivirus?
11. The user used Powershell to execute commands. What command
was executed by the user?
12. We suspect the user deleted some event logs. Which Event log file
was cleared?
Artifact Background
I’m given five different event logs:
Tools
These Windows Event Log files are a binary format that I’ll need to
either convert to something useful to work with, or log into the
Windows Event Log Viewer. I much prefer working from the Linux
command line, so I’ll use EvtxECmd.exe (a Zimmerman tool) to convert
the logs from this binary format to JSON. Then I can work with jq ,
along with grep and other Bash utilities.
Data
The given data has the five log files:
Results
Login (Task 1)
When did the cyberjunkie user first successfully log into his computer?
(UTC)
Successful logon events (or “An account was successfully logged on”)
are event id 4624. I’ll look at the first log and see that the event id is
stored in a field named EventId :
The records are stored as JSON lines. That means that each line has a
even starting with { and ending with } . To read just one of these, I’m
using -s with jq , which slurps these into a list of events, and then I
can select the first one with .[0] .
This filters down to 67 logs (using -c to output one log per line so that
wc -l will count logs).
The user logging in is a part of the Payload field. I’ll filter more to get
logs where CyberJunkie is in that field with the test function, which
applies a regex and returns True or False:
Awesome, it’s down to four logs. There are two different timestamps if I
drop the fractional seconds:
The user tampered with firewall settings on the system. Analyze the
firewall event logs to find out the Name of the firewall rule added?
I’ll grep the log lines for “firewall” (case insensitive) and look at the first
log:
oxdf@hacky$ cat 20240511121627_EvtxECmd_Output.json | grep -i
{
"PayloadData1": ": @{Windows.CBSPreview_10.0.19041.1023_neu
"PayloadData2": "",
"PayloadData3": "Direction: Outbound",
"PayloadData4": "Action: Block",
"PayloadData5": "Protocol: All",
"RemoteHost": "*: ",
"MapDescription": "A rule has been added to the Windows Def
"ChunkNumber": 0,
"Computer": "DESKTOP-887GK2L",
"Payload": "{\"EventData\":{\"Data\":[{\"@Name\":\"RuleId\"
"UserId": "S-1-5-19",
"Channel": "Microsoft-Windows-Windows Firewall With Advance
"Provider": "Microsoft-Windows-Windows Firewall With Advanc
"EventId": 2004,
"EventRecordId": "192",
"ProcessId": 2836,
"ThreadId": 4100,
"Level": "Info",
"Keywords": "0x8000020000000000",
"SourceFile": ".\\Event-Logs\\Windows Firewall-Firewall.evt
"ExtraDataOffset": 0,
"HiddenRecord": false,
"TimeCreated": "2023-02-01T00:59:07.7193859+00:00",
"RecordNumber": 1
}
The SourceFile attribute seems like a good one to filter on. I’ll just use
grep:
Find Addition
Given that the user logged on and added a rule, I’m looking for a 2004
after 2023-03-27T14:37:09. I can filter both of those with jq :
There’s only three logs left. A quick inspection of the format of the logs
shows the data to pull:
The event log for System audit policy was changed is event id 4719.
There’s only one of these:
oxdf@hacky$ cat 20240511121627_EvtxECmd_Output.json | jq -c
1
oxdf@hacky$ cat 20240511121627_EvtxECmd_Output.json | jq 'sel
{
"PayloadData1": "CategoryId: %%8274 SubcategoryId: %%12804"
"PayloadData2": "SubcategoryGuid: 0cce9227-69ae-11d9-bed3-5
"PayloadData3": "AuditPolicyChanges: %%8449",
"UserName": "WORKGROUP\\DESKTOP-887GK2L$",
"MapDescription": "System audit policy was changed",
"ChunkNumber": 0,
"Computer": "DESKTOP-887GK2L",
"Payload": "{\"EventData\":{\"Data\":[{\"@Name\":\"SubjectU
"Channel": "Security",
"Provider": "Microsoft-Windows-Security-Auditing",
"EventId": 4719,
"EventRecordId": "13102",
"ProcessId": 780,
"ThreadId": 1488,
"Level": "LogAlways",
"Keywords": "Audit success",
"SourceFile": ".\\Event-Logs\\Security.evtx",
"ExtraDataOffset": 0,
"HiddenRecord": false,
"TimeCreated": "2023-03-27T14:50:03.7218352+00:00",
"RecordNumber": 83
}
I originally tried just Other Object Access, but the placeholder showed I
needed one more word.
What’s the full path of the file which was scheduled for the task?
What are the arguments of the command?
The event code for A scheduled task was created is 4698. There’s only
one of these in the dataset:
I can go further and get the XML for the scheduled task to include the
script that’s run from Payload which then needs to be converted from
JSON, pull out the TakContent , then get the #text , HTML decode,
remove , , and lint with XML:
Filter By Time
There’s a lot of different log types there, so before I figure out what
each of these are, I’m going to assume I’m still looking at events that
happen after that first login. That reduces the logs to look at from 444
to 11:
This page documents all the event id values for Defender logs:
1116 - MALWAREPROTECTION_STATE_MALWARE_DETECTED
1117 - MALWAREPROTECTION_STATE_MALWARE_ACTION_TAKEN
5007 - MALWAREPROTECTION_CONFIG_CHANGED
1116
Starting with the 1116 logs, I’ll pull the interesting parts out of each:
It’s two detections for the same binary, which is SharpHound (Task 8),
detected as a Zip file at
C:\Users\CyberJunkie\Downloads\SharpHound-v1.1.0.zip (Task 9).
1117
Event Id 1117 is very similar to 1116, but this one has the action in the
.Payload . To get to it, I’ll need to select it and then convert that
fromjson , and process it more in a rather annoying way. The cheat is
to just grep :
The action taken was quarantine (Task 10). A pretty jq way to do it is:
oxdf@hacky$ cat 20240511121627_EvtxECmd_Output.json | grep "W
"Quarantine"
"Quarantine"
Powershell Overview
4103 / 4104
The 4103 logs the start of a PowerShell session, where 4104 logs the
commands run. 4103 shows the start of sessions:
The middle one is the interesting one (Task 11). I’ll get the full log for
the interesting one:
We suspect the user deleted some event logs. Which Event log file was
cleared?
One common log for security event log being cleared is 1102. There is
one of those here:
It’s before the first login, and thus I think not of interest (at least it’s not
the accepted answer).
If I add the filter for after the first login, there’s only one:
Timeline
Putting all that together makes the following timeline:
2023-03-
27T14:37:09
CyberJunkie first login Security 4624
2023-03-
27T14:38:32
CyberJunkie second login Security 4624
2023-03-
27T14:42:34
SharpHound zip detected Defender 1116
2023-03-
27T14:42:48
SharpHound quarantined Defender 1117
2023-03-
27T14:51:21
Scheduled task created Security 4698
2023-03- PowerShell
Runs Automation-HTB.ps1
27T14:58:33 4104
2023-03-
27T15:01:56
Firewall event logs cleared System 104
Question Answers
1. When did the cyberjunkie user first successfully log into his
computer? (UTC)
27/03/2023 14:37:09
2. The user tampered with firewall settings on the system. Analyze the
firewall event logs to find out the Name of the firewall rule added?
Metasploit C2 Bypass
Outbound
4. The user changed audit policy of the computer. What’s the
Subcategory of this changed policy?
HTB-AUTOMATION
6. What’s the full path of the file which was scheduled for the task?
C:\Users\CyberJunkie\Desktop\Automation-HTB.ps1
-A cyberjunkie@hackthebox.eu
SharpHound
9. What’s the full path of the malware which raised the alert?
C:\Users\CyberJunkie\Downloads\SharpHound-v1.1.0.zip
Quarantine
12. We suspect the user deleted some event logs. Which Event log file
was cleared?
0xdf
@0xdf@infosec.exchange
Buy me a coffee