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 systems where you want to run this tool.
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

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 module 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

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   --...

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...

Installing nuclei and go tool in kali

 First you need to install go: https://go.dev/doc/install You need to download this go tool go1.23.4.linux-amd64.tar.gz by clicking the Download button.  Say you are root and download the tool in your Downloads directory. Now run the below command: tar -C /usr/local -xzf go1.23.4.linux-amd64.tar.gz (if this cmd fails then you need to move this tool to /usr/local folder then run this cmd tar -xzf  go1.23.4.linux-amd64.tar.gz) Now add /usr/local/go/bin to the PATH environment variable. You can do this by adding the following line to your $HOME/.profile or /etc/profile (for a system-wide installation): export PATH=$PATH:/usr/local/go/bin Now use the following command for immediate effect. Preventing you from log off then log back in: source $HOME/.profile go version (to check it is installed successfully) Install nuclei: go install -v github.com/projectdiscovery/nuclei/v3/cmd/nuclei@latest or apt install nuclei nuclei -update-templates nuclei -u https://www.domain....