One Token to Rule Them All: Post-Exploitation Fun in Windows Environments Luke Jennings 12 th March 2009.

Slides:



Advertisements
Similar presentations
Chapter Five Users, Groups, Profiles, and Policies.
Advertisements

By Rashid Khan Lesson 5-Directory Assistance: Administration Using Active Directory Users and Computers.
A Complete Tool For System Penetration Testing Presented By:- Mahesh Kumar Sharma B.Tech IV Year Computer Science Roll No. :- CS09047.
ITP 457 Network Security Network Hacking 101. Hacking Methodology (review) 1. Gather target information 2. Identify services and ports open on the target.
CS 140 Lecture Notes: Processes and ThreadsSlide 1 UNIX Fork/Exec Example int pid = fork(); if (pid == 0) { exec("foo"); } else { waitpid(pid, &status,
6.1 © 2004 Pearson Education, Inc. Exam Planning, Implementing, and Maintaining a Microsoft Windows Server 2003 Active Directory Infrastructure.
70-290: MCSE Guide to Managing a Microsoft Windows Server 2003 Environment Chapter 1: Introduction to Windows Server 2003.
7.1 © 2004 Pearson Education, Inc. Exam Managing and Maintaining a Microsoft® Windows® Server 2003 Environment Lesson 7: Introducing Group Accounts.
A centralized system.  Active Directory is Microsoft's trademarked directory service, an integral part of the Windows architecture. Like other directory.
1 Chapter Overview Creating User and Computer Objects Maintaining User Accounts Creating User Profiles.
11 SYSTEMS ADMINISTRATION AND TERMINAL SERVICES Chapter 12.
Guide to MCSE , Enhanced 1 Activity 10-1: Restarting Windows Server 2003 Objective: to restart Windows Server 2003 Start  Shut Down  Restart Configure.
1 Chapter Overview Monitoring Server Performance Monitoring Shared Resources Microsoft Windows 2000 Auditing.
MS systems use one of the following: LanManager Hash (LM) LanManager Hash (LM) NT LanManager (NTLM) NT LanManager (NTLM) Cached passwords Cached passwords.
70-270: MCSE Guide to Microsoft Windows XP Professional Chapter 5: Users, Groups, Profiles, and Policies.
Module 1: Introduction to Administering Accounts and Resources
9.1 © 2004 Pearson Education, Inc. Exam Planning, Implementing, and Maintaining a Microsoft Windows Server 2003 Active Directory Infrastructure.
Hands-On Microsoft Windows Server 2008 Chapter 1 Introduction to Windows Server 2008.
Working with Workgroups and Domains
Introduction to Application Penetration Testing
Module 9 Configuring Server Security Compliance. Module Overview Securing a Windows Infrastructure Overview of EFS Configuring an Audit Policy Overview.
Chapter 4 Windows NT/2000 Overview. NT Concepts  Domains –A group of one or more NT machines that share an authentication database (SAM) –Single sign-on.
1 Group Account Administration Introduction to Groups Planning a Group Strategy Creating Groups Understanding Default Groups Groups for Administrators.
Hands-On Microsoft Windows Server 2008 Chapter 1 Introduction to Windows Server 2008.
Chapter 14: Remote Server Administration BAI617. Chapter Topics Configure Windows Server 2008 R2 servers for remote administration Remotely connect to.
Enforcing Concurrent Logon Policies with UserLock.
Hands-On Microsoft Windows Server 2008
6.1 © 2004 Pearson Education, Inc. Exam Managing and Maintaining a Microsoft® Windows® Server 2003 Environment Lesson 6: Administering User Accounts.
5.1 © 2004 Pearson Education, Inc. Lesson 5: Administering User Accounts Exam Microsoft® Windows® 2000 Directory Services Infrastructure Goals 
Copyright 2000 eMation SECURITY - Controlling Data Access with
11 MANAGING AND DISTRIBUTING SOFTWARE BY USING GROUP POLICY Chapter 5.
Security Planning and Administrative Delegation Lesson 6.
| nectar.org.au NECTAR TRAINING Module 5 The Research Cloud Lifecycle.
DIT314 ~ Client Operating System & Administration CHAPTER 5 MANAGING USER ACCOUNTS AND GROUPS Prepared By : Suraya Alias.
Managing Groups, Folders, Files and Security Local Domain local Global Universal Objects Folders Permissions Inheritance Access Control List NTFS Permissions.
Chapter 13 Users, Groups Profiles and Policies. Learning Objectives Understand Windows XP Professional user accounts Understand the different types of.
Module 9 Authenticating and Authorizing Users. Module Overview Authenticating Connections to SQL Server Authorizing Logins to Access Databases Authorization.
Active Directory Administration Lesson 5. Skills Matrix Technology SkillObjective DomainObjective # Creating Users, Computers, and Groups Automate creation.
Breno de MedeirosFlorida State University Fall 2005 Windows servers The NT security model.
Module 7 Active Directory and Account Management.
70-270: MCSE Guide to Microsoft Windows XP Professional 1 Windows XP Professional User Accounts Designed for use as a network client for: Windows NT Windows.
MCTS Guide to Microsoft Windows Server 2008 Applications Infrastructure Configuration (Exam # ) Chapter Five Windows Server 2008 Remote Desktop Services,
Working with Workgroups and Domains Lesson 9. Objectives Understand users and groups Create and manage local users and groups Understand the difference.
Working with Users and Groups Lesson 5. Skills Matrix Technology SkillObjective DomainObjective # Introducing User Account Control Configure and troubleshoot.
ITS – Identity Services ONEForest Security Jake DeSantis Keith Brautigam
MEMBERSHIP AND IDENTITY Active server pages (ASP.NET) 1 Chapter-4.
Fall 2002 CS 325 Class Notes Page 1 Lecture 25 Today –exec() in Unix –CreateProcess in Windows Announcements.
Configuring and Troubleshooting Identity and Access Solutions with Windows Server® 2008 Active Directory®
| nectar.org.au NECTAR TRAINING Module 5 The Research Cloud Lifecycle.
CNIT 124: Advanced Ethical Hacking Ch 13: Post Exploitation Part 2.
Chapter 4- Part3. 2 Implementing User Profiles A local user profile is automatically created at the local computer when you log on with an account for.
Notes on Processes, Context, Context Switching The following slides contain partially quoted statements from various Wikipedia pages.
Unit 7 ITT TECHNICAL INSTITUTE NT1330 Client-Server Networking II Date: 2/3/2016 Instructor: Williams Obinkyereh.
1 BCS 4 th Semester. Step 1: Download SQL Server 2005 Express Edition Version Feature SQL Server 2005 Express Edition SP1 SQL Server 2005 Express Edition.
PostExploitation CIS 5930/4930 Offensive Computer Security Spring 2014.
Token Kidnapping's Revenge Cesar Cerrudo Argeniss.
Lesson 6: Configuring Servers for Remote Management
File System Implementation
Module 1: Introduction to Administering Accounts and Resources
Active Directory Administration
CIT 480: Securing Computer Systems
Bomgar Remote support software
Linux Fork/Exec Example
UNIX Fork/Exec Example
UNIX Fork/Exec Example
BACHELOR’S THESIS DEFENSE
BACHELOR’S THESIS DEFENSE
BACHELOR’S THESIS DEFENSE
Linux Fork/Exec Example
Security Planning and Administrative Delegation
Presentation transcript:

One Token to Rule Them All: Post-Exploitation Fun in Windows Environments Luke Jennings 12 th March 2009

2 Introduction The Increasing Importance of Post-Exploitation Microsoft Technology is Pervasive Security has improved significantly since their Trustworthy Computing Initiative Consequently, Post-Exploitation has become increasingly important

3 Introduction The Potential for Token Abuse for Post-Exploitation This has been addressed to some extent. Metasploit is a good example From a penetration tester’s perspective, not much has been done with windows access tokens They are integral to Microsoft's whole concept of single sign-on within an active directory environment Difficult to convince clients of the importance of keeping their administrators' desktops as secure as their servers etc

4 Windows Access Tokens: An Overview Not well understood Processes have a primary token associated which dictates their privileges Threads by default use this but can impersonate other users temporarily through impersonation tokens Tokens have four different security levels (delegation most interesting) : - oAnonymous oIdentification oImpersonation oDelegation Interactive logons result in delegation level tokens being created Non-interactive logons normally result in impersonation level tokens, but can produce delegation tokens if a service is trusted for delegation e.g. EFS file server

5 Token Abuse Tokens may be present on compromised systems that allow privilege escalation of some sort Domain Privilege Escalation oIf domain user tokens are available then other systems may be accessible using these oe.g. compromising a DBA's workstation might allow his token to be used to gain access to sensitive database servers that are secure from direct compromise Local Privilege Escalation oUnder some circumstances, presence of impersonation level tokens may allow local privilege escalation oE.g. compromising an SQL Server instance running as an unprivileged service account. If an administrator connects using windows authentication then their access token can be used to escalate privileges to local Administrator

6 Requirements From a Penetration Tester's Perspective Enumerate available tokens from a compromised system Perform common post-exploitation tasks using specific tokens oExecute processes oForce remote connections in order to capture challenge/response LANMAN/NTLM hashes oAdd a user to a host, a user to a group etc

7 Introducing Incognito An Overview Why the name? oBecause it allows you to assume another’s identity Functionality oList available tokens by unique username or group oCreate processes with a specified token e.g. cmd.exe oSnarf challenge/response hashes of all tokens oAttempt to add a user to a host with all tokens oAttempt to add a user to a group on a host with all tokens oCan be used remotely with communication over named pipes (pwdump style)

8 Introducing Incognito Enumerating Tokens Uses NtQuerySystemInformation() API call to enumerate all handles on the system NTSTATUS WINAPI NtQuerySystemInformation( SYSTEM_INFORMATION_CLASS SystemInformationClass, PVOID SystemInformation, ULONG SystemInformationLength, PULONG ReturnLength ); NtQueryObject() API call is then used to determine which handles are access tokens NTSTATUS NtQueryObject( HANDLE Handle, OBJECT_INFORMATION_CLASS ObjectInformationClass, PVOID ObjectInformation, ULONG ObjectInformationLength, PULONG ReturnLength ); Various other API calls, such as GetTokenInformation() and LookupAccountSid() are then used to discover information about the tokens such as the username and groups associated and security level (impersonation, delegation etc)

9 Introducing Incognito Enumerating Tokens

10 Introducing Incognito Creating Processes Processes can be created using tokens present on the system, which is implemented via the CreateProcessAsUser() API call, which allows a token handle to be specified. BOOL WINAPI CreateProcessAsUser( HANDLE hToken, LPCTSTR lpApplicationName, LPTSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCTSTR lpCurrentDirectory, LPSTARTUPINFO lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation ); This is a useful post-exploitation feature. A common example would be to create a new instance of cmd.exe to gain access to a command shell running under the context of the specified token

11 Introducing Incognito Creating Processes

12 Introducing Incognito Snarfing Hashes With the aid of a sniffer, LANMAN/NTLM challenge response hashes can be snarfed by forcing connections to remote servers with delegation level tokens. This makes use of the WNetAddConnection2() API call and iterates through all available tokens DWORD WNetAddConnection2( LPNETRESOURCE lpNetResource, LPCTSTR lpPassword, LPCTSTR lpUsername, DWORD dwFlags );

13 Introducing Incognito Adding Users to Hosts Incognito can use the Network Management set of API calls to perform some common user and group management operations. The NetUserAdd(), NetGroupAddUser() and NetLocalGroupAddMembers() API calls allow users to be added to hosts, users to be added to global groups on hosts and users to be added to localgroups on hosts, respectively.

14 Incognito Demo

15 Unsuspected 0wnage I'm currently logged off. My account is safe...right? oIt is supposed to be as all tokens should be cleaned up when a session ends (for example, when you log off in the case of an interactive login) oWhilst researching this topic I stumbled upon a case where this isn't true oOn unpatched systems the tokens for interactive logins appear to persist after logoff. oTokens are only reported as impersonation level tokens through the W32 API but if you try to use them it turns out they can access network resources! oTokens do not disappear until reboot Therefore, if you logged into "that ropey old development system" briefly a month ago as a Domain Admin then your entire Windows Domain just got 0wned! :)

16 Unsuspected 0wnage Demo

17 Unsuspected 0wnage – Terminal Services How do you use Terminal Services? oWhen using Terminal Services it is possible to close the window without logging off oDoing this leaves your session logged on oIt allows you to leave programs running and reconnect at a later date oSome people use this functionality oSome people intend to use this functionality and then forget and do not reconnect for a long time oSome people don’t intend to use this functionality and just click close because that it is easier than logging out! oHowever you use it, this can lead to sensitive tokens persisting for much longer periods of time

18 Metasploit Integration I am a big fan of the Metasploit project Whilst writing Incognito it occurred to me that Incognito's functionality would be very useful as a Meterpreter module oIt would allow Incognito's features to be utilised directly through an exploit launched from Metasploit oThe Meterpreter runs as a thread and so implementing the functionality to cause that thread to impersonate another token would automatically allow all of the existing Meterpreter functionality to be used under the context of other tokens oThe automated exploitation functionality offered by Metasploit could be used to perform certain actions automatically on every compromised host across a large network oe.g. Tell Metasploit to try to compromise every windows system on a particular address range, snarf the hashes of all the available tokens and try to add a new domain administrator.

19 Incognito Meterpreter Module Demo

20 Precision Strikes Locating targets that might house interesting tokens When using Incognito’s functionality for domain privilege escalation it is a useful general tool for “squeezing all the juice” out of a compromise However, a penetration test may often be highly targeted e.g. attacking an organisation’s financial SQL Server databases These systems may be very well protected and so safe from direct compromise. However, other systems that house tokens which have access to these systems may be less well protected e.g. the DBA’s desktop It is likely that it would not be feasible to make the effort to compromise as much of a large network as possible in a brute force approach, hoping compromised systems might house these sensitive tokens. It would be nice if it were simple to locate systems that house these tokens before making the effort to compromise them…..a precision strike

21 Locating Tokens Incognito comes with a supplementary tool which offers the ability to enumerate what tokens might be present on a system before compromising it The tool is called find_token and it can sweep a network remotely in order to search for particular tokens This is achieved via the API call NetWkstaUserEnum() which can be used to enumerate the currently logged on users To sweep an entire domain using this API call, it is only necessary to have a standard domain user account. It is not perfect since it lists users that have logged on previously but have since logged off and so can produce false positives. However, this can be very useful for unpatched hosts that do not clean up their tokens on logoff!

22 Find_user Demo

23 Targeted Penetration Testing With Incognito A Basic Methodology 1) Determine targets (e.g. critical database servers) 2) Conduct conventional penetration testing 3) If penetration attempts fail then attempt to enumerate who has access to the system with standard techniques (e.g. members of local administrators group) 4) Locate other systems that might currently house the relevant users' tokens (with find_token’s functionality) 5) Attempt to penetrate these systems 6) If present, use tokens from compromised hosts to compromise main targets

24 Defence Limiting the use of privileged accounts helps reduce exposure (e.g. run as) Use "Account is sensitive and cannot be delegated" option in active directory for highly privileged accounts (doesn't work with interactive sessions) Don't have ropey old boxes lying around! In particular, secure your administrators’ desktops Resources are only as secure as the weakest system that any account that can be used to access them is currently logged into. Therefore, it is important to have strong policies governing security requirements for systems in order for sensitive accounts to be used to access them. Use separate administrative accounts for accessing development/test systems that are likely to be more prone to compromise than their production system counterparts

25 References Whitepaper available from: - “Security Implications of Windows Access Tokens” Incognito on Sourceforge: - Metasploit Framework Development Trunk: -