Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login...

70
RID HIJACKING Maintaining Access on Windows Machines. Security Conference Bogotá, Colombia. 2018 [email protected]

Transcript of Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login...

Page 1: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

RID HIJACKINGMaintaining Access on Windows Machines.

Security Conference

Bogotá, Colombia. 2018

[email protected]

Page 2: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

Agenda

0x01. Exposing the RID Hijacking Attack.

0x02. Windows Logon in a nutshell.

0x03. Hijacking the RID.

0x04. Demo (Metasploit vs Win10).

0x05. Conclusions.

[email protected]

Page 3: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

Agenda

0x01. Exposing the RID Hijacking Attack.

0x02. Windows Logon in a nutshell.

0x03. Hijacking the RID.

0x04. Demo.

0x05. Conclusions.

[email protected]

Page 4: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

Not reliable on Domain Controllers (yet).

• A new persistence technique that affects ALL Windows Systems

since NT. (Haven’t tried this on Windows 95 nor Phone ).

• A stealthy way to maintain access by only using OS resources.

• A method which takes advantage of important security issues

found at the Windows Security Architecture.

What is RID Hijacking?

[email protected]

Page 5: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

What does it do?

This technique hijacks the RID of any existing user

account on the victim host and assigns it to another one.

RID HIJACKING

SID <Guest Account>

==========================================

S-1-5-2196653972-2908857710-5094559845-501

SID <Guest hijacked Administrator>

========================================

S-1-5-2196653972-2908857710-5094559845-500

[email protected]

Page 6: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

What does it do?

0x01. Assigns the privileges of the hijacked account to the hijackerone, even if the hijacked account is disabled.

0x02. Allows to authenticate with the hijacker account credentials(also remotely, depending on machine’s configuration), and obtainauthorized access as the hijacked user.

0x03. Permits to register any operation executed on the event log asthe hijacked user, despite of being logged on as the hijacker one.

[email protected]

Page 7: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

How does it look like?

whoami

net user Guest

writing on System32 folder

[email protected]

Page 8: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

Agenda

0x01. Exposing the RID Hijacking Attack.

0x02. Windows Logon in a nutshell.

0x03. Hijacking the RID.

0x04. Demo.

0x05. Conclusions.

[email protected]

Page 9: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

A Windows Logon Story…

[email protected]

Page 10: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

A Windows Logon Story…

[email protected]

Page 11: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

Windows Security Architecture

Winlogonwinlogon.exe

LSA

Serverlsasrv.dll

SAM

Serversamsrv.dll

HKLM\SAM

AD

Services

ntdsa.dll

MSV1_0.dll

kerberos.dll

AD DB

LSA DBHKLM\SECURITY

KDCKdcsvc.dll

Others

Local Security Authority Subsystem <LSASS>

[email protected]

Page 12: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

Winlogonwinlogon.exe

LSA

Serverlsasrv.dll

SAM

Serversamsrv.dll

HKLM\SAM

MSV1_0.dll

Local Security Authority Subsystem <LSASS>

LSA DBHKLM\SECURITY

Windows Security Architecture

[email protected]

Page 13: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

Quick Logon Overview

WINLOGON

& LSASS

User: Administrator

Pass: iamgreen

OK!

ACCESS TOKENUser: Administrator S-1-5-…-500

Group1: Everyone S-1-1-0

Group2: Administrators S-1-5-32-544

Privileges:

- …

- …

File_X’s DACLREAD: Everyone S-1-1-0

WRITE: Administrators S-1-5-32-544

.....

SRM

[email protected]

Page 14: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

Security Identifiers <SID>

S-1-5-21-397955417-62688126-188441444-1010

Literal

prefix

Identifier

Autority

Sub Autority Indicating

this class of ID

Three Sub Authorities for Uniqueness

Relative

ID

1010

[email protected]

Page 15: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

Authentication

Hi! ADMINhere.

Pass: ilovegreen

[email protected]

Page 16: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

Authentication Steps

0x01. WINLOGON Initialization.

0x02. WINLOGON calls LOGONUI (using CPs).

0x03. WINLOGON creates an unique LOGON SID.

0x04. WINLOGON calls LSASS and prepares a handle for an

Authentication Package.

[email protected]

Page 17: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

Authentication Packages

List: HKLM\SYSTEM\CurrentControlSet\Control\Lsa

For interactive logons:

• <MSV1_0.dll>: Standalone Authentication.

• <Kerberos.dll>: Domain Kerberos Authentication.

Kerberos authentication package will be

ignored by now.

[email protected]

Page 18: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

Authentication Steps

0x05. WINLOGON sends logon info to the MSV1_0 calling

LsaLogonUser.

Logon Info:

Username/Password.

LOGON SID.

MSV1_0 is also used on domain-member

computers when are disconnected of the

network.

[email protected]

Page 19: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

Authentication Steps

0x06. MSV1_0 sends username and hashed password to the

SAMSRV.

0x07. SAMSRV queries on the SAM database with the logon

data, retrieving some security info.

MSV1_0.dll Samsrv.dllHKLM\SAM

[email protected]

Page 20: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

Authentication Steps

0x08. MSV1_0 checks the information obtained from the

SAMSRV response.

0x09. If OK, MSV1_0 generates a LUID for the session.

0x0A. MSV1_0 sends the login information (including LUID)

to LSASS.

All the data sent will be used for the

further access token creation.

Page 21: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

Authorization

HELLO 500.

Creating your

Access token

[email protected]

Page 22: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

Authorization Steps

0x0B. LSASS checks the LSA database for

the user’s allowed access.

0x0C. LSASS adds the Groups, SIDs and

privileges to the access token.

0x0D. LSASS formally creates a primary

access token.

[email protected]

Page 23: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

Authorization

WELCOME ADMINHere’s your Access

token

[email protected]

Page 24: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

ACCESS GRANTED

TOKEN

Authorization

[email protected]

Page 25: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

Agenda

0x01. Exposing the RID Hijacking Attack.

0x02. Windows Logon in a nutshell.

0x03. Hijacking the RID.

0x04. Demo.

0x05. Conclusions.

[email protected]

Page 26: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

Understanding the attack

How is the user identified by the system after being

successfully authenticated?

How does the system associate an username with his SID?

S-1-5-2196653972-2908857710-5094559845-500

Using the Samsrv.dll black magic :)

[email protected]

Page 27: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

Remembering…

0x06. MSV1_0 sents username and hashed password to the

SAMSRV.

0x07. SAMSRV queries on the SAM database with the logon

data, retrieving some security info.

MSV1_0.dll Samsrv.dllHKLM\SAM

[email protected]

Page 28: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

Remembering…

0x06. MSV1_0 sents username and hashed password to the

SAMSRV.

0x07. SAMSRV queries on the SAM database with the logon

data, retrieving some security info.

MSV1_0.dll Samsrv.dllHKLM\SAM

How is the username associated

with the SID?

What security info is retrieved?

[email protected]

Page 29: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

Samsrv.dll and SAM

SAMSRV looks for the

username at the SAM

database.

HKLM\SAM\SAM\Domains\Account\Users\Names

[email protected]

Page 30: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

Samsrv.dll and SAM

SAMSRV looks for the

username at the SAM

database.

Each key contains a

REG_BINARY value.

HKLM\SAM\SAM\Domains\Account\Users\Names

[email protected]

Page 31: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

Samsrv.dll and SAM

SAMSRV looks for the

username at the SAM

database.

Each key contains a

REG_BINARY value.

The REG_BINARY has

as Type the RID of

the account.

HKLM\SAM\SAM\Domains\Account\Users\Names

[email protected]

Page 32: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

Samsrv.dll and MSV1_0.dll

SAMSRV looks for the

key associated with

the RID.

HKLM\SAM\SAM\Domains\Account\Users

[email protected]

Page 33: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

SAMSRV looks for the

key associated with

the RID.

SAMSRV grabs all the

data stored in the

referenced key.

HKLM\SAM\SAM\Domains\Account\Users

Samsrv.dll and MSV1_0.dll

[email protected]

Page 34: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

Samsrv.dll and MSV1_0.dll

SAMSRV looks for the

key associated with

the RID.

SAMSRV grabs all the

data stored in the

referenced key.

MSV1_0.dll receives

back all the data

from SAMSRV.

MSV1_0.dll

Samsrv.dll

[email protected]

Page 35: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

Understanding the attack

Why does the SAM store only the RID?

[email protected]

Page 36: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

Understanding the attack

Why does the SAM store only the RID?

S-1-5-2196653972-2908857710-5094559845-500

Consistent for all local users SIDs Relative

[email protected]

Page 37: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

Understanding the attack

S-1-5-2196653972-2908857710-5094559845-500

Consistent for all local users SIDs Relative

Why does the SAM store only the RID?

What info is retrieved from the SAM?

[email protected]

Page 38: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

Understanding the attack

S-1-5-2196653972-2908857710-5094559845-500

Consistent for all local users SIDs Relative

Why does the SAM store only the RID?

What info is retrieved from the SAM?

Password’s Hash.

Account status (Active: Y/N).

Some account restrictions.

A copy of the user’s RID.

[email protected]

Page 39: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

Login as Guest

Hi! GUESThere.

Pass: sexygirl

[email protected]

Page 40: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

Login as Guest

MSV1_0.dll Samsrv.dll

HKLM\SAM

GuestA85666C6540692E19

E23AEEDAB77E108

[email protected]

Page 41: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

Login as Guest

MSV1_0.dll Samsrv.dll

HKLM\SAM

GuestA85666C6540692E19

E23AEEDAB77E108

Username:

Guest

[email protected]

Page 42: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

Login as Guest

MSV1_0.dll Samsrv.dll

HKLM\SAM

GuestA85666C6540692E19

E23AEEDAB77E108

Username:

Guest

0x1F5

[email protected]

Page 43: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

Login as Guest

MSV1_0.dll Samsrv.dll

HKLM\SAM

GuestA85666C6540692E19

E23AEEDAB77E108

Username:

Guest

0x1F5

HKLM\SAM\SAM\Domains

\Account\Users\0…1F5

[email protected]

Page 44: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

Login as Guest

MSV1_0.dll Samsrv.dll

HKLM\SAM

GuestA85666C6540692E19

E23AEEDAB77E108

Username:

Guest

0x1F5

HKLM\SAM\SAM\Domains

\Account\Users\0…1F5

A85666C6540692E19

E23AEEDAB77E108

Restrictions

RID Copy:

0x1F5

[email protected]

Page 45: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

Login as Guest

MSV1_0.dll Samsrv.dll

HKLM\SAM

GuestA85666C6540692E19

E23AEEDAB77E108

Username:

Guest

0x1F5

HKLM\SAM\SAM\Domains

\Account\Users\0…1F5

A85666C6540692E19

E23AEEDAB77E108

Restrictions

RID Copy:

0x1F5

A85666C6540692E19

E23AEEDAB77E108

Restrictions

RID Copy:

0x1F5

[email protected]

Page 46: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

Login as Guest (Case 1)

GET OUTTA HERE!!!

[email protected]

Page 47: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

Login as Guest (Case 1)

GET OUTTA HERE!!!

GUEST Account <0x1F5> cannot

log on to this machine.

[email protected]

Page 48: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

Login as Guest (Case 2)

WELCOME guestHere’s your Access

token

[email protected]

Page 49: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

Login as Guest (Case 2)

Not

but

could be

better!

[email protected]

Page 50: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

What if…?

What would happen if the RID COPY is

changed to another value?

[email protected]

Page 51: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

What if…?

What would happen if the RID COPY is

changed to another value?

RID(Administrator) = 500

500d = 0x1F4

[email protected]

Page 52: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

MSV1_0.dll

Corrupted

HKLM\SAM

GuestA85666C6540692E19

E23AEEDAB77E108

Login as Guest (the comeback)

Samsrv.dll

[email protected]

Page 53: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

MSV1_0.dll

Corrupted

HKLM\SAM

GuestA85666C6540692E19

E23AEEDAB77E108

Login as Guest (the comeback)

Samsrv.dll

Username:

Guest

Page 54: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

MSV1_0.dll

Corrupted

HKLM\SAM

GuestA85666C6540692E19

E23AEEDAB77E108

Login as Guest (the comeback)

Samsrv.dll

Username:

Guest

0x1F5

[email protected]

Page 55: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

MSV1_0.dll

Corrupted

HKLM\SAM

GuestA85666C6540692E19

E23AEEDAB77E108

Login as Guest (the comeback)

Samsrv.dll

Username:

Guest

0x1F5

HKLM\SAM\SAM\Domains

\Account\Users\0…1F5

[email protected]

Page 56: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

MSV1_0.dll

Corrupted

HKLM\SAM

GuestA85666C6540692E19

E23AEEDAB77E108

Login as Guest (the comeback)

Samsrv.dll

Username:

Guest

0x1F5

HKLM\SAM\SAM\Domains

\Account\Users\0…1F5

A85666C6540692E19

E23AEEDAB77E108

Restrictions

RID Copy:

0x1F4

[email protected]

Page 57: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

MSV1_0.dll

Corrupted

HKLM\SAM

GuestA85666C6540692E19

E23AEEDAB77E108

Login as Guest (the comeback)

Samsrv.dll

Username:

Guest

0x1F5

HKLM\SAM\SAM\Domains

\Account\Users\0…1F5

A85666C6540692E19

E23AEEDAB77E108

Restrictions

RID Copy:

0x1F4

A85666C6540692E19

E23AEEDAB77E108

Restrictions

RID Copy:

0x1F4

Logon Processcontinues…

[email protected]

Page 58: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

MSV1_0.dll

MSV1_0 checks the account

restrictions provided from

SAMSRV.

If allowed, then compares:

SAMSRV response password hash

VS

User entered hashed password

A85666C6540692E19

E23AEEDAB77E108

Restrictions

RID Copy:

0x1F4

Login as Guest (the comeback)

[email protected]

Page 59: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

MSV1_0.dll

MSV1_0 checks the account

restrictions provided from

SAMSRV.

If allowed, then compares:

SAMSRV response password hash

VS

User entered hashed password

A85666C6540692E19

E23AEEDAB77E108

Restrictions

RID Copy:

0x1F4

Login as Guest (the comeback)

Hash will be the

same

[email protected]

Page 60: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

LSASS MSV1_0.dll

Password: OK

RID: 0x1F4

LUID

Login as Guest (the comeback)

[email protected]

Page 61: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

LSASS MSV1_0.dll

Password: OK

RID: 0x1F4

LUID

Login as Guest (the comeback)Token source

Impersonation type

Token ID

Authentication ID

Modified ID

Expiration Time

Session ID

Flags

Logon session (LUID)

Mandatory Policy

Administrators

Default DACL

SID-1-5-………-500Group 1 SID

Group n SID

Restricted SID 1

Restricted SID n

Privilege 1

Privilege n

Creates theAccess Token with RID 500

[email protected]

Page 62: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

LSASS MSV1_0.dll

Password: OK

RID: 0x1F4

LUID

Login as Guest (the comeback)Token source

Impersonation type

Token ID

Authentication ID

Modified ID

Expiration Time

Session ID

Flags

Logon session (LUID)

Mandatory Policy

Administrators

Default DACL

SID-1-5-………-500Group 1 SID

Group n SID

Restricted SID 1

Restricted SID n

Privilege 1

Privilege n

Creates theAccess Token with RID 500

Before After

RID HIJACKING

[email protected]

Page 63: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

Login as Guest

WELCOME guestHere’s your Access

token

[email protected]

Page 64: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

Login as Guest

ACCESS GRANTED

TOKEN

[email protected]

Page 65: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

SECURITY ISSUES

0x01. SAMSRV does not check if the RID associated

with the user is consistent to the RID COPY.

0x02. LSASS does not corroborate the RID with the

username before creating the access token.

0x03. LSASS never looks for RID inconsistencies

during the user’s session.

[email protected]

Page 66: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

Agenda

0x01. Exposing the RID Hijacking Attack.

0x02. Windows Logon in a nutshell.

0x03. Hijacking the RID.

0x04. Demo.

0x05. Conclusions.

[email protected]

Page 67: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

Demonstration

Windows 10

VICTIM

Kali Linux

ATTACKER

192.168.68.3 192.168.68.4

Interactive

PsExec

RDPGuest

Unprivileged

USER

[email protected]

Page 68: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

Agenda

0x01. Exposing the RID Hijacking Attack.

0x02. Windows Logon in a nutshell.

0x03. Hijacking the RID.

0x04. Demo.

0x05. Conclusions.

[email protected]

Page 69: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

Conclusions

[email protected]

Page 70: Presentación de PowerPoint · 2019-02-02 · LSASS MSV1_0.dll Password: OK RID: 0x1F4 LUID Login as Guest (the comeback) Token source Impersonation type Token ID Authentication ID

References

1.http://csl.com.co/rid-hijacking/

2. Russinovich, Mark. Solomon, David A. Ionescu, Alex. “Windows Internals”. 6th Edition.

3. Scambray, Joel. McClure, Stuart. “Hacking Exposed: Windows Security Secrets & Solutions”. 3rd Edition.

4. https://technet.microsoft.com/pt-pt/library/cc780332(v=ws.10).aspx

5. https://docs.microsoft.com/en-us/windows-server/security/windows-authentication/credentials-processes-in-windows-authentication

[email protected]