Merge pull request #1518 from 0xmachos/master
Refactor install for #1477
This commit is contained in:
189
install
189
install
@@ -8,127 +8,154 @@
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
IFS=$'\n\t'
|
IFS=$'\n\t'
|
||||||
|
|
||||||
clear
|
|
||||||
|
|
||||||
if [ -f core/main/console/beef.ascii ] ; then
|
info() { echo -e "\\033[1;36m[INFO]\\033[0m $*"; }
|
||||||
cat core/main/console/beef.ascii
|
warn() { echo -e "\\033[1;33m[WARNING]\\033[0m $*"; }
|
||||||
echo
|
fatal() { echo -e "\\033[1;31m[FATAL]\\033[0m $*"; exit 1 ; }
|
||||||
fi
|
|
||||||
|
|
||||||
echo "#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#"
|
|
||||||
echo " -- [ BeEF Installer ] -- "
|
|
||||||
echo "#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#"
|
|
||||||
echo
|
|
||||||
|
|
||||||
command_exists () {
|
command_exists () {
|
||||||
|
|
||||||
command -v "$1" /dev/null 2&>/dev/null
|
command -v "$1" /dev/null 2&>/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
info() { echo "[INFO] $*"; }
|
|
||||||
warn() { echo "[WARN] $*"; }
|
|
||||||
error() { echo "[ERROR] $*"; }
|
|
||||||
fatal() { echo "[FATAL] $*"; exit 1 ; }
|
|
||||||
|
|
||||||
warn 'This script will install BeEF and its required dependencies (including operating system packages).'
|
get_permission () {
|
||||||
read -p "Are you sure you wish to continue (Y/n)? "
|
|
||||||
if [ "`echo ${REPLY} | tr [:upper:] [:lower:]`" = "n" ] ; then
|
warn 'This script will install BeEF and its required dependencies (including operating system packages).'
|
||||||
fatal 'Installation aborted'
|
|
||||||
fi
|
read -rp "Are you sure you wish to continue (Y/n)? "
|
||||||
|
if [ "$(echo "${REPLY}" | tr "[:upper:]" "[:lower:]")" = "n" ] ; then
|
||||||
|
fatal 'Installation aborted'
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
check_os () {
|
||||||
|
|
||||||
|
info "Detecting OS..."
|
||||||
|
|
||||||
|
OS=$(uname)
|
||||||
|
readonly OS
|
||||||
|
info "Operating System: $OS"
|
||||||
|
if [ "${OS}" = "Linux" ] ; then
|
||||||
|
info "Launching Linux install..."
|
||||||
|
install_linux
|
||||||
|
elif [ "${OS}" = "Darwin" ]; then
|
||||||
|
info "Launching Mac OSX install..."
|
||||||
|
install_mac
|
||||||
|
else
|
||||||
|
fatal "Unable to locate installer for your Operating system: $OS"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
install_linux () {
|
install_linux () {
|
||||||
|
|
||||||
info "Detecting Linux OS distribution..."
|
info "Detecting Linux OS distribution..."
|
||||||
|
|
||||||
Distro=''
|
Distro=''
|
||||||
if [ -f /etc/redhat-release ] ; then
|
if [ -f /etc/redhat-release ] ; then
|
||||||
Distro='RedHat'
|
Distro='RedHat'
|
||||||
elif [ -f /etc/debian_version ] ; then
|
elif [ -f /etc/debian_version ] ; then
|
||||||
Distro='Debian'
|
Distro='Debian'
|
||||||
elif [ -f /etc/os-release ] ; then
|
elif [ -f /etc/os-release ] ; then
|
||||||
DISTRO_ID=`grep ^ID= /etc/os-release | cut -d= -f2-`
|
DISTRO_ID=$(grep ^ID= /etc/os-release | cut -d= -f2-)
|
||||||
if [ "$DISTRO_ID" = 'kali' ] ; then
|
if [ "${DISTRO_ID}" = 'kali' ] ; then
|
||||||
Distro='Kali'
|
Distro='Kali'
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z $Distro ] ; then
|
if [ -z "${Distro}" ] ; then
|
||||||
fatal "Unable to locate installer for your $OS distribution"
|
fatal "Unable to locate installer for your ${OS} distribution"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
readonly Distro
|
readonly Distro
|
||||||
info "OS Distribution: $Distro"
|
info "OS Distribution: ${Distro}"
|
||||||
info "Installing $Distro prerequisite packages..."
|
info "Installing ${Distro} prerequisite packages..."
|
||||||
if [ "$Distro" = "Debian" -o "$Distro" = "Kali" ]; then
|
if [ "${Distro}" = "Debian" ] || [ "${Distro}" = "Kali" ]; then
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install curl git build-essential openssl libreadline6-dev zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev autoconf libc6-dev libncurses5-dev automake libtool bison subversion nodejs
|
sudo apt-get install curl git build-essential openssl libreadline6-dev zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev autoconf libc6-dev libncurses5-dev automake libtool bison subversion nodejs
|
||||||
elif [ "$Distro" = "RedHat" ]; then
|
elif [ "${Distro}" = "RedHat" ]; then
|
||||||
sudo yum install -y git make gcc openssl-devel gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel bzip2 autoconf automake libtool bison iconv-devel sqlite-devel nodejs
|
sudo yum install -y git make gcc openssl-devel gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel bzip2 autoconf automake libtool bison iconv-devel sqlite-devel nodejs
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
install_mac () {
|
install_mac () {
|
||||||
# brew install ...
|
# brew install ...
|
||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
info "Detecting OS..."
|
|
||||||
OS=`uname`
|
|
||||||
readonly OS
|
|
||||||
info "Operating System: $OS"
|
|
||||||
if [ "${OS}" = "Linux" ] ; then
|
|
||||||
info "Launching Linux install..."
|
|
||||||
install_linux
|
|
||||||
elif [ "$OS" = "Darwin" ]; then
|
|
||||||
info "Launching Mac OSX install..."
|
|
||||||
install_mac
|
|
||||||
else
|
|
||||||
fatal "Unable to locate installer for your Operating system: $OS"
|
|
||||||
fi
|
|
||||||
|
|
||||||
info 'Detecting Ruby environment...'
|
check_ruby_version () {
|
||||||
MIN_RUBY_VER='2.3'
|
|
||||||
if command_exists ruby
|
info 'Detecting Ruby environment...'
|
||||||
then
|
|
||||||
RUBY_VERSION=`ruby -e "puts RUBY_VERSION"`
|
MIN_RUBY_VER='2.3'
|
||||||
info "Ruby version ${RUBY_VERSION} is installed"
|
if command_exists ruby
|
||||||
if [ `ruby -e "puts RUBY_VERSION.to_f >= ${MIN_RUBY_VER}"` = 'false' ]
|
|
||||||
then
|
then
|
||||||
fatal "Ruby version ${RUBY_VERSION} is not supported. Please install Ruby ${MIN_RUBY_VER} (or newer) and restart the installer."
|
RUBY_VERSION=$(ruby -e "puts RUBY_VERSION")
|
||||||
|
info "Ruby version ${RUBY_VERSION} is installed"
|
||||||
|
if [ "$(ruby -e "puts RUBY_VERSION.to_f >= ${MIN_RUBY_VER}")" = 'false' ]
|
||||||
|
then
|
||||||
|
fatal "Ruby version ${RUBY_VERSION} is not supported. Please install Ruby ${MIN_RUBY_VER} (or newer) and restart the installer."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
fatal "Ruby is not installed. Please install Ruby ${MIN_RUBY_VER} (or newer) and restart the installer."
|
||||||
fi
|
fi
|
||||||
else
|
}
|
||||||
fatal "Ruby is not installed. Please install Ruby ${MIN_RUBY_VER} (or newer) and restart the installer."
|
|
||||||
fi
|
|
||||||
|
|
||||||
#if command_exists rbenv
|
|
||||||
#then
|
|
||||||
# info 'rbenv is installed'
|
|
||||||
#elif command_exists rvm
|
|
||||||
#then
|
|
||||||
# info 'rvm is installed'
|
|
||||||
#else
|
|
||||||
# fatal 'Could not find Ruby environment manager!
|
|
||||||
#Please install either RVM or rbenv and restart the installer
|
|
||||||
#For more information:
|
|
||||||
# * rbenv: https://github.com/rbenv/rbenv
|
|
||||||
# * rvm: https://rvm.io/rvm/install'
|
|
||||||
#fi
|
|
||||||
|
|
||||||
info 'Detecting bundler gem...'
|
check_bundler () {
|
||||||
if command_exists bundler
|
|
||||||
then
|
|
||||||
info 'bundler gem is installed'
|
|
||||||
else
|
|
||||||
info 'Installing bundler gem'
|
|
||||||
gem install bundler
|
|
||||||
fi
|
|
||||||
|
|
||||||
info "Installing required Ruby gems..."
|
info 'Detecting bundler gem...'
|
||||||
bundle install --without test development
|
|
||||||
|
if command_exists bundler
|
||||||
|
then
|
||||||
|
info 'bundler gem is installed'
|
||||||
|
else
|
||||||
|
info 'Installing bundler gem'
|
||||||
|
gem install bundler
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
echo
|
|
||||||
echo "=========================================="
|
|
||||||
echo
|
|
||||||
echo " Install completed successfully!"
|
|
||||||
echo " Run './beef' to launch BeEF"
|
|
||||||
echo
|
|
||||||
echo "=========================================="
|
|
||||||
echo
|
|
||||||
|
|
||||||
|
install_beef () {
|
||||||
|
|
||||||
|
echo "Installing required Ruby gems..."
|
||||||
|
bundle install --without test development
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "=========================================="
|
||||||
|
echo
|
||||||
|
info "Install completed successfully!"
|
||||||
|
info "Run './beef' to launch BeEF"
|
||||||
|
echo
|
||||||
|
echo "=========================================="
|
||||||
|
echo
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
main () {
|
||||||
|
|
||||||
|
clear
|
||||||
|
|
||||||
|
if [ -f core/main/console/beef.ascii ] ; then
|
||||||
|
cat core/main/console/beef.ascii
|
||||||
|
echo
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#"
|
||||||
|
echo " -- [ BeEF Installer ] -- "
|
||||||
|
echo "#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#"
|
||||||
|
echo
|
||||||
|
|
||||||
|
get_permission
|
||||||
|
check_os
|
||||||
|
check_ruby_version
|
||||||
|
check_bundler
|
||||||
|
install_beef
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
||||||
|
|||||||
Reference in New Issue
Block a user