event filtering and searching with xpath and powershell

29
Ing. Ondřej Ševeček MCSM:Directory | MVP:Enterprise Security | Certified Ethical Hacker | MCSE:SharePoint [email protected] | www.sevecek.com Event Filtering and Searching with XPath and PowerShell SCOM ACS bohužel nebude, zato bude víc ostatního

Upload: muniya

Post on 23-Feb-2016

30 views

Category:

Documents


1 download

DESCRIPTION

Event Filtering and Searching with XPath and PowerShell. SCOM ACS bohu žel nebude, zato bude víc ostatního. Ing. Ond řej Ševeček MCSM:Directory | MVP:Enterprise Security | Certified Ethical Hacker | MCSE:SharePoint [email protected] | www.sevecek.com. Auditing (2000+). - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Event Filtering and Searching with  XPath  and PowerShell

Ing. Ondřej ŠevečekMCSM:Directory | MVP:Enterprise Security |Certified Ethical Hacker | MCSE:[email protected] | www.sevecek.com

Event Filtering and Searching with XPath and PowerShellSCOM ACS bohužel nebude, zato bude víc ostatního

Page 2: Event Filtering and Searching with  XPath  and PowerShell

Auditing (2000+)

Page 3: Event Filtering and Searching with  XPath  and PowerShell

Granular auditing (2008/Vista+)

Page 4: Event Filtering and Searching with  XPath  and PowerShell

Event viewer

Page 5: Event Filtering and Searching with  XPath  and PowerShell

Event viewer

Page 6: Event Filtering and Searching with  XPath  and PowerShell

Event viewer

Page 7: Event Filtering and Searching with  XPath  and PowerShell

Event viewer and XML

Page 8: Event Filtering and Searching with  XPath  and PowerShell

XPath

XML "searching" language Quick examples

//State[@code='CZ']//State[population>20]/States/State[starts-with(display, 'C') and @continent='NAM']//State[position()=3]/States/*[starts-with(display, 'C')]//display[starts-with(., 'C')]//display[starts-with(text(), 'C')]

Page 9: Event Filtering and Searching with  XPath  and PowerShell

XPath

Event viewermust replace < with &lt; or > with &gt;must replace <= with &lt;=can use only position(), Band() and timediff()today: TimeCreated[timediff(@SystemTime) &lt;= 86400000]]

WEVTUTILnormal operators >, >=, <=, != …

Page 10: Event Filtering and Searching with  XPath  and PowerShell

Logon auditing

Account Logon Event– "authentication event"– when an account database validates credentials

Logon Event– "session event"– every time an Access Token is created or closed

Page 11: Event Filtering and Searching with  XPath  and PowerShell

NTLM and Schannel network logon

DC2000+

Client2000+

Server2000+

App Traffic

DC2000+

SMBD/COM

In-bandNTLM hash

Pass-through NTLM hash

D/COM Dynamic TCP

Page 12: Event Filtering and Searching with  XPath  and PowerShell

Kerberos network logon (basic principle)

DC2000+

Client2000+

Kerberos

Server2000+

App Traffic

TGT: User

In-bandTGS: Server

TGS: Server

Page 13: Event Filtering and Searching with  XPath  and PowerShell

Auditing (Interactive Logon)

SQLFS

WFE

DC

Client

Account Logon1

Logon2

Page 14: Event Filtering and Searching with  XPath  and PowerShell

Logon types

Type Value

Interactive 2

Network 3

Batch 4

Service 5

Unlock 7

NetworkCleartext 8

NewCredentials 9

RemoteInteractive 10

CachedInteractive 11

CachedRemoteInteractive 12

CachedUnlock 13

Page 15: Event Filtering and Searching with  XPath  and PowerShell

Status codes

Status Value

STATUS_WRONG_PASSWORD 0xC000006A

STATUS_PASSWORD_RESTRICTION 0xC000006C

STATUS_LOGON_FAILURE 0xC000006D

STATUS_ACCOUNT_RESTRICTION 0xC000006E

STATUS_INVALID_LOGON_HOURS 0xC000006F

STATUS_INVALID_WORKSTATION 0xC0000070

STATUS_PASSWORD_EXPIRED 0xC0000071

STATUS_ACCOUNT_DISABLED 0xC0000072

STATUS_LOGON_NOT_GRANTED 0xC0000155

STATUS_LOGON_TYPE_NOT_GRANTED 0xC000015B

STATUS_ACCOUNT_EXPIRED 0xC0000193

STATUS_PASSWORD_MUST_CHANGE 0xC0000224

STATUS_ACCOUNT_LOCKED_OUT 0xC0000234

Page 16: Event Filtering and Searching with  XPath  and PowerShell

Download err.exe

version 2008– http://www.microsoft.com/en-us/download/details.aspx?id=985

most up-to-date version– SDK for Windows 8.1– http://msdn.microsoft.com/en-us/windows/desktop/bg162891.aspx

Page 17: Event Filtering and Searching with  XPath  and PowerShell

Auditing (Network session)

SQLFS

WFE

DC

Client

Account Logon1

Logon2

Page 18: Event Filtering and Searching with  XPath  and PowerShell

immediately at logoff

Auditing (Interactive logoff)

SQLFS

WFE

DC

Client

Logoff1

Page 19: Event Filtering and Searching with  XPath  and PowerShell

SQLFS

WFE

when TCP connection closed

Auditing (Network session)

DC

Client

Logoff1

Page 20: Event Filtering and Searching with  XPath  and PowerShell

PowerShell notes

Get-WmiObject-Computer-Query

EventCode, InsertionStrings

Page 21: Event Filtering and Searching with  XPath  and PowerShell

Timestamps in LDAP

pwdLastSet lastLogon

– non-replicated lastLogonTimestamp lockoutTime badPasswordTime

– non-replicated accountExpires

Page 22: Event Filtering and Searching with  XPath  and PowerShell

Logon timestamps

Client

DC

DC

DC

lastLogon 11:38

lastLogon 9:00

lastLogon -

Page 23: Event Filtering and Searching with  XPath  and PowerShell

Logon timestamps (2003 DFL)

Client

DC

DC

DC

lastLogon 11:38

lastLogon 9:00

lastLogon -

lastLogonTimestamp 11:00

lastLogonTimestamp 11:00

lastLogonTimestamp 11:00

Page 24: Event Filtering and Searching with  XPath  and PowerShell

lastLogonTimestamp

Requires 2003 domain functional level Updated only once per 14-random(5) days

– DC=idtt,DC=local– msDS-LogonTimeSyncInterval– 1+ – minimum without randomization– 5+ – randomization starts– 14 – the default– ...

Page 25: Event Filtering and Searching with  XPath  and PowerShell

Authentication failures

Client

PDC

pwd2

DC

pwd2

pwd2

DC

pwd1

Page 26: Event Filtering and Searching with  XPath  and PowerShell

Authentication failures

ClientDC

DC

badPasswordCount 3

badPasswordCount 2

PDC

badPasswordCount 7

lockoutTime

DC

badPasswordCount 2

Page 27: Event Filtering and Searching with  XPath  and PowerShell

Searching in LDAP

(name=m*) (&(name=m*)(c=cz)) (|(c=cz)(c=de)) (!c=cz) (whenCreated>=20080323205258.0+1200) (whenCreated>=20080323205258.0Z) (pwdLastSet>=128962296000000000) (userAccountControl:1.2.840.113556.1.4.803:=2)

Page 28: Event Filtering and Searching with  XPath  and PowerShell

Powershell and DateTime

get-date [DateTime]::Parse("2011-05-28") (get-date).AddDays(-50) ((get-date) –

[DateTime]::Parse("1601-01-01")).Ticks ([DateTime]::Parse("2010-11-28") –

[DateTime]::Parse("1601-01-01")).Ticks ((get-date).AddDays(-50) – [DateTime]::Parse("1601-01-

01")).Ticks

Page 29: Event Filtering and Searching with  XPath  and PowerShell

Kurzy Počítačové školy Gopas na www.gopas.cz

GOC170 - AD Monitoring with SCOM and ACSGOC171 - Active Directory TroubleshootingGOC172 - Kerberos TroubleshootingGOC173 - Enterprise PKIGOC174 - SharePoint Architecture and TroubleshootingGOC175 - Advanced SecurityGOC169 - Auditing ISO/IEC 2700x

Získejte tričko TechEd 2014za vyplněný hodnotící dotazník.

Počítačová škola Gopas – Vaše IT škola života