The officially official Devuan Forum!

You are not logged in.

#1 2017-08-15 14:37:38

pedropt
Member
Registered: 2017-01-27
Posts: 11  

Install Metasploit-Framework From Git on Devuan

I am creating this thread also for me to consult in future in case i need .

Before Installing
You should be a root user .

If during instalation you get this error : update-rc.d: not found

You should edit .bashrc on your home folder and add PATH so this file can be located .
for this use nano :

nano ~/.bashrc

and write this line at the end of the file

export PATH=$PATH:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin

Note : This could happen on a fresh devuan install
STEP 1
Install ruby 2.4.2

- Dependencies for Rudy & Metaploit-Framework

sudo apt-get install git-core curl zlib1g-dev build-essential libpq5 libpq-dev libssl-dev libreadline-dev libreadline5 libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libpcap-dev git-core autoconf postgresql pgadmin3 curl zlib1g-dev libyaml-dev curl libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev git 

Install Rubyenv

-

git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc

git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

- Close your terminals and open one terminal again so bashrc can be reloaded with the new config

UPDATE : Updated ruby version to latest metasploit requirements from 2.4.2 to 2.5.3

rbenv install -v 2.5.3
rbenv global 2.5.3
echo "gem: --no-document" > ~/.gemrc
gem install bundler
gem install rails
rbenv rehash

STEP 2 - Clone metasploit from git and configure it
(This example will install metasploit on /opt directory , but you can choose any directory you want)

mkdir /opt
cd /opt
git clone https://github.com/rapid7/metasploit-framework.git
cd metasploit-framework
bundle install
service postgresql start

Configure metasploit Databases on Postgresql , so it could be faster the search inside metasploit framework

cat <<EOF> $HOME/pg-utf8.sql

update pg_database set datallowconn = TRUE where datname = 'template0';

\c template0

update pg_database set datistemplate = FALSE where datname = 'template1';
 
drop database template1;
 
create database template1 with template = template0 encoding = 'UTF8';
 
update pg_database set datistemplate = TRUE where datname = 'template1';
 
\c template1
 
update pg_database set datallowconn = FALSE where datname = 'template0';
 
\q
 
EOF
sudo -u postgres psql -f $HOME/pg-utf8.sql
sudo -u postgres createuser msfdev -dRS
sudo -u postgres psql
"ALTER USER msfdev with ENCRYPTED PASSWORD 'msf';"

Press Enter
Press CTRL+D

- Create metasploit databases in Postgresql

sudo -u postgres createdb --owner msfdev msf_dev_db
sudo -u postgres createdb --owner msfdev msf_test_db
./msfconsole

Metasploit will start and will create its directory on your Home folder .
write "exit" inside metasploit framework to quit .

- Set database configuration on metasploit home folder to access its database in postgresql

cat <<EOF> $HOME/.msf4/database.yml
 
# Development Database
 
  development: pgsql
 
  adapter: postgresql
 
  database: msf_dev_db
 
  username: msfdev
 
  password: msf
 
  host: localhost
 
  port: 5432
 
  pool: 5
 
  timeout: 5

# Production database -- same as dev
 
production: &production
 
  <<: *pgsql

# Test database -- not the same, since it gets dropped all the time

 test:
 
  <<: *pgsql
 
  database: msf_test_db
 
EOF

Press CTRL+D to Exit

service postgresql start
 
sudo -sE su postgres
 
psql
 
update pg_database set datallowconn = TRUE where datname = 'template0';
 
\c template0
 
update pg_database set datistemplate = FALSE where datname = 'template1';
 
drop database template1;
 
create database template1 with template = template0 encoding = 'UTF8';
 
update pg_database set datistemplate = TRUE where datname = 'template1';
 
\c template1
 
update pg_database set datallowconn = FALSE where datname = 'template0';
 
\q

Press CTRL+D to exit

- Setting up Metasploit database Password on postgresql

sudo -u postgres psql
\password msfdev

Write "msf" and press ENTER key ,
Then confirm again by writing "msf" and pressing ENTER key again .

Press CTRL+D to exit .

service postgresql restart

- STEP 3

Create symlinks to metasploit executables on your sbin folder (so you can run metasploit anywhere)

ln -s /opt/metasploit-framework/msfconsole /usr/local/sbin/msfconsole
ln -s /opt/metasploit-framework/msfupdate /usr/local/sbin/msfupdate
ln -s /opt/metasploit-framework/msfvenom /usr/local/sbin/msfvenom

Everything is installed , now you can run metasploit by writing in your terminal "msfconsole" .
You can update your metasploit by writing in terminal "msfupdate"

Last edited by pedropt (2019-01-26 17:11:34)

Offline

Board footer