My Grey Cells Burning

Friday, June 22, 2007
Configuring Metasploit 3 on Ubuntu Feisty


In the last article, we had msf3 installed and working nicely in our system. It is time to configure msf3 properly so that it can do the job.. well.

From here, we can see that we need to execute msfconsole (./msfconsole) , load db_mysql plugin and create database in which I will call metasploit inside mysql database from msfconsole.

However, there are little bit error when I followed the command db_create within the linked how to above:

msf > db_create root:mydbpass@localhost/metasploit
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: YES)'


Assuming that you had set the root password for MySQL database, typing help will show the correct parameter:

db_connect Connect to an existing database ( user:pass@host:port/db )

Right, we missing the port section, which caused the error above assuming that you had SET the root password for MySQL db.

msf > db_create root:mydbpass@localhost:3306/metasploit
[*] Database creation complete (check for errors)

Now it's alright.

Connecting now to the metasploit database that we had created earlier:

msf > db_connect root:mydbpass@localhost:3306/metasploit
msf >


Right. Lets type db_hosts:

msf > db_hosts
[-] Error while running command db_hosts: can't convert String into Integer

Call stack:
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/mysql_adapter.rb:389:in `real_connect'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/mysql_adapter.rb:389:in `connect'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/mysql_adapter.rb:152:in `initialize'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/mysql_adapter.rb:82:in `new'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/mysql_adapter.rb:82:in `mysql_connection'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:262:in `send'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:262:in `connection_without_query_cache='
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/query_cache.rb:54:in `connection='
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:230:in `retrieve_connection'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:78:in `connection'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:1139:in `add_limit!'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:1101:in `construct_finder_sql'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:997:in `find_every'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:418:in `find'
./lib/msf/core/db_objects.rb:35:in `find'
/usr/lib/ruby/1.8/thread.rb:135:in `synchronize'
./lib/msf/core/db_objects.rb:34:in `find'
./lib/msf/core/db.rb:160:in `hosts'
./lib/msf/core/db.rb:151:in `each_host'
./lib/msf/ui/console/command_dispatcher/db.rb:45:in `cmd_db_hosts'
./lib/rex/ui/text/dispatcher_shell.rb:230:in `send'
./lib/rex/ui/text/dispatcher_shell.rb:230:in `run_command'
./lib/rex/ui/text/dispatcher_shell.rb:196:in `run_single'
./lib/rex/ui/text/dispatcher_shell.rb:191:in `each'
./lib/rex/ui/text/dispatcher_shell.rb:191:in `run_single'
./lib/rex/ui/text/shell.rb:125:in `run'
./msfconsole:77
[-] Error while running command db_hosts: can't convert String into Integer

Call stack:
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/mysql_adapter.rb:389:in `real_connect'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/mysql_adapter.rb:389:in `connect'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/mysql_adapter.rb:152:in `initialize'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/mysql_adapter.rb:82:in `new'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/mysql_adapter.rb:82:in `mysql_connection'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:262:in `send'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:262:in `connection_without_query_cache='
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/query_cache.rb:54:in `connection='
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:230:in `retrieve_connection'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:78:in `connection'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:1139:in `add_limit!'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:1101:in `construct_finder_sql'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:997:in `find_every'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:418:in `find'
./lib/msf/core/db_objects.rb:35:in `find'
/usr/lib/ruby/1.8/thread.rb:135:in `synchronize'
./lib/msf/core/db_objects.rb:34:in `find'
./lib/msf/core/db.rb:160:in `hosts'
./lib/msf/core/db.rb:151:in `each_host'
./lib/msf/ui/console/command_dispatcher/db.rb:45:in `cmd_db_hosts'
./lib/rex/ui/text/dispatcher_shell.rb:230:in `send'
./lib/rex/ui/text/dispatcher_shell.rb:230:in `run_command'
./lib/rex/ui/text/dispatcher_shell.rb:196:in `run_single'
./lib/rex/ui/text/dispatcher_shell.rb:191:in `each'
./lib/rex/ui/text/dispatcher_shell.rb:191:in `run_single'
./lib/rex/ui/text/shell.rb:125:in `run'
./msfconsole:77
msf >

From the looks of it, the error Can't convert String into Integer is a unidentified error (Well, by me since I never encountered this error before and I still a n00b in Ruby). Suspicion falls on broken Ruby or maybe broken/misconfigured MySQL db, but let ask Uncle Googol first. After endless surfing, search shows a solution which is stolen from here:

Execute:

# mysql -u root -h localhost -p
Enter password:

mysql > create user 'root'@'localhost' identified by 'mydbpass';
mysql > grant all on metasploit.* to 'root'@'localhost';


Execute msfconsole, load mysql plugin, db_connect to metasploit db and now MySQL problem come up with this message:

"Client does not support authentication protocol requested by server; consider upgrading MySQL client"

Solution:

# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.0.38-Ubuntu_0ubuntu1-log Ubuntu 7.04 distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> set password for root@localhost = old_password('mydbpass');
Query OK, 0 rows affected (0.18 sec)

mysql> \q


Again, dance on msfconsole, and this time error like this:

"Error while running command db_hosts: getaddrinfo: Name or service not known"

Well, this one is due to missing DNS service. Installing bind by running:

# sudo apt-get install bind
# sudo updatedb


Check service is running by execute:

# ps -ef | grep named

Check open port by execute:

# sudo netstat -ltunpw

Dancing again into the msfconsole, and run the db_hosts again:

msf > db_hosts
msf >

Indicate 0 host added. (Hooray, no error pop up again!!)

Trying to add hosts using db_add_hosts:

msf > db_add_hosts localhost
[*] Adding 1 hosts...

So far, so good.

Trying db_nmap:

msf > db_nmap localhost

Starting Nmap 4.20 ( http://insecure.org ) at 2007-06-23 16:46 MYT
Interesting ports on penguin (127.0.0.1):
Not shown: 1693 closed ports
PORT STATE SERVICE
53/tcp open domain
3306/tcp open mysql

Nmap finished: 1 IP address (1 host up) scanned in 0.147 seconds
msf >

Beautiful. No more gibberish error and my head are spinning fast. And I am sleepy. Today is too hot.

Want to spend resting in hot day with custom-made ice-cream. Nyum nyum.
And listening to favorite musics, and sleep. Ta.


Hey! I listen to:

Labels:

posted by zarxcky @ 6/22/2007 02:35:00 AM  
0 Comments:
Post a Comment
<< Home
 
About Me
Previous Post
Archives
Links
Comrades
Syndicates