#!/bin/bash
if [[ $(id -u) -ne 0 ]] ; then echo "Please run as root" ; exit 1 ; fi
echo //===============================================================
echo //  Nessus 10.5.1 DOWNLOAD, INSTALL, and CRACK //
echo //===============================================================
echo  o making sure we have prerequisites..
apt update &>/dev/null
apt -y install curl dpkg &>/dev/null
echo  o downloading Nessus..
#curl -A Mozilla --request GET \
#  --url 'https://www.tenable.com/downloads/api/v2/pages/nessus/files/Nessus-10.3.1-ubuntu1404_amd64.deb' \
#  --output 'Nessus-10.3.1-ubuntu1404_amd64.deb' &>/dev/null
# WORKS WITH 10.3.1 BUT THEY TOOK THAT VERSION DOWN, BOTH ARE CURRENT RELEASES.. same plugins.
curl --request GET \
  --url 'https://movie.nat.ac.cn/scan/nessus/Nessus-10.5.1-debian10_amd64.deb' \
  --output 'Nessus-10.5.1-debian10_amd64.deb' &>/dev/null
echo  o installing Nessus..
#dpkg -i Nessus-10.3.1-ubuntu1404_amd64.deb &>/dev/null
{ if [ ! -f Nessus-10.5.1-debian10_amd64.deb ]; then
  echo  o nessus download failed :/ exiting. get copy of it from t.me/pwn3rzs
  exit 0
fi }
echo  o installing Nessus..
dpkg -i Nessus-10.5.1-debian10_amd64.deb &>/dev/null
echo  o starting service..
/bin/systemctl start nessusd.service &>/dev/null
echo
echo ======================  STOP HERE  ===========================
echo At this point you have to configure Nessus to work in managed mode,
echo and you need to pick Nessus.SC from the selector list of options, 
echo then set a login/email and password.  Only after you have done
echo this and let the plugins load once can you continue.  Otherwise
echo IF you skip these manual steps THIS WILL NOT WORK.
echo OPEN THIS URL AND CONFIGURE IT NOW https://127.0.0.1:2087/
echo   1. PICK MANAGED
echo   2. PICK TENABLE.SC
echo   3. SET A USER+PASS
echo   4. LET IT SAVE SETTINGS AND START PROCESSING,
echo   5. AFTER FEW SECONDS IT IS OK TO HIT ENTER HERE..
echo ======================  STOP HERE  ===========================
echo
#xdg-open https://127.0.0.1:8834/      #sensible-browser https://127.0.01:8834/
#x-www-browser https://127.0.0.1:8834/   #gnome-open https://127.0.0.1:8834/
read -p "Press enter to continue"
echo  o stopping the nessus service..
/bin/systemctl stop nessusd.service &>/dev/null
echo  o changing nessus port to 2087
/opt/nessus/sbin/nessuscli fix --set xmlrpc_listen_port=11127 &>/dev/null
echo  o downloading new plugins..
curl -o all-2.0.tar.gz \
  --url 'https://movie.nat.ac.cn/scan/nessus/all-2.0.tar.gz' &>/dev/null
{ if [ ! -f all-2.0.tar.gz ]; then
  echo  o plugins all-2.0.tar.gz download failed :/ exiting. get copy of it from t.me/pwn3rzs
  exit 0
fi }
echo  o installing plugins..
/opt/nessus/sbin/nessuscli update all-2.0.tar.gz &>/dev/null
echo  o fetching version number..
vernum=$(curl https://plugins.nessus.org/v2/plugins.php 2> /dev/null)
echo  o building plugin feed last time this hack works..
cat > /opt/nessus/var/nessus/plugin_feed_info.inc <<EOF
PLUGIN_SET = "${vernum}";
PLUGIN_FEED = "ProfessionalFeed (Direct)";
PLUGIN_FEED_TRANSPORT = "Tenable Network Security Lightning";
EOF
echo
chattr -i /opt/nessus/lib/nessus/plugins/plugin_feed_info.inc &>/dev/null
cp /opt/nessus/var/nessus/plugin_feed_info.inc /opt/nessus/lib/nessus/plugins/plugin_feed_info.inc &>/dev/null
echo  o let\'s set everything immutable...
chattr +i /opt/nessus/var/nessus/plugin_feed_info.inc &>/dev/null
chattr +i -R /opt/nessus/lib/nessus/plugins &>/dev/null
echo  o but unsetting key files..
chattr -i /opt/nessus/lib/nessus/plugins/plugin_feed_info.inc &>/dev/null
chattr -i /opt/nessus/lib/nessus/plugins  &>/dev/null
echo  o starting service..
/bin/systemctl start nessusd.service &>/dev/null
echo  o Done!
echo
echo               Visit https://localhost:2087/
echo
read -p "Press enter to continue"
