PowerShell 技能连载 - 获取缓存的凭据
在前一个技能中我们谈到一个名为“PSCredentialManager”的公共模块,可以用来管理缓存的凭据。有些时候,少即是多。当您阅读它的代码时,会发现它是通过一个名为 cmdkey.exe 的控制台命令在和 windows 系统打交道。
要获取您本机缓存的凭据,您只需要这样:
1 | PS> cmdkey /list |
它输出的是纯文本。然而,PowerShell 可以用 ForEach-Object
处理原始数据:
1 | cmdkey.exe /list | ForEach-Object {$found=$false} { |
结果类似这样:
Type User Info Target
---- ---- ---- ------
Domain Extended Credentials tabcabcabc@hicsawr.com Saved for this logon only Mi
Domain Extended Credentials 02jbqxcbqvsb Saved for this logon only Mi
Generic tabcabcabc@hicsawr.com Local machine persistence Le
Generic Local machine persistence Le
Generic Local machine persistence Le
Generic Local machine persistence Le
Generic tabcabcabc@hicsawr.com Local machine persistence Le
Generic Local machine persistence Le
Generic 02jdrxcbqvsb Local machine persistence Wi
Generic Martin Le
Domain Password Martin Do
Domain Password Martin Do
Domain Password User Do
PowerShell 技能连载 - 获取缓存的凭据
http://blog.vichamp.com/2017/09/28/getting-cached-credentials/