Skip to content

Instantly share code, notes, and snippets.

@holms
Last active August 19, 2023 19:12
Show Gist options
  • Star 17 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save holms/7379965 to your computer and use it in GitHub Desktop.
Save holms/7379965 to your computer and use it in GitHub Desktop.
Install Metasploit with Armitage on OSX Maverics

Install Metasploit (with Armitage) on OSX Maverics

Requirements

PostgreSQL

Install role

Open pgAdmin III.app, connect to the local postgresql server (user postgres, if it asks, & whatever password from above), right-click on Login Roles and select New Login Role...

Set the role name (this will be the username) to whatever you want or use msfuser Under the definition tab, set the password to whatever you want or use msfpassword

Configure the database

Still in pgAdmin III.app, right-click on Databases and select New Database... Set the database Name to whatever you want or use metasploitdb Set the database Owner to the new user from above (msfuser in the example above)

Macports

Install MacPorts - http://www.macports.org/

Configure macports

Add /opt/local to your spotlight privacy settings to avoid excessive compile times & unnecessary indexing by spotlight.

Go to: System Preferences->Spotlight->Privacy->"+" Press command+shift+G and type in /opt/local

Update with sudo port selfupdate Quit terminal & relaunch to accept new path settings added by MacPorts

Metasploit

Install requirements

sudo port install ruby19 +nosuffix
sudo mv /opt/local/bin/ruby /opt/local/bin/ruby20
sudo ln -s /opt/local/bin/ruby1.9 /opt/local/bin/ruby
sudo gem update --system
sudo gem install pg -- --with-opt-include=/Library/PostgreSQL/9.3/include/ --with-opt-lib=/Library/PostgreSQL/9.3/lib/

Install the gsm msgpack with: sudo gem install msgpack

Install metasploit (with armitage)

sudo bash
cd /opt
git clone https://github.com/rapid7/metasploit-framework.git
mv metasploit-framework msf && cd msf
export PATH=/Library/PostgreSQL/9.3/bin/:$PATH # change to your postgresql version
bundle
ln -s /opt/msf/* /opt/local/bin
ln -s /opt/msf/armitage /opt/local/bin

Configure metasploit:

mkdir -p /opt/local/config
cat > /opt/local/config/database.yml

Add this:

# These settings are for the database used by the Metasploit Framework
# unstable tree included in this installer, not the commercial editions.
#

production:
  adapter: "postgresql"
  database: "metasploitdb"
  username: "msfuser"
  password: "msfpassword"
  port: 5432
  host: "localhost"
  pool: 256
  timeout: 5

Run Metasploit

Launch daemons, and connect to DB:

export MSF_DATABASE_CONF=/opt/local/config/database.yml
msfrpcd -U msfuser2 -P msfpassword2 -S -a 127.0.0.1 -t Msg 
msfconsole # open msf console and connect to db
msf> db_connect -y /opt/local/config/database.yml
msf> exit

Create msfrpcd a launchd service:

/Library/LaunchDaemons/org.metasploitframework.rpcd.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Disabled</key>
        <false/>
        <key>Label</key>
        <string>org.metasploitframework.rpcd</string>
        <key>RunAtLoad</key>
        <true/>
        <key>Debug</key>
        <false/>
        <key>ProgramArguments</key>
        <array>
                <string>export MSF_DATABASE_CONF=/opt/local/config/database.yml</string>
                <string>/opt/local/bin/ruby</string>
                <string>/opt/local/msf/msfrpcd</string>
                <string>-f</string>
                <string>-U</string>
                <string>msfuser2</string>
                <string>-P</string>
                <string>msfpassword2</string>
                <string>-S</string>
                <string>-a</string>
                <string>127.0.0.1</string>
                <string>-t</string>
                <string>Msg</string>
        </array>
        <key>WorkingDirectory</key>
        <string>/opt/local/bin/</string>
</dict>
</plist>

Start the msfrpcd launchd with sudo launchctl load /Library/LaunchDaemons/org.metasploitframework.rpcd.plist

Armitage

Version mac from here: http://www.fastandeasyhacking.com/download doesn't work for me. The only way I Armitage worked for me, is to launch it from command line with this:

MSF_DATABASE_CONFIG=/opt/local/config/database.yml open /Applications/Armitage.app

Although I've tried to put it to ~/.zshrc and /etc/bashrc and ~/.profile, variable is visible only for me, but not visible for armitage so whatever.. it works.

If you have problem like this: java.net.SocketException: Unexpected end of file from server You probably forgot to include -S param when starting msfrpcd, this one disables SSL.

Compile Armitage from source

cd /opt
svn checkout http://armitage.googlecode.com/svn/trunk/ armitage-read-only
mv armitage-read-only armitage && cd armitage
port -v install apache-ant
./package.sh
java -C "armitage.jar"
@marc6194
Copy link

bash-3.2# java -C "armitage.jar"
Unrecognized option: -C
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

what am i doing wrong

@maslaczek
Copy link

For issue "Could not find minitest-4.7.5 in any of the sources" helped me downgrade of ruby version ( 2.1 from 2.2 ).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment