Nikto vulnerability scan for domains|Shell script to scan cPanel accounts

Date Posted: 06-05-2017

Nikto is an opensource webserver scanner which helps to perform security scan on the webserver. In this post, we will explain on how to install nikto scan tool and create a script to scan cPanel accounts.

Installation:

Download the nikto script.

cd /usr/local/src

wget https://cirt.net/nikto/nikto-2.1.5.tar.gz

Extract the downloaded file.

tar -xzf nikto-2.1.5.tar.gz

Change the directory nikto directory.

cd nikto-*

You can perform the scan of a single account using the below command.

/bin/perl /usr/local/src/nikto-2.1.5/nikto.pl -host <hostIPaddress> -vhost domain.tld -p 80

Script to take backup of cPanel account:

Copy the script on any location and execute the script.

#!/bin/bash
for vhost in `cat /etc/trueuserdomains|cut -d : -f1`; 
do 	
  echo "+++++++" ; 
  echo $vhost ; 
  echo "+++++++"; 
  digip=`dig +short $vhost`
  check_serverip=$(/scripts/ipusage |grep $digip|awk '{print $1}')
  if [[ $digip == $check_serverip ]];
  then
    echo -e "Creating tmp directory for $vhost "
    mkdir -p /tmp/niktoscan/$vhost
    /bin/perl /usr/local/src/nikto-2.1.5/nikto.pl -host $digip -vhost $vhost -p 80 > /tmp/niktoscan/$vhost/niktoscanreport.txt
  else
    echo "Both Result doesn't match"
  fi
done

The above script will scan the accounts which points to the same server. The results will be stored on /tmp/niktoscan/domain.tld/niktoscanreport.txt. 

For each domain, separate file will be created on /tml/niktoscan. Analyse the result and take necessary action for the vulnerable items.

 

Leave a Reply