Extrahieren von Anmeldeinformationen aus Windows-Protokollen

Teilen:

Übersicht

During a recent engagement, I observed a lot of members of a particular organization authenticating with remote systems and services over the commandline with username and password in plaintext. This ranged from domain administrators using the net user command to create user accounts and updated passwords to database administrators managing their instances with commandline tools.

The security operations team had configured the active directory connected systems to record 4688 logs and ship those off to a centralized server. This resulted in a consolidated repository of all applications executed in the environment along with the commandline arguments. This is great for threat detection; however, it can also be leveraged by adversaries to find plaintext credentials.

Examples

Here are a few examples of credentials being passed to applications in plaintext. Some applications take in positional arguments such as net.exe. Programs that take in positional arguments will require prior knowledge of their use and formatting since we’ll have to essentially parse out the right token.

Other applications such as wmic.exe use named parameters (e.g. /password) to provide credentials. These are more generalizable, so we can build a regular expression to extract passwords provided through named parameters so long as the application adheres to a common naming scheme (e.g. -p, /p, /password, –password).

So, what does scraping event logs for credentials buy us?

You already have to have admin access to the network to read events from the Security Event Log, but it can get you a few things:

  • It could yield domain admin credentials for privilege escalation, but you’d have to be pretty lucky to land on a domain admin box
  • It gives you plaintext credentials to add to your password list for cracking
  • Most importantly, it can capture credentials for other services such as databases or non-active directory connected systems

Tools Utilized

Creating a Script to Scrape Credentials from Event Logs

Step 1: Define the Parameter Block

The first step of building a script to scrape credentials is to define the parameter block. This will create a nice UI for the operator to use in the SpecterInsight interactive session. We want to be able to provide options for scraping localhost and remote systems and for authenticating with impersonation or explicit credentials. We satisfy these requirements with three parameters across two parameter sets:

Parameter Set 1: Impersonation

  • ComputerName: The system to scrape events logs for credentials. The default is “localhost.”

Parameter Set 2: Username and Password

  • ComputerName: The system to scrape events logs for credentials. The default is “localhost.”
  • Username: The fully qualified username to authenticate with (e.g. [email protected]).
  • Password: The password associated with the specified user.

Step 2: Load Dependencies

We are going to leverage a few high-performance cmdlets from the SpecterInsight EventLog post-exploitation module. Specifically, the Get-Events cmdlet runs about 100 times faster than the Get-WinEvent cmdlet that is bundled with PowerShell.

The “load” command instructs the implant to download and import the EventLog.dll module from the C2 server.

#Load dependencies
load EventLog;

Step 3: Define Regular Expressions for Extracting Credentials

The first thing we are going to need is a regex for detecting passwords from commandline arguments. This expression is going to get a little messy, so I’m going to try and break it down into chunks. First, let’s take a look at what we’re trying to match against. That is, what are some examples of passwords as commandline args?

pracsec

Kommentar verfassen

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

lade-bild
London, GB
11:54 am, Feb. 1, 2025
Wetter-Symbol 5°C
L: 5° | H: 6°
overcast clouds
Luftfeuchtigkeit: 87 %
Druck: 1029 mb
Wind: 7 mph ESE
Windböe: 0 mph
UV-Index: 0
Niederschlag: 0 mm
Wolken: 100%
Regen Chance: 0%
Sichtbarkeit: 10 km
Sonnenaufgang: 7:38 am
Sonnenuntergang: 4:49 pm
TäglichStündlich
Tägliche VorhersageStündliche Vorhersage
Today 9:00 pm
Wetter-Symbol
5° | 6°°C 0 mm 0% 7 mph 87 % 1029 mb 0 mm/h
Tomorrow 9:00 pm
Wetter-Symbol
2° | 8°°C 0 mm 0% 7 mph 85 % 1025 mb 0 mm/h
Mo. Feb. 03 9:00 pm
Wetter-Symbol
4° | 9°°C 0 mm 0% 9 mph 93 % 1026 mb 0 mm/h
Di. Feb. 04 9:00 pm
Wetter-Symbol
6° | 9°°C 1 mm 100% 14 mph 94 % 1026 mb 0 mm/h
Mi. Feb. 05 9:00 pm
Wetter-Symbol
4° | 8°°C 0.8 mm 80% 9 mph 91 % 1046 mb 0 mm/h
Today 12:00 pm
Wetter-Symbol
5° | 6°°C 0 mm 0% 7 mph 87 % 1029 mb 0 mm/h
Today 3:00 pm
Wetter-Symbol
6° | 6°°C 0 mm 0% 6 mph 82 % 1029 mb 0 mm/h
Today 6:00 pm
Wetter-Symbol
5° | 5°°C 0 mm 0% 6 mph 79 % 1028 mb 0 mm/h
Today 9:00 pm
Wetter-Symbol
3° | 3°°C 0 mm 0% 5 mph 85 % 1026 mb 0 mm/h
Tomorrow 12:00 am
Wetter-Symbol
3° | 3°°C 0 mm 0% 4 mph 85 % 1024 mb 0 mm/h
Tomorrow 3:00 am
Wetter-Symbol
2° | 2°°C 0 mm 0% 5 mph 84 % 1022 mb 0 mm/h
Tomorrow 6:00 am
Wetter-Symbol
2° | 2°°C 0 mm 0% 5 mph 81 % 1021 mb 0 mm/h
Tomorrow 9:00 am
Wetter-Symbol
3° | 3°°C 0 mm 0% 5 mph 77 % 1022 mb 0 mm/h
Name Preis24H (%)
Bitcoin(BTC)
€98,307.17
-2.60%
Ethereum(ETH)
€3,129.08
-2.48%
XRP(XRP)
€2.88
-3.56%
Fesseln(USDT)
€0.96
-0.03%
Solana(SOL)
€219.40
-4.51%
USDC(USDC)
€0.97
0.00%
Dogecoin(DOGE)
€0.313012
-1.95%
Shiba Inu(SHIB)
€0.000018
-0.98%
Pepe(PEPE)
€0.000013
-1.29%
Nach oben scrollen