Process Investigation
First up, let's look at some process-related commands. These are your bread and butter for quick investigation:Get-Process | Where-Object {$_.CPU -gt 50} | Select-Object ProcessName, CPU, WorkingSet | Sort-Object CPU -DescendingGet-NetTCPConnection -State Established | 
    Select-Object LocalAddress,LocalPort,RemoteAddress,RemotePort,State,
    @{Name="Process";Expression={(Get-Process -Id $_.OwningProcess).ProcessName}} |
    Where-Object {$_.RemoteAddress -notmatch "^10\.|^172\.|^192\.168\."}This shows all established connections to addresses outside your private network. Hello, C2 detection!
For more information on process investigation, please refer to our PowerShell Quick Guide: Process Investigation.
Suspicious File Hunt
Looking for files created in the last hour? I've got you covered:Get-ChildItem -Path C:\ -Recurse -ErrorAction SilentlyContinue | 
    Where-Object {$_.CreationTime -gt (Get-Date).AddHours(-1)} | 
    Select-Object FullName, CreationTime, LengthGet-ChildItem -Path $env:TEMP -Include *.exe,*.dll,*.ps1 -Recurse -ErrorAction SilentlyContinue | 
    Select-Object FullName, CreationTime, LengthService Shenanigans
Want to find services running with suspicious paths?Get-WmiObject win32_service | 
    Where-Object {$_.PathName -like "*temp*" -or $_.PathName -like "*appdata*"} | 
    Select-Object Name, PathName, StartNameGet-Service | Where-Object {$_.StartType -eq "Automatic" -and $_.Status -eq "Stopped"} | 
    Select-Object Name, DisplayName, Status, StartTypeRegistry Recon
Check for programs set to autostart (a favorite hiding spot for malware):Get-ItemProperty -Path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Run' |
    Select-Object * -Exclude PSPath,PSParentPath,PSChildName,PSProviderPro Tips
1. Always use `-ErrorAction SilentlyContinue` when searching through files or registry. Trust me, your console will thank you for not flooding it with access denied errors. 2. Need to export results? Just pipe to `Export-Csv`:... | Export-Csv -Path "C:\investigation\findings.csv" -NoTypeInformation
 
 
0 comments:
Post a Comment