This isn’t the first time I’ve had to do this, but I recently had to quickly spin up an Amazon EC2 instance to run the Metasploit Framework online, and thought I should capture the high level process flow somewhere. And so this gist was created on github.
I found that if you need it quickly, aren’t expecting on requiring it for very long and don’t mind spending a little bit more (I’m still talking about that Metasploit instance .. sickos), then running up one of Amazon’s “Basic 64-bit Amazon Linux AMI” on an “High-CPU Extra Large (c1.xlarge, 7GB)” instance is perfect, especially if you need to install ruby 1.9.2 instead of using the AMI’s default ruby 1.8.
The gist does the following:
sudo yum install make gcc openssl-devel svn git
Install the necessary packages to build software, including OpenSSL requirements. Also install git (for getting RVM, more below) and svn (for getting MSF .. although they have moved to github, so this will likely change soon)
bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
exit
Install RVM, the Ruby Version Manager, this is a simplified method to install multiple ruby versions. The bash script above is ripped directly from the RVM page here. This helps us run up ruby 1.9.2, which seems to work brilliantly with the Metasploit Framework, at least as of the current version. We exit, and then you ssh back into your instance so that RVM gets setup in your bash profile.
rvm pkg install openssl
Use RVM to install the OpenSSL package, this is used for the RVM process when we install Ruby 1.9.2.
rvm install 1.9.2 --with-openssl-dir=$rvm_path/usr
Use RVM to install Ruby version 1.9.2, and set it to use the RVM install OpenSSL, per the above command. This is the longest part of the process, and this is where we really benefit from using that High CPU instance ;)
svn co https://www.metasploit.com/svn/framework3/trunk/
cd trunk
Checkout the latest version of the Metasploit Framework into the “trunk” folder and change into there.
rvm use 1.9.2
Tell RVM that we want to use that installed version of Ruby 1.9.2.
rvmsudo ruby -v
Check that we’re running Ruby 1.9.2. Rvmsudo is used to emulate running the commands through sudo, but in the context of rvm. We want to check that Ruby 1.9.2 runs under rvmsudo because we may want Metasploit to listen on low ports, such as TCP/80.
rvmsudo ruby ./msfconsole
Lets start up Metasploit, as Root, using Ruby 1.9.2. Obviously, if you’re concerned about running Metasploit as root feel free to start Metasploit as a regular user with “ruby ./msfconsole”.
And there you go. A quick, blow away Amazon Linux powered Metasploit Framework instance.
Tags: amazon, cloud, metasploit, Security


