Contenidos
Todas las comprobaciones las haremos desde PowerShell.
Archivos recientemente abiertos
1 |
Get-ChildItem ([Environment]::GetFolderPath("Recent")) |
Dispositivos conectados al USB recientemente
El siguiente código muestra la información de los dispositivos conectados al USB en bruto, es decir que aparece mucha información.
1 2 3 4 |
Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USBSTOR\*\*\' Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB\*\*\' Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\USB\*\*\' Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\USBSTOR\*\*\' |
Modificar el código para obtener información que nos puede ayudar.
1 2 3 4 |
Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USBSTOR\*\*\' | Select-Object FriendlyName, DeviceDesc, Mfg | Format-Table Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB\*\*\' | Select-Object FriendlyName, DeviceDesc, Mfg | Format-Table Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\USB\*\*\' | Select-Object FriendlyName, DeviceDesc, Mfg | Format-Table Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\USBSTOR\*\*\' | Select-Object FriendlyName, DeviceDesc, Mfg | Format-Table |
Listar los ficheros de configuración de los dispositivos conectados al USB (mediante una función).
1 2 3 4 5 6 7 8 9 10 11 12 |
function procesar ($info) { foreach($linea in $info.DeviceDesc) { $linea.split(",")[0] } } procesar (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USBSTOR\*\*\' | Select-Object DeviceDesc) procesar (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB\*\*\' | Select-Object DeviceDesc) procesar (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\USB\*\*\' | Select-Object DeviceDesc) procesar (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\USBSTOR\*\*\' | Select-Object DeviceDesc) |
Ver la fecha de creación de los ficheros de configuración de los dispositivos conectados al USB (mediante una función).
1 2 3 4 5 6 7 8 9 10 11 12 |
function procesar ($info) { foreach($linea in $info.DeviceDesc) { Get-ChildItem ("C:\Windows\INF\"+$linea.split(",")[0].replace("@","")) | select name, CreationTime, LastWriteTime } } procesar (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USBSTOR\*\*\' | Select-Object DeviceDesc) procesar (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB\*\*\' | Select-Object DeviceDesc) procesar (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\USB\*\*\' | Select-Object DeviceDesc) procesar (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\USBSTOR\*\*\' | Select-Object DeviceDesc) |
Usuarios que han iniciado sesión o han realizado alguna acción
1 2 3 4 5 6 7 8 9 10 11 12 13 |
# 4624: An account was successfully logged on $iniciossesion = Get-EventLog -LogName Security -InstanceId 4624 | ForEach-Object { # Convertir el contenido del log en un objeto [PSCustomObject]@{ Time = $_.TimeGenerated Usuario = "{0}\{1}" -f $_.ReplacementStrings[5], $_.ReplacementStrings[6] Type = $_.ReplacementStrings[10] Path = $_.ReplacementStrings[17] } } $iniciossesion | Sort-Object Time -Descending |