-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_metasploit.sh
117 lines (107 loc) · 4.06 KB
/
install_metasploit.sh
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
#!/usr/bin/env bash
function banner()
{
cat logo.txt 2> /dev/null
echo -e "\033[1;37mCreated by \033[32mAhmed Al-Nassif\033[37m with \033[31m<3\033[0m"
echo -e "\033[1;37mGitHub: \033[4;32mhttps://github.com/Ahmed-AlNassif\033[0m"
echo -e "\033[1;34mFacebook\033[37m: \033[4;32mhttps://fb.me/Ahm3d.Nassif\033[0m"
}
function update()
{
echo -e "\033[1;34m[*] \033[37mUpdate and upgrade the packages...\[033[0m"
apt update
apt list --upgradable
echo -n -e "\033[1;33m[?]\033[37m Do you want to upgrade? [Y|N]: \033[32m"
read answer
echo -n -e "\033[0m"
if [[ "${answer^^}" == "Y" || "${answer^^}" == "YES" ]]; then
apt full-upgrade
fi
}
function packages()
{
echo -e "\033[1;34m[*] \033[37mInstalling the requirements.\033[0m"
pkgs="binutils python autoconf bison clang coreutils curl findutils apr apr-util postgresql openssl readline libffi libgmp libpcap libsqlite libgrpc libtool libxml2 libxslt ncurses make ncurses-utils ncurses git wget unzip zip tar termux-tools termux-elf-cleaner pkg-config git ruby"
for pkg in pkgs
do
echo -e "\033[1;31m\$ \033[34mapt \033[35minstall \033[32m $pkg\033[0m"
echo -n -e "\033[1;37m"
apt install "$pkg" -y
echo -n -e "\033[0m"
done
}
function fetch_msf()
{
echo -e "\033[1;34m[*] \033[37mFetching Metasploit-Framework...\033[033[0m"
url="https://github.com/rapid7/metasploit-framework/archive/refs/heads/master.zip"
file_name="msf.zip"
echo -n -e "\033[1;32m"
curl -L -o "$file_name" "$url"
echo -n -e "\033[0m"
if [[ $? != 0 ]]; then
echo -e "\033[1;33m[!] \033[37mDownloading the file failed. Do you want to retry Downloading it? [Y|N]:\033[32m "
read answer echo -n -e "\033[0m"
if [[ "${answer^^}" == "Y" || "${answer^^}" == "YES" ]];then
fetch_msf
else
exit 1
fi
fi
unzip "$file_name" &> /dev/null
if [[ $? != 0 ]]; then
echo -e "\033[1;33m[!] \033[37mThe file is corrupt. Do you want to retry Downloading it? [Y|N]:\033[32m "
read answer echo -n -e "\033[0m"
if [[ "${answer^^}" == "Y" || "${answer^^}" == "YES" ]];then
rm -f "$file_name"
fetch_msf
else
exit 1
fi
fi
}
function uninstall_ruby()
{
echo -e "\033[1;34m[*] \033[37mUninstalling Ruby..\033[0m"
echo -n -e "\033[1;33m[?]\033[37m Do you want to uninstall Ruby? [Y|N]: \033[32m"
read answer
echo -n -e "\033[0m"
if [[ "${answer^^}" == "Y" || "${answer^^}" == "YES" ]]; then
apt autoremove ruby -y
rm -rf ${PREFIX}/lib/ruby
fi
}
function install_msf()
{
path="${PREFIX}/opt/metasploit-framework"
unziped_file="metasploit-framework-master"
if [[ -d "$path" ]];then
echo -n -e "\033[1;33m[?]\033[37m MSF installed in $path. Do you want to remove it? [Y|N]: \033[32m"
read answer
echo -n -e "\033[0m"
if [[ "${answer^^}" == "Y" || "${answer^^}" == "YES" ]]; then
rm -rf "$path"
mv "$unziped_file" "$path"
fi
else
mv "$unziped_file" "$path"
fi
gem install bundler
cd "$path"
bundle config set documentation false
NOKOGIRI_VERSION=$(cat Gemfile.lock | grep -i nokogiri | sed 's/nokogiri [\(\)]/(/g' | cut -d ' ' -f 5 | grep -oP "(.).[[:digit:]][\w+]?[.].")
gem install nokogiri -v $NOKOGIRI_VERSION -- --with-cflags="-Wno-implicit-function-declaration -Wno-deprecated-declarations -Wno-incompatible-function-pointer-types" --use-system-libraries
bundle install -j$(nproc --all)
bundle update --bundler
ln -sf "${PREFIX}/opt/metasploit-framework/msfconsole" "${PREFIX}/bin/"
ln -sf "${PREFIX}/opt/metasploit-framework/msfvenom" "${PREFIX}/bin/"
ln -sf "${PREFIX}/opt/metasploit-framework/msfrpcd" ${PREFIX}/bin/
ln -sf "${PREFIX}/opt/metasploit-framework/msfdb" "${PREFIX}/bin/"
echo -e "\033[1;32m[+] \033[37mCongratulations, the installation has completed successfully.\033[0m"
echo -e "\033[1;34m[*] \033[37mYou can run: \033[32mmsfconsole\033[37m, \033[32mmsfvenom\033[37m, \033[32mmsfdb\033[37m, \033[32mmsfrpcd \033[37mfrom your terminal.\033[0m"
}
banner
uninstall_ruby
update
packages
fetch_msf
install_msf