Installing Metasploit on Mac OS X


Metasploit LogoI have known about the Metasploit framework for quite some time but have never really known how to use it or taken the time to learn. Recently, Chris inspired me to try it by showing me a movie explaining how to exploit a vulnerability in Microsoft Windows related to the .ANI Header Stack Overflow Vulnerability (more on this in my next post).

Before I could begin working with this nifty little exploit in Metaspolit I had to get the framework installed on my MacBook. Metasploit is a suite of Ruby scripts and will run on virtually any Unix based operating system and Windows (with some minor tweaking). I checked the MacPorts for Metasploit and it was available as a port install but the latest version in the ports tree was 2.7. I needed at least version 3.0, and later determined I needed a development version, version 3.1, from the trunk to get the exploit I was after.

The first thing I did was upgrade my Subversion client on Mac OS X. I got the universal binary from here and installing and upgrading my Subversion was pretty painless. It installed like most other Mac applications from a package.

Once my Subversion client was up to date, I downloaded the Metasploit framework and unpcked it into /usr/local/msf/. I then made symbolic links to the different Metasploit related applications in /opt/local/bin/, the directory where MacPorts installs binaries and application related scripts. I did this by running the following command as root (or using sudo):

% sudo ln -s /usr/local/msf/msf* /opt/local/bin/

Now that I had the framework downloaded and in place, I installed an updated version of Ruby from MacPorts by running the following command:

% sudo port install ruby

I then downloaded the latest version of RubyGems, uncompressed it, changed into the uncompressed directory and ran the following command to install Ruby Gems:

% sudo ruby setup.rb

Once that operation had completed, I installed the latest version of Rails by issuing the following command:

gem install -v=1.2.3 rails

The original instructions for the steps performed above are available on the Metasploit wiki but I had to modify their instructions a bit due to some errors. The first error I encountered while using the MetaSploit instructions was with installing RubyGems. When following the instructions in the Metasploit wiki I received the following error:

ruby: No such file or directory -- setup (LoadError))

I found some instructions in the RubyGems User Guide that led me to the ruby setup.rb command to install Gems.

The next issue I encountered when using the instructions in the Metaploit wiki was an error when trying to run gem install -v=1.2.2 rails I don’t have the exact error to give you but it was basically something to the effect that version 1.2.2 wasn’t found i the repository. I browsed the repository and saw that a newer version, version 1.2.3, was available so that is why I issued the command with -v=1.2.3.

Once all of the above was completed, I tried to run the exploit I was hoping to run and version 3.0 of the Metasploit framework. I tried to update Metasploit to a higher version but was returned the following:

% sudo svn update
Skipped '.'

I then grabbed a development snapshot by running the following command:

% sudo svn co http://metasploit.com/svn/framework3/trunk/

I placed the trunk/ directory in my /usr/local/msf/ directory and changed my symbolic links to point to the newly downloaded Metasploit components by issuing the following command:

% sudo ln -sf /usr/local/msf/trunk/msf* /opt/local/bin/

I hope this helps other Mac users if and when they get ready to install the Metasploit framework, or Ruby, RubyGems, and Ruby on Rails on their Mac. It is also good for me to have things like this documented somewhere in case I need to revisit it in the future. Either way, Enjoy!

Until next time…

12 Responses to “Installing Metasploit on Mac OS X”

    a gravatar
  1. Cocoa Crusty » Blog Archive » My First Remote Shell Access Exploit Says:

    [...] post is the reason I posted my previous blog entry on installing the Metasploit framework on my Apple MacBook. Chris sent me a link to this movie [...]

    From United States using WordPress WordPress 2.1.3
  2. a gravatar
  3. average admins » Blog Archive » Installing Metasploit on Mac OS X Says:

    [...] posted at cocoacrusty.com on Monday, April 16th, [...]

    From United States using WordPress WordPress 2.1
  4. a gravatar
  5. r0sk Says:

    Lots of thanks!, there are so many errors installing Metasploit and now (after read your post) that’s running so well (educational purpose only) ;).

    From United States using Mozilla Firefox Mozilla Firefox 2.0.0.3 on Mac OS Mac OS X
  6. a gravatar
  7. Cocoa Crusty Says:

    Glad I could help, r0sk!

    Take care!

    Cocoa

    From United States using Mozilla Firefox Mozilla Firefox 2.0.0.3 on Mac OS Mac OS X
  8. a gravatar
  9. links for 2007-07-11 at edsmiley.com Says:

    [...] Installing Metasploit on Mac OS X | Cocoa Crusty (tags: metasploit macosx) [...]

    From United States using WordPress WordPress 2.1.3
  10. a gravatar
  11. bassglider Says:

    gem install rails –include-dependencies

    works best

    From United States using Safari Safari 419.3 on Mac OS Mac OS X
  12. a gravatar
  13. Gakk Says:

    Great! I had to use 1.2.2 version of rails though, but it’s working fine now.

    From United States using Camino Camino 1.5 on Mac OS Mac OS X
  14. a gravatar
  15. _J Says:

    I’m installing right now ;-) Thanks alot

    From United States using Safari Safari 522.12.1 on Mac OS Mac OS X
  16. a gravatar
  17. sist3m Says:

    The reason why you were getting this error:

    # sudo svn update
    Skipped ‘.’

    is because you executed the command from the wrong directory. You have to be in the following directory for it to be successful:

    …Metasploit/Framework3/framework

    Cocoa are you Australia ? If so, are there any Hack OS X groups in Sydney ?

    r/

    sist3m.

    ps Ruxcon was canceled this year :(

    From United States using Internet Explorer Internet Explorer 7.0 on Windows Windows XP
  18. a gravatar
  19. Cocoa Crusty Says:

    Thanks for the heads up, sist3m. I am not from Australia. Good luck finding a group in Sydney!

    Cocoa

    From United States using Mozilla Firefox Mozilla Firefox 2.0.0.7 on Windows Windows XP
  20. a gravatar
  21. spadge3 Says:

    I am a n00b. I have never used command line before. I got to the part of the metasploit install directions where you installed Ruby Gems. I am on a MacBook as well and it keeps telling me there is no such directory or file I don’t know what I did wrong. Can anyone help?

    From United States using Safari Safari 419.3 on Mac OS Mac OS X
  22. a gravatar
  23. Cocoa Crusty » Blog Archive » Where Are You?! Says:

    [...] these people are searching for “metasploit mac osx” or something similar, and my post, found here, ranks number one on Google. People are also stumbling upon (pun intended) my Web site for queries [...]

    From United States using WordPress WordPress 2.5.1

Leave a Reply


 

Categories