From 1e3b254fc94049e7e37a5ebff09b756a94d06217 Mon Sep 17 00:00:00 2001 From: 0xmachos <0xmachos@gmail.com> Date: Fri, 9 Mar 2018 13:23:01 +0000 Subject: [PATCH 01/12] Convert bundle install steps to function --- install | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/install b/install index ca079f93e..da60fda03 100755 --- a/install +++ b/install @@ -119,15 +119,23 @@ else gem install bundler fi -echo "Installing required Ruby gems..." -bundle install --without test development +} + + +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 +} + -echo -echo "==========================================" -echo -info "Install completed successfully!" -info "Run './beef' to launch BeEF" -echo -echo "==========================================" -echo From 2d9ba380486232decfb49ebcf9a97062e440f71c Mon Sep 17 00:00:00 2001 From: 0xmachos <0xmachos@gmail.com> Date: Fri, 9 Mar 2018 13:23:48 +0000 Subject: [PATCH 02/12] Convert bundler detection steps to function --- install | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/install b/install index da60fda03..d532dd807 100755 --- a/install +++ b/install @@ -110,15 +110,19 @@ fi # * rvm: https://rvm.io/rvm/install' #fi -info 'Detecting bundler gem...' -if command_exists bundler -then - info 'bundler gem is installed' -else - info 'Installing bundler gem' - gem install bundler -fi + +check_bundler () { + + info 'Detecting bundler gem...' + + if command_exists bundler + then + info 'bundler gem is installed' + else + info 'Installing bundler gem' + gem install bundler + fi } From 724355e1c36ee2d0e66a8f5f91c7a714576b61fe Mon Sep 17 00:00:00 2001 From: 0xmachos <0xmachos@gmail.com> Date: Fri, 9 Mar 2018 13:28:22 +0000 Subject: [PATCH 03/12] Remove unused code --- install | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/install b/install index d532dd807..b067f032a 100755 --- a/install +++ b/install @@ -96,19 +96,6 @@ 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 From 8ea4e7773a69c2469d3eb63c755d476d2486b2d8 Mon Sep 17 00:00:00 2001 From: 0xmachos <0xmachos@gmail.com> Date: Fri, 9 Mar 2018 13:29:24 +0000 Subject: [PATCH 04/12] Convert Ruby version detection steps to function --- install | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/install b/install index b067f032a..d249c4335 100755 --- a/install +++ b/install @@ -82,21 +82,24 @@ else fatal "Unable to locate installer for your Operating system: $OS" fi -info 'Detecting Ruby environment...' -MIN_RUBY_VER='2.3' -if command_exists ruby -then - 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' ] + +check_ruby_version () { + + info 'Detecting Ruby environment...' + + MIN_RUBY_VER='2.3' + if command_exists ruby 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 -else - fatal "Ruby is not installed. Please install Ruby ${MIN_RUBY_VER} (or newer) and restart the installer." -fi - - +} check_bundler () { From 5b2abf4441beec473b49f20f63cccfaddab8d056 Mon Sep 17 00:00:00 2001 From: 0xmachos <0xmachos@gmail.com> Date: Fri, 9 Mar 2018 13:30:34 +0000 Subject: [PATCH 05/12] Convert OS detection steps to function --- install | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/install b/install index d249c4335..7365c2580 100755 --- a/install +++ b/install @@ -34,6 +34,24 @@ read -p "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 () { info "Detecting Linux OS distribution..." @@ -68,20 +86,6 @@ install_mac () { 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 - check_ruby_version () { From 0d60f3ea602b848a5a0eacfa4633f445fb360237 Mon Sep 17 00:00:00 2001 From: 0xmachos <0xmachos@gmail.com> Date: Fri, 9 Mar 2018 13:38:16 +0000 Subject: [PATCH 06/12] install_linux: wrap variables in curly braces --- install | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/install b/install index 7365c2580..00a392f73 100755 --- a/install +++ b/install @@ -54,30 +54,32 @@ check_os () { install_linux () { + info "Detecting Linux OS distribution..." + Distro='' if [ -f /etc/redhat-release ] ; then Distro='RedHat' elif [ -f /etc/debian_version ] ; then Distro='Debian' elif [ -f /etc/os-release ] ; then - DISTRO_ID=`grep ^ID= /etc/os-release | cut -d= -f2-` - if [ "$DISTRO_ID" = 'kali' ] ; then + DISTRO_ID=$(grep ^ID= /etc/os-release | cut -d= -f2-) + if [ "${DISTRO_ID}" = 'kali' ] ; then Distro='Kali' fi fi - if [ -z $Distro ] ; then - fatal "Unable to locate installer for your $OS distribution" + if [ -z "${Distro}" ] ; then + fatal "Unable to locate installer for your ${OS} distribution" fi readonly Distro - info "OS Distribution: $Distro" - info "Installing $Distro prerequisite packages..." - if [ "$Distro" = "Debian" -o "$Distro" = "Kali" ]; then + info "OS Distribution: ${Distro}" + info "Installing ${Distro} prerequisite packages..." + if [ "${Distro}" = "Debian" ] || [ "${Distro}" = "Kali" ]; then 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 - 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 fi } From 0c26203ff79b6ac19077f97370247e9896641739 Mon Sep 17 00:00:00 2001 From: 0xmachos <0xmachos@gmail.com> Date: Fri, 9 Mar 2018 13:39:12 +0000 Subject: [PATCH 07/12] Convert get user permission steps to function --- install | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/install b/install index 00a392f73..bd7cbe598 100755 --- a/install +++ b/install @@ -22,6 +22,16 @@ echo command_exists () { command -v "$1" /dev/null 2&>1 + + +get_permission () { + + warn 'This script will install BeEF and its required dependencies (including operating system packages).' + + read -rp "Are you sure you wish to continue (Y/n)? " + if [ "$(echo "${REPLY}" | tr "[:upper:]" "[:lower:]")" = "n" ] ; then + fatal 'Installation aborted' + fi } info() { echo "[INFO] $*"; } @@ -29,11 +39,6 @@ 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).' -read -p "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..." From 86e18aabc16717add07d5b5639c1ed08011af618 Mon Sep 17 00:00:00 2001 From: 0xmachos <0xmachos@gmail.com> Date: Fri, 9 Mar 2018 13:39:43 +0000 Subject: [PATCH 08/12] command_exists: wrap variable in curly braces --- install | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/install b/install index bd7cbe598..210060335 100755 --- a/install +++ b/install @@ -21,7 +21,9 @@ echo "#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#" echo command_exists () { - command -v "$1" /dev/null 2&>1 + + command -v "${1}" /dev/null 2&>1 +} get_permission () { From 7e00ac21891baaec99a9ff189011e7794867deda Mon Sep 17 00:00:00 2001 From: 0xmachos <0xmachos@gmail.com> Date: Fri, 9 Mar 2018 13:41:42 +0000 Subject: [PATCH 09/12] Move preamble ascii art to main --- install | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/install b/install index 210060335..932744a6b 100755 --- a/install +++ b/install @@ -8,17 +8,8 @@ set -euo pipefail IFS=$'\n\t' -clear -if [ -f core/main/console/beef.ascii ] ; then - cat core/main/console/beef.ascii - echo -fi -echo "#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#" -echo " -- [ BeEF Installer ] -- " -echo "#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#" -echo command_exists () { @@ -145,4 +136,19 @@ install_beef () { } +main () { + clear + + if [ -f core/main/console/beef.ascii ] ; then + cat core/main/console/beef.ascii + echo + fi + + echo "#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#" + echo " -- [ BeEF Installer ] -- " + echo "#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#" + echo +} + +main "$@" From 38c17bacfddd8069f4dbb10109ecf43257454332 Mon Sep 17 00:00:00 2001 From: 0xmachos <0xmachos@gmail.com> Date: Fri, 9 Mar 2018 13:42:30 +0000 Subject: [PATCH 10/12] Add colour to info, warn and fatal functions --- install | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/install b/install index 932744a6b..ec1498697 100755 --- a/install +++ b/install @@ -9,6 +9,9 @@ set -euo pipefail IFS=$'\n\t' +info() { echo -e "\\033[1;36m[INFO]\\033[0m $*"; } +warn() { echo -e "\\033[1;33m[WARNING]\\033[0m $*"; } +fatal() { echo -e "\\033[1;31m[FATAL]\\033[0m $*"; exit 1 ; } command_exists () { @@ -27,10 +30,6 @@ get_permission () { fi } -info() { echo "[INFO] $*"; } -warn() { echo "[WARN] $*"; } -error() { echo "[ERROR] $*"; } -fatal() { echo "[FATAL] $*"; exit 1 ; } check_os () { From bd0ac9eafd6d64d070e9e9fae23424083a06ec8f Mon Sep 17 00:00:00 2001 From: 0xmachos <0xmachos@gmail.com> Date: Fri, 9 Mar 2018 13:43:13 +0000 Subject: [PATCH 11/12] main: add function calls --- install | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/install b/install index ec1498697..64c848eca 100755 --- a/install +++ b/install @@ -148,6 +148,12 @@ main () { echo " -- [ BeEF Installer ] -- " echo "#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#" echo + + get_permission + check_os + check_ruby_version + check_bundler + install_beef } main "$@" From 13d24bfbed0725162db722d45d8ebac57660498a Mon Sep 17 00:00:00 2001 From: 0xmachos <0xmachos@gmail.com> Date: Fri, 9 Mar 2018 13:43:49 +0000 Subject: [PATCH 12/12] Add line between functions --- install | 1 + 1 file changed, 1 insertion(+) diff --git a/install b/install index 64c848eca..3a0ce58ec 100755 --- a/install +++ b/install @@ -81,6 +81,7 @@ install_linux () { fi } + install_mac () { echo }