Aerosol Posted March 26, 2015 Report Posted March 26, 2015 A modular incident response framework in Powershell. Note there's a bug that's currently cropping up in PowerShell version 2 systems, but version 3 and later should be fine.More info:trustedsignal -- blog: KansaPowerShell Magazine » Kansa: A PowerShell-based incident response frameworkWhat does it do?It uses Powershell Remoting to run user contributed, ahem, user contri-buted modules across hosts in an enterprise to collect data for useduring incident response, breach hunts, or for building an environmentalbaseline.How do you use it?Here's a very simple command line example you can run on your own localhost.After downloading the project and unzipping it, you'll likely needto "unblock" the ps1 files. The easiest way to do this if you're usingPowershell v3 or later is to cd to the directory where Kansa residesand do:ls -r *.ps1 | Unblock-FileIf you're not running PS v3 or later, Sysinternal's Streams utility canbe used to remove the alternate data streams that Powershell uses todetermine if files came from the Internet. Once you've removed thoseADSes, you'll be able to run the scripts without issue.I've not run into any issues running the downloaded scripts via WindowsRemote Management / Powershell Remoting through Kansa, so you shouldn'thave to do anything if you want to run the scripts via remoting.Open an elevated Powershell Prompt (Right-click Run As Administrator)At the command prompt, enter:.\kansa.ps1 -Target localhost -ModulePath .\Modules -Verbose The script should start collecting data or you may see an error aboutnot having Windows Remote Management enabled. If so, do a littlesearching online, it's easy to turn on. Turn it on and try again. Whenit finishes running, you'll have a new Output_timestamp subdirectory,with subdirectories for data collected by each module. You can cd intothose subdirectories and checkout the data. There are some analysisscripts in the Analysis directory, but many of those won't make senseon a collection of data from a single host. Kansa was written forcollection and analysis of data from dozens, hundreds, thousands, tensof thousands of systems.Running Modules StandaloneKansa modules can be run as standalone utilities outside of the Kansaframework. Why might you want to do this? Consider netstat -naob, theoutput of the command line utility is ugly and doesn't easily lenditself to analysis. RunningModules\Net\Get-Netstat.ps1as a standalone script will call netstat -naob, but it will returnPowershell objects in an easy to read, easy to analyze format. You caneasily convert its output to CSV, TSV or XML using normal Powershellcmdlets. Here's an example:.\Get-Netstat.ps1 | ConvertTo-CSV -Delimiter "`t" -NoTypeInformation | % { $_ -replace "`"" } | Set-Content netstat.tsvthe result of the above will be a file called netstat.tsv containingunquoted, tab separate values for netstat -naob's ouput.Caveats:Powershell relies on the Windows API. Your adversary may use subterfuge.*Collectors can be written to bypass the Windows API as well.Get-RekallPslist.ps1 for example.Link: https://github.com/davehull/Kansa Quote