-
Notifications
You must be signed in to change notification settings - Fork 182
/
metasploit.sh
72 lines (52 loc) · 2.54 KB
/
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
#!/data/data/com.termux/files/usr/bin/bash
# Remove Old Folder if exist
find $HOME -name "metasploit-*" -type d -exec rm -rf {} \;
cwd=$(pwd)
msfvar=6.1.21
msfpath='/data/data/com.termux/files/home'
apt update && apt upgrade
apt install -y binutils libiconv zlib autoconf bison clang coreutils curl findutils git apr apr-util libffi libgmp libpcap postgresql readline libsqlite openssl libtool libxml2 libxslt ncurses pkg-config wget make ruby libgrpc termux-tools ncurses-utils ncurses unzip zip tar termux-elf-cleaner
# Many phones are claiming libxml2 not found error
ln -sf $PREFIX/include/libxml2/libxml $PREFIX/include/
cd $msfpath
curl -LO https://github.com/rapid7/metasploit-framework/archive/refs/tags/$msfvar.tar.gz
tar -xf $msfpath/$msfvar.tar.gz
mv $msfpath/metasploit-framework-$msfvar $msfpath/metasploit-framework
cd $msfpath/metasploit-framework
# Update rubygems-update
#if [ "$(gem list -i rubygems-update 2>/dev/null)" = "false" ]; then
# gem install --no-document --verbose rubygems-update
#fi
# Update rubygems
#update_rubygems
# Install bundler
#gem install --no-document --verbose bundler:1.17.3
gem install bundler
# Installing all gems
#bundle config build.nokogiri --use-system-libraries
gem install nokogiri -v 1.12.5 -- --use-system-libraries
bundle install
echo "Gems installed"
# Some fixes
sed -i "s@/etc/resolv.conf@$PREFIX/etc/resolv.conf@g" $msfpath/metasploit-framework/lib/net/dns/resolver.rb
find "$msfpath"/metasploit-framework -type f -executable -print0 | xargs -0 -r termux-fix-shebang
find "$PREFIX"/lib/ruby/gems -type f -iname \*.so -print0 | xargs -0 -r termux-elf-cleaner
echo "Creating database"
mkdir -p $msfpath/metasploit-framework/config && cd $msfpath/metasploit-framework/config
curl -LO https://raw.githubusercontent.com/Hax4us/Metasploit_termux/master/database.yml
mkdir -p $PREFIX/var/lib/postgresql
pg_ctl -D "$PREFIX"/var/lib/postgresql stop > /dev/null 2>&1 || true
if ! pg_ctl -D "$PREFIX"/var/lib/postgresql start --silent; then
initdb "$PREFIX"/var/lib/postgresql
pg_ctl -D "$PREFIX"/var/lib/postgresql start --silent
fi
if [ -z "$(psql postgres -tAc "SELECT 1 FROM pg_roles WHERE rolname='msf'")" ]; then
createuser msf
fi
if [ -z "$(psql -l | grep msf_database)" ]; then
createdb msf_database
fi
rm $msfpath/$msfvar.tar.gz
cd ${PREFIX}/bin && curl -LO https://raw.githubusercontent.com/Hax4us/Metasploit_termux/master/msfconsole && chmod +x msfconsole
ln -sf $(which msfconsole) $PREFIX/bin/msfvenom
echo "you can directly use msfvenom or msfconsole rather than ./msfvenom or ./msfconsole."