Bug #1158

db_add_host throws stack trace - undefined method `created_at'

Added by Jonathan Cran almost 2 years ago. Updated over 1 year ago.

Status:Closed Start date:03/16/2010
Priority:Normal Due date:
Assignee:- % Done:

0%

Category:database support
Target version:Metasploit 3.4.0
Resolution:worksforme Release Note:

Description


msf > db_driver
[*]    Active Driver: mysql
[*]        Available: sqlite3, mysql, postgresql

msf > db_connect root:pass@127.0.0.1
[*] Successfully connected to the database
[*] File: root:pass@127.0.0.1

msf > db_notes
msf > db_vulns

msf > db_add_host 1.2.3.4
[*] Adding 1 hosts...
[-] Error while running command db_add_host: undefined method `created_at' for nil:NilClass

Call stack:
/media/truecrypt1/metasploit/source/framework3/lib/msf/ui/console/command_dispatcher/db.rb:345:in `cmd_db_add_host'
/media/truecrypt1/metasploit/source/framework3/lib/msf/ui/console/command_dispatcher/db.rb:343:in `each'
/media/truecrypt1/metasploit/source/framework3/lib/msf/ui/console/command_dispatcher/db.rb:343:in `cmd_db_add_host'
/media/truecrypt1/metasploit/source/framework3/lib/rex/ui/text/dispatcher_shell.rb:239:in `send'
/media/truecrypt1/metasploit/source/framework3/lib/rex/ui/text/dispatcher_shell.rb:239:in `run_command'
/media/truecrypt1/metasploit/source/framework3/lib/rex/ui/text/dispatcher_shell.rb:201:in `run_single'
/media/truecrypt1/metasploit/source/framework3/lib/rex/ui/text/dispatcher_shell.rb:195:in `each'
/media/truecrypt1/metasploit/source/framework3/lib/rex/ui/text/dispatcher_shell.rb:195:in `run_single'
/media/truecrypt1/metasploit/source/framework3/lib/rex/ui/text/shell.rb:144:in `run'
./msfconsole:93

History

Updated by James Lee almost 2 years ago

  • Category set to database support
  • Status changed from New to Closed
  • Target version set to Metasploit 3.4.0
  • Resolution set to worksforme

Doesn't reproduce on ruby 1.8.6, 1.9.1, 1.9.2-head, postgres or mysql. It's likely that you had a failed migration. Closing as works for me.

Updated by Jori Hardman over 1 year ago

I'm having the same error with ruby 1.9.1p429 on archlinux. I checked the database, and it was created correctly using db_create. There is a created_at column in the hosts table. I'm starting to think there is a problem with mysql in general as I can't connect to my database using db_connect:

msf > db_driver mysql
[*] Using database driver mysql
msf > db_connect root:password@localhost/metasploit
[-] Error while running command db_connect: Failed to connect to the database: Can't connect to MySQL server on '127.0.0.1' (111)

Call stack:
/usr/src/metasploit/lib/msf/ui/console/command_dispatcher/db.rb:1430:in `db_connect_mysql'
/usr/src/metasploit/lib/msf/ui/console/command_dispatcher/db.rb:1277:in `cmd_db_connect'
/usr/src/metasploit/lib/rex/ui/text/dispatcher_shell.rb:246:in `run_command'
/usr/src/metasploit/lib/rex/ui/text/dispatcher_shell.rb:208:in `block in run_single'
/usr/src/metasploit/lib/rex/ui/text/dispatcher_shell.rb:202:in `each'
/usr/src/metasploit/lib/rex/ui/text/dispatcher_shell.rb:202:in `run_single'
/usr/src/metasploit/lib/rex/ui/text/shell.rb:141:in `run'
/usr/bin/msfconsole:112:in `<main>'

I can connect to the db just fine using mysql -u root -p metasploit

Updated by Jori Hardman over 1 year ago

I figured it out for anyone who has this problem in the future. In my.cnf skip-networking was uncommented. I commented that out and now there are no problems.

Also available in: Atom PDF