> For the complete documentation index, see [llms.txt](https://duc193.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://duc193.gitbook.io/notes/redteam/active-directory/double-hop.md).

# Double Hop

## 1. Nguyên nhân dẫn tới Double Hop :&#x20;

Khi tạo remote session bằng WinRM sử dụng Kerberos:

1. Client authenticate tới KDC/DC và nhận được TGT.
2. Client dùng TGT để request một TGS cho service WinRM (thường là HTTP/hostname).
3. Khi establish WinRM session với remote host, client chỉ gửi TGS của service WinRM tới remote host, chứ không forward user's TGT.
4. Vì remote host không có user's TGT nên nó không thể:
   * request thêm TGS mới
   * authenticate tới service khác
   * access LDAP/SMB/DC thay mặt user

\=> dẫn tới Kerberos Double Hop.

## 2. Cách check :

### 1. check bằng Klist

trong winrm session :

```bash
klist
```

Kết quả:

```
Cached Tickets: (1)
Server: HTTP/DEV01
```

Chỉ có ticket cho WinRM service.

Không có:

```
krbtgt
ldap/DC01
cifs/DC01
```

### 2. check bằng mimikatz

```bash
.\mimikatz"privilege::debug""sekurlsa::logonpasswords"exit
```

Kết quả:

```
backupadm process tồn tại
```

ví dụ:

```
wsmprovhost.exe
```

nhưng:

```
Password : (null)
```

Tức là: credential thật không nằm trong memory

## 3. Fix :

### 1. PSCredential

Tự đưa credential lại mỗi lần query.

```bash
$SecPassword = ConvertTo-SecureString '!qazXSW@' -AsPlainText -Force
$Cred = New-Object System.Management.Automation.PSCredential(
'INLANEFREIGHT\\backupadm',
$SecPassword
)
Get-DomainUser -SPN -Credential $Cred | select samaccountname
```

### 2. Register-PSSessionConfiguration

```bash
Enter-PSSession -ComputerName DEV01 -Credential INLANEFREIGHT\\backupadm
Register-PSSessionConfiguration `
-Name backupadmsess `
-RunAsCredential INLANEFREIGHT\\backupadm
# Sau buoc nay no se hoi password

Restart-Service WinRM
#connect lai 
Enter-PSSession `
-ComputerName DEV01 `
-Credential INLANEFREIGHT\\backupadm `
-ConfigurationName backupadmsess
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://duc193.gitbook.io/notes/redteam/active-directory/double-hop.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
