Thursday, May 2, 2024

How to use XPath Windows Event Log

Windows Event logs under the format EVTX are actually recorded with XML. You can use XPATH to query XML. I deally, you would never need to do this, as you can export Windows Event Logs to a SIEM. However, you may need to query the Event Log Directly, and the bui;t in search is pretty terrible. If you get used to the XPATH Sytanx, you can make it a lot easier to query the Windows Event Log. 

First, Open the Windows Event Log. In our examples, we will be querying the Security Event Log. In the Right panel, press "Filter Current Log..."



Click the XML Tab at the top right, then select at the bottom "Edit Query Manually"




Specific Account logging on:

For whatever reason, The "User" field in the Filter does not actually work post Windows 2003, which is very frustrating. we can actually search for users via XPATH. In this example I am looking for a specific Windows Event IDs 4648 and 4624. 




<QueryList>

  <Query Id="0" Path="Security">

    <Select Path="Security">*[System[(EventID=4648 or EventID=4624)] and EventData[Data[@Name="TargetUserName"]="accountname"]]</Select>

  </Query>

</QueryList>


Checking a user login to a specific process:


In this example, we have multiple Sites in IIS that AD users can authenticate to. We want to look at just one of those web apps, as to not have to sift through all the sign ins. The ProcessName field can be filtered down to the name of any process, in this case, IIS. 


<QueryList>

  <Query Id="0" Path="Security">

    <Select Path="Security">*[System[(EventID=4648)] and EventData[Data[@Name="TargetUserName"]="bob"] and EventData[Data[@Name="ProcessName"]="C:\inetpub\sites\ecommerce\ecommerceweb\Bank.Web.exe"]]</Select>

  </Query>

</QueryList>




Query for NTLM v1

As part of auditing, you may be looking to eliminate NTLMv1 usage. This can be quieried with XPATH like such:

<QueryList>

  <Query Id="0" Path="Security">

    <Select Path="Security">*[System[(EventID=4624)] and EventData[Data[@Name="LmPackageName"]="NTLM V1"]]</Select>

  </Query>

</QueryList>






Sunday, May 10, 2020

Finding the Homepage in the Windows Registry: Cal Poly FAST CTF Challenge 21

Question: What is the exact URL of the start page for Internet Explorer?
Points: 100
Download File from: https://github.com/mfput/CTF-Questions/raw/master/NTUSER.DAT
Hint: no hint
Answer: http://www.virustotal.com/
Note: NTUSER.DAT\Software\Windows\Internet Explorer\Main

Find Chrome Version from Windows Registry: Cal Poly FAST CTF Challenge 20


Question: What is the exact version of Google Chrome installed?
Points: 100
Download File from: https://github.com/mfput/CTF-Questions/raw/master/NTUSER.DAT
Hint: no hint
Answer: 49.0.2623.112
Note: NTUSER.DAT\Software\Google\Chrome\BLBeacon

User Assist Forensics 2: Cal Poly FAST CTF Challenge 19

Question: When was the last date ProcMon.exe was run? FORMAT: YYYY-MM-DD
Points: 200
Download File from: https://github.com/mfput/CTF-Questions/raw/master/NTUSER.DAT
Hint: None
Answer: 2017-04-18
Note: NTUSER.DAT\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssit\GUID\Count

User Assist Forensics: Cal Poly FAST CTF Challenge 18

Question: How many times was minesweeper run? FORMAT: ##
Points: 200
Download File from: https://github.com/mfput/CTF-Questions/raw/master/NTUSER.DAT
Hint: None
Answer: 06
Note: NTUSER.DAT\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssit\GUID\Count

Run Dialog Forensics: Cal Poly CTF Challenge 17

Question: What is the 2nd command ran in the Windows run dialog box?
Points: 150
Download File from: https://github.com/mfput/CTF-Questions/raw/master/NTUSER.DAT
Hint: abc denotes the order.
Answer: syskey
Note: NTUSER.DAT\Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU

NTUSER.DAT Forensics 1: Finding the Most Recent Document

Question: What is the target name of the least recent most recent document opened in explorer?
Points: 150
Download File from: https://github.com/mfput/CTF-Questions/raw/master/NTUSER.DAT
Hint: none
Answer: POS2009.txt
Note: NTUSER.DAT\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs

This is the first in a series of forensics questions based around the NTUSER.DAT file, which is the registry hive for the user profile. This questions is intentionally worded in a confusing way, as we are looking for the oldest document in the "Recent Documents".

First, we'll use