Skip to content

Instantly share code, notes, and snippets.

@maus-
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maus-/165e080278ea56de3ea9 to your computer and use it in GitHub Desktop.
Save maus-/165e080278ea56de3ea9 to your computer and use it in GitHub Desktop.
MSF Installer on Ubuntu 12.04-14.04 works well with vagrant boxes
#!/bin/bash
# I CAN MSF AND SO CAN YOU
LOLPASSWORD=$(strings /dev/urandom | grep -o '[[:alnum:]]' | head -n 32 | tr -d '\n'; echo)
LOLPASSWORDTESTUSER=$(strings /dev/urandom | grep -o '[[:alnum:]]' | head -n 32 | tr -d '\n'; echo)
RUBY_VERSION="ruby-1.9.3-p547"
MSFPATH="/opt/msf"
install_deps () {
apt-get update;
# Obviously more than MSF.
apt-get -y install \
build-essential zlib1g zlib1g-dev libxml2 subversion libxml2-dev libxslt-dev locate libreadline6-dev libcurl4-openssl-dev git-core libssl-dev libyaml-dev openssl autoconf libtool ncurses-dev bison curl wget postgresql postgresql-contrib libpq-dev libapr1 libaprutil1 libsvn1 libpcap-dev git postgresql-client htop unzip lsof git-core vim gawk libsqlite3-dev sqlite3 libgdbm-dev libffi-dev tree
}
setup_rvm () {
\curl -o rvm.sh -L get.rvm.io && cat rvm.sh | bash -s stable --autolibs=enabled --ruby=$1
source /etc/profile.d/rvm.sh
rvm --default use $1
sudo usermod -a -G rvm $(whoami)
}
setup_postgres() {
service postgresql start
sudo -u postgres psql -c "CREATE USER msfuser WITH PASSWORD '$1';"
sudo -u postgres psql -c "CREATE USER msftest WITH PASSWORD '$2';"
sudo -u postgres psql -c "CREATE database metasploit_framework_development;"
sudo -u postgres psql -c "CREATE database metasploit_framework_test;"
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE metasploit_framework_development to msfuser;"
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE metasploit_framework_test to msftest;"
}
setup_nmap() {
svn co https://svn.nmap.org/nmap /tmp/nmap
cd /tmp/nmap; /tmp/nmap/configure
make
make install
}
setup_msf () {
git clone https://github.com/rapid7/metasploit-framework $3
cd $3; bundle install
for MSF in $(ls msf*)
do ln -s $3/$MSF /usr/local/sbin/$MSF
done
cp $3/config/database.yml.example $3/config/database.yml
sed -i 's/username: \metasploit_framework_development/username: msfuser/g' $3/config/database.yml
sed -i 's/username: \metasploit_framework_test/username: msftest/g' $3/config/database.yml
sed -i "s/__________________________________/$1/g" $3/config/database.yml
sed -i "s/___________________________/$2/g" $3/config/database.yml
echo "export MSF_DATABASE_CONFIG=$3/config/database.yml" >> ~/.bash_profile
source ~/.bash_profile
}
supbrah () {
echo " __ __ ____ _____ "
echo "| \/ / ___|| ___|"
echo "| |\/| \___ \| |_ "
echo "| | | |___) | _| "
echo "|_| |_|____/|_| "
echo "happy msfing dev nonsense"
echo "TODO: call msf oustide of $1"
}
install_deps
setup_rvm $RUBY_VERSION
setup_postgres $LOLPASSWORD $LOLPASSWORDTESTUSER
setup_nmap
setup_msf $LOLPASSWORD $LOLPASSWORDTESTUSER $MSFPATH
supbrah
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment