#!/bin/bash
version=2.0
John_="Yes"
Hashcat_="Yes"
set -e
function print_centered {
     [[ $# == 0 ]] && return 1

     declare -i TERM_COLS="$(tput cols)"
     declare -i str_len="${#1}"
     [[ $str_len -ge $TERM_COLS ]] && {
          echo "$1";
          return 0;
     }

     declare -i filler_len="$(( (TERM_COLS - str_len) / 2 ))"
     [[ $# -ge 2 ]] && ch="${2:0:1}" || ch=" "
     filler=""
     for (( i = 0; i < filler_len; i++ )); do
          filler="${filler}${ch}"
     done

     printf "%s%s%s" "$filler" "$1" "$filler"
     [[ $(( (TERM_COLS - str_len) % 2 )) -ne 0 ]] && printf "%s" "${ch}"
     printf "\n"

     return 0
}
if [ $John_ = "Yes" ]
then
print_centered "$(tput setaf 9)"
print_centered ".________ ._______  .___.__  .______ "
print_centered ":____.   \: .___  \ :   |  \ :      \ "
print_centered " __|  :/ || :   |  ||   :   ||       |"
print_centered "|     :  ||     :  ||   .   ||   |   |"
print_centered " \__. __/  \_. ___/ |___|   ||___|   |"
print_centered "    :/       :/         |___|    |___|"
print_centered "    :        :                        "
fi
if [ $John_ = "Yes" ] && [ $Hashcat_ = "Yes" ]
then
echo -n -e "$(tput sgr0)"
print_centered "&"
fi
if [ $Hashcat_ = "Yes" ]
then
print_centered "$(tput setaf 11)"
print_centered ".___.__  .______  .________.___.__  ._______ .______  _____._"
print_centered ":   |  \ :      \ |    ___/:   |  \ :_.  ___\:      \ \__ _:|"
print_centered "|   :   ||   .   ||___    \|   :   ||  : |/\ |   .   |  |  :|"
print_centered "|   .   ||   :   ||       /|   .   ||    /  \|   :   |  |   |"
print_centered "|___|   ||___|   ||__:___/ |___|   ||. _____/|___|   |  |   |"
print_centered "    |___|    |___|   :         |___| :/          |___|  |___|"
print_centered "                                     :                       "
fi
echo -n -e "$(tput sgr0)"
if [ -f /tmp/tmp_txt ];then rm /tmp/tmp_txt ; fi
if [ $John_ = "Yes" ]; then echo -n "John the Ripper " > /tmp/tmp_txt;fi
if [ $John_ = "Yes" ] && [ $Hashcat_ = "Yes" ]; then echo -n "& " >>/tmp/tmp_txt;fi
if [ $Hashcat_ = "Yes" ]; then echo -n "HaschCat " >> /tmp/tmp_txt;fi

echo -n "installer Version $version" >>/tmp/tmp_txt
value=`cat /tmp/tmp_txt`
print_centered "$value"

if [ $John_ = "Yes" ]
then
echo "John The Ripper install:"
sudo apt-get install libbz2-dev libpcap-dev -y
sudo apt-get -y install ocl-icd-opencl-dev opencl-headers pocl-opencl-icd
cd /home/wareck/
if [ ! -d password ];then mkdir password ;fi
cd /home/wareck/password/
if [ -d john ]; then rm -r -f john ;fi
git clone https://github.com/openwall/john.git
cd /home/wareck/password/john/src
./configure
make -j 6
echo ""
fi

if [ $Hashcat_ = "Yes" ]
then
echo "Hashcat install:"
sudo apt-get install libbz2-dev libpcap-dev -y
sudo apt-get -y install ocl-icd-opencl-dev opencl-headers pocl-opencl-icd
cd /home/wareck/
if [ ! -d password ];then mkdir password ;fi
cd /home/wareck/password
if [ ! -d hashcat ]
then
git clone https://github.com/hashcat/hashcat.git
cd hashcat
else
cd hashcat
git pull
fi
make -j 6
fi

echo ""
echo "Done."