forked from beefproject/beef
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
executable file
·225 lines (174 loc) · 5.5 KB
/
install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
#!/bin/bash
#
# Copyright (c) 2006-2018 Wade Alcorn - [email protected]
# Browser Exploitation Framework (BeEF) - http://beefproject.com
# See the file 'doc/COPYING' for copying permission
#
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 ; }
RUBYSUFFIX=''
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
}
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
elif [ "${OS}" = "FreeBSD" ]; then
info "Launching FreeBSD install..."
for SUFX in 26 25 24 23
do
if command_exists ruby${SUFX}
then
RUBYSUFFIX=${SUFX}
break
fi
done
install_freebsd
elif [ "${OS}" = "OpenBSD" ]; then
info "Launching OpenBSD install..."
for SUFX in 26 25 24 23
do
if command_exists ruby${SUFX}
then
RUBYSUFFIX=${SUFX}
break
fi
done
install_openbsd
else
fatal "Unable to locate installer for your Operating system: $OS"
fi
}
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-)
DISTRO_ID=$(cat /etc/os-release | grep ID= | cut -d= -f2-)
if [ "${DISTRO_ID}" = 'kali' ] ; then
Distro='Kali'
elif [ "${DISTRO_ID}" = 'arch' ] ; then
Distro='Arch'
fi
fi
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" ] || [ "${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 nodejs
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 sqlite-devel nodejs
elif [ "${Distro}" = "Arch" ]; then
sudo pacman -Syu # Updates repo, dependencies, etc.
sudo pacman -S curl git make openssl gcc readline zlib libyaml sqlite bzip2 autoconf automake libtool bison nodejs ruby ruby-rdoc # Installs dependencies
fi
}
install_openbsd () {
sudo pkg_add curl git libyaml libxml libxslt bison node ruby${RUBYSUFFIX}-bundler lame espeak
}
install_freebsd () {
sudo pkg install curl git libyaml libxslt devel/ruby-gems bison node espeak
}
install_mac () {
local mac_deps=(curl git nodejs python3 \
openssl readline libyaml sqlite3 libxml2 \
autoconf ncurses automake libtool \
bison wget)
if ! command_exists brew; then
fatal "Homebrew (https://brew.sh/) required to install dependencies"
fi
info "Installing dependencies via brew"
brew update
for package in "${mac_deps[@]}"; do
if brew install "${package}"; then
info "${package} installed"
else
fatal "Failed to install ${package}"
fi
done
}
check_ruby_version () {
info 'Detecting Ruby environment...'
MIN_RUBY_VER='2.3'
if command_exists ruby${RUBYSUFFIX}
then
RUBY_VERSION=$(ruby${RUBYSUFFIX} -e "puts RUBY_VERSION")
info "Ruby version ${RUBY_VERSION} is installed"
if [ "$(ruby${RUBYSUFFIX} -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
}
check_bundler () {
info 'Detecting bundler gem...'
if command_exists bundler${RUBYSUFFIX}
then
info "bundler${RUBYSUFFIX} gem is installed"
else
info 'Installing bundler gem'
gem${RUBYSUFFIX} install bundler
fi
}
install_beef () {
echo "Installing required Ruby gems..."
if command_exists bundler${RUBYSUFFIX}
then
bundle${RUBYSUFFIX} install --without test development
else
bundle install --without test development
fi
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 "$@"