Skip to main content

Installing kansa incident response tool

 Kansa is an IR framework.
https://github.com/davehull/Kansa

For enterprise data collection, you need to do this first from the admin system:
Set-NetConnectionProfile -NetworkCategory Private (In private network)
Enable-PSRemoting from powershell on the system where you want to run this tool. This will enable winrm service with port 5985 and 5986.
Check:
netstat -naob | findstr "5985" 
Also allow tcp port 5985 and 5986 for winrm through the network. You can use  GPO. Though winrm is communicating over http and https but authentication will be happened using kerberos in domain environment. 

After downloading it from the github and unzip it, you need to unlock it using powershell. Need powershell v3 or later.
ls -r *.ps1 | Unblock-File

Powershell policy bypass:
Set-ExecutionPolicy AllSigned | RemoteSigned | Unrestricted

From FOR508 course:
.\kansa.ps1 -OutputPath .\Output\ -TargetList .\hostlist -TargetCount 250 -Verbose -Pushbin
-Pushbin is required by those scripts who has dependency of other binary. Kansa will then push that binary to the target systems. -Rmbin to remove that as well.
Those scripts are following:
1. Get-Autorunsc.ps1
2. Get-CertStore.ps1
3. Get-FlsBodyfile.ps1
4. Get-ProcDump.ps1
5. Get-RekalPslist.ps1
If you use the -Pushbin flag then make sure you have copied the above 5 scripts binary (whichever you want) to the .\Modules\bin\ folder.  

Do not do this in production. In production authentication should be kerberos. In lab you can do this to set the auth mode as basic.
winrm set winrm/config/client/auth '@{Basic="true"}'
winrm set winrm/config/service/auth '@{Basic="true"}'
winrm set winrm/config/client  '@{AllowUnencrypted="true"}'
winrm set winrm/config/service '@{AllowUnencrypted="true"}'

Fetch artifacts from single machine:
.\kansa.ps1 -OutputPath .\Output\ -Target localhost or $env:COMPUTERNAME -ModulePath .\Modules\ -Verbose -Authentication basic -Credential (Get-Credential)

You need place the Autorunsc.exe tool in the %SystemRoot% folder to execute the script successfully. Once the tool finishes it task you will see a folder named Output_timestamp
The .\Analysis folder contains some powershell scripts to analyze the collected data. For that you need logparser.exe microsoft tool to be installed. Make sure this tool can be called from any location by kansa. Optionally you can add the binary to path environment variable if it is failed to call the binary from anywhere in the system. 
hostlist file must contain one host per line.

If you do not provide hostlist file then the tool will query to AD to fetch the targets. For that you need remote server administration tool to be installed. 

Download RSAT:
https://www.microsoft.com/en-us/download/details.aspx?id=39296

When using AD, you also need to use -TargetCount parameter to limit the query.

Results are converted into tsv format so that it can easily understandable by timeline explorer.

Running modules separately:

Modules\Net\Get-Netstat.ps1

.\Get-Netstat.ps1 | ConvertTo-CSV -Delimiter "`t" -NoTypeInformation | % { $_ -replace "`"" } | Set-Content netstat.tsv 

Distributed kansa + fire and forget:
Please check For508 Advanced IR and TH book number 1 pdf 109 page. If you have less than 150 systems then normal kansa.ps1 will suffice. But if you have more than that then you may need to think of kansa distributed script. 


Avi

Comments

Popular posts from this blog

Installtion of SQLMutant tool

This tool is perfectly works on ubuntu 24 system. And I found it is not working properly in kali linux 24 version.   https://github.com/blackhatethicalhacking/SQLMutant/tree/main This tool need to use along with sqlmap tool. Showing this cheat sheet for kali or debian based system.  This tool actually analyze everything and give you the vulnerable url where sql injection is possible. You just need to use then sqlmap to exploit that.   Prerequisite: apt install pipx -y (for ubuntu) pip3 install uro or pipx install uro pipx ensurepath pipx completions  (not needed)  source ~/.bashrc   or restart system If go tool is not installed then run the below two commands first ( golang-go ) or follow this link to install go (https://mahimfiroj.blogspot.com/2024/12/installing-nuclei-in-kali.html) otherwise skip this step.   dpkg -l | grep packagename (Using this command you can check package is installed or not) apt install gccgo-go -y or apt install gol...

Install Nessus from docker

Docker installation. Give the below commands one by one. apt install docker-cli or apt install docker.io After the installation is complete, if you are inside wsl then give this command to start docker, because inside wsl systemd (systemctl) does not work: service docker start WSL troubleshooting : If the above command " service docker start " does not work then use below command: dockerd (It may not work if any previous docker process is running. It will show you pid of that process. Use this command to kill that process " kill -9 pid " and run dockerd command again) If " docker ps -a " giving error like " Cannot connect to the Docker daemon at unix:///run/podman/podman.sock. Is the docker daemon running? " This is because you may installed podman-docker package. If you remove the package still you will get this error but you should remove the package. Then issue this command: env | grep -i docker DOCKER_HOST=unix:///run/podman/podman.sock   --...

WSL - windows subsystem for linux

  1. From the start menu, type "Turn Windows features on or off". Check the box, Virtual Machine Platform and Windows Subsystem for Linux or in the command prompt simply give this command: wsl.exe --install --no-distribution Now Restart the system.  If wsl is already installed, then give this command: wsl.exe --update 2. Now from Microsoft store download kali linux and install it. Or you can give this command to see list of distributions. Then install based on your choice.  To see list of distributions: wsl.exe --list --online To install: wsl.exe --install --distribution <Distro Name> i.e.  wsl --install --distribution kali-linux 3. Now it will ask for username and password, say at the time of installing kali-linux here. Provide that.  4. Once it is installed, it has come with very minimum package installation.  Run the following commands to install all packages: sudo apt update sudo apt full-upgrade -y sudo apt install -y kali-linux-default (This re...