Armitage is a new GUI for Metasploit, which is very interactive and makes hacking or like white-hats call it pen-testing real easy.
To install Armitage, all you have to do is download it and run it on Linux using the following command:
./armitage.sh
The reason I’m writing this blog is that while trying to run it with Metasploit and MySQL, I came across two errors and it took me a while to find the answers.
I was trying to install Armitage on Backtrack4, not 4r2 version for which the instructions are available here.
So the first error i was getting was when installing the gem mysql. The gem is required if you want to use MySQL database. When I tried installing the gem in Metasploit itself or in shell I was getting the following error:
ERROR: could not find gem mysql locally or in a repository
So I need to update the gem repository and I tried:
gem update --system
This returned an error:
ERROR: While executing gem ... (RuntimeError)
gem update --system is disabled on Debian. RubyGems can be updated using the
official Debian repositories by aptitude or apt-get.
Wandered on the Interwebs for a while and found no solution. So I tried updating the ruby gems by doing:
apt-get install rubygems
And this updated the package and the following command now worked:
gem install mysql
But wait, I’m still not able to connect to the MySQL database in Metasploit or Armitage, when I run the following command:
msf > db_connect root:toor@127.0.0.1/msf3
The error I get is:
[-] Error while running command db_connect: Failed to connect to the database: uninitialized constant MysqlCompat::MysqlRes
Call stack:
/opt/metasploit3/msf3/lib/msf/ui/console/command_dispatcher/db.rb:1702:in `db_connect_mysql'
/opt/metasploit3/msf3/lib/msf/ui/console/command_dispatcher/db.rb:1548:in `cmd_db_connect'
/opt/metasploit3/msf3/lib/rex/ui/text/dispatcher_shell.rb:246:in `run_command'
/opt/metasploit3/msf3/lib/rex/ui/text/dispatcher_shell.rb:208:in `block in run_single'
/opt/metasploit3/msf3/lib/rex/ui/text/dispatcher_shell.rb:202:in `each'
/opt/metasploit3/msf3/lib/rex/ui/text/dispatcher_shell.rb:202:in `run_single'
/opt/metasploit3/msf3/lib/rex/ui/text/shell.rb:143:in `run'
/opt/metasploit3/msf3/msfconsole:128:in `'
WTF…
Searched for the error on Google and found an article on how to resolve this error on Mac OS X. Unix Linux same shit. Knew it will work. So ran the following command:
sudo gem install --no-rdoc --no-ri -v=2.7 mysql -- --with-mysql-dir=/usr/local/mysql --with-mysql-config=/usr/bin/mysql_config
It worked and Armitage now successfully connected to the Metaploit db in MySQL.
Happy Hacking!