I've decided to add a section on using db_autopwn, just too add to completeness and content. Please spend some time with the resources I've included in the links section as well. db_autopwn is a very handy tool to get some work done quickly, however using exploits individually can often be more effective as well as quieter/stealthier. Also, please configure you're postgresql database, as many of us have pointed out quite a number of times that sqlite3 has issues or is not as reliable as postgres for using db_autopwn. Visit sickn3ss' thread listed in the links section for information on configuring postgresql for this use.
Below is setting the driver, and confirming it is set to what you need
Code:
root@bt:~# msfconsole
msf > db_driver postgresql
[*] Using database driver postgresql
msf > db_driver
[*] Active Driver: postgresql
[*] Available: postgresql, sqlite3
[*] DB Support: Enable the mysql driver with the following command:
[*] $ gem install mysql
[*] This gem requires mysqlclient headers, which can be installed on Ubuntu with:
[*] $ sudo apt-get install libmysqlclient-dev
This is what will be output if you have not yet used postgres for this(i.e. have not created the database. In this case we are creating the database 'db_autopwn')
Anyway, here is the command to connect
Code:
msf > db_connect postgres:mypassword@127.0.0.1/db_autopwn
NOTICE: CREATE TABLE will create implicit sequence "hosts_id_seq" for serial column "hosts.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "hosts_pkey" for table "hosts"
NOTICE: CREATE TABLE will create implicit sequence "clients_id_seq" for serial column "clients.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "clients_pkey" for table "clients"
NOTICE: CREATE TABLE will create implicit sequence "services_id_seq" for serial column "services.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "services_pkey" for table "services"
NOTICE: CREATE TABLE will create implicit sequence "vulns_id_seq" for serial column "vulns.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "vulns_pkey" for table "vulns"
NOTICE: CREATE TABLE will create implicit sequence "refs_id_seq" for serial column "refs.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "refs_pkey" for table "refs"
NOTICE: CREATE TABLE will create implicit sequence "notes_id_seq" for serial column "notes.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "notes_pkey" for table "notes"
NOTICE: CREATE TABLE will create implicit sequence "wmap_targets_id_seq" for serial column "wmap_targets.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "wmap_targets_pkey" for table "wmap_targets"
NOTICE: CREATE TABLE will create implicit sequence "wmap_requests_id_seq" for serial column "wmap_requests.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "wmap_requests_pkey" for table "wmap_requests"
NOTICE: CREATE TABLE will create implicit sequence "workspaces_id_seq" for serial column "workspaces.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "workspaces_pkey" for table "workspaces"
NOTICE: CREATE TABLE will create implicit sequence "events_id_seq" for serial column "events.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "events_pkey" for table "events"
NOTICE: CREATE TABLE will create implicit sequence "loots_id_seq" for serial column "loots.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "loots_pkey" for table "loots"
NOTICE: CREATE TABLE will create implicit sequence "users_id_seq" for serial column "users.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "users_pkey" for table "users"
NOTICE: CREATE TABLE will create implicit sequence "reports_id_seq" for serial column "reports.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "reports_pkey" for table "reports"
NOTICE: CREATE TABLE will create implicit sequence "tasks_id_seq" for serial column "tasks.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "tasks_pkey" for table "tasks"
NOTICE: CREATE TABLE will create implicit sequence "creds_id_seq" for serial column "creds.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "creds_pkey" for table "creds"
NOTICE: CREATE TABLE will create implicit sequence "exploited_hosts_id_seq" for serial column "exploited_hosts.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "exploited_hosts_pkey" for table "exploited_hosts"
NOTICE: CREATE TABLE will create implicit sequence "report_templates_id_seq" for serial column "report_templates.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "report_templates_pkey" for table "report_templates"
NOTICE: CREATE TABLE will create implicit sequence "campaigns_id_seq" for serial column "campaigns.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "campaigns_pkey" for table "campaigns"
NOTICE: CREATE TABLE will create implicit sequence "email_templates_id_seq" for serial column "email_templates.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "email_templates_pkey" for table "email_templates"
NOTICE: CREATE TABLE will create implicit sequence "attachments_id_seq" for serial column "attachments.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "attachments_pkey" for table "attachments"
NOTICE: CREATE TABLE will create implicit sequence "email_addresses_id_seq" for serial column "email_addresses.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "email_addresses_pkey" for table "email_addresses"
NOTICE: CREATE TABLE will create implicit sequence "web_templates_id_seq" for serial column "web_templates.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "web_templates_pkey" for table "web_templates"
NOTICE: CREATE TABLE will create implicit sequence "web_sites_id_seq" for serial column "web_sites.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "web_sites_pkey" for table "web_sites"
NOTICE: CREATE TABLE will create implicit sequence "web_pages_id_seq" for serial column "web_pages.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "web_pages_pkey" for table "web_pages"
NOTICE: CREATE TABLE will create implicit sequence "web_forms_id_seq" for serial column "web_forms.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "web_forms_pkey" for table "web_forms"
NOTICE: CREATE TABLE will create implicit sequence "web_vulns_id_seq" for serial column "web_vulns.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "web_vulns_pkey" for table "web_vulns"
NOTICE: CREATE TABLE will create implicit sequence "imported_creds_id_seq" for serial column "imported_creds.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "imported_creds_pkey" for table "imported_creds"
Next, I like to verify the status of the connection. If you are not creating a new database and are connecting to an existing one, it may be a good idea to see if you've left anything in it. Here's the example
Code:
msf > db_status
[*] postgresql connected to db_autopwn
msf > db_hosts
Hosts
=====
address address6 arch comm comments created_at info mac name os_flavor os_lang os_name os_sp purpose state updated_at svcs vulns workspace
------- -------- ---- ---- -------- ---------- ---- --- ---- --------- ------- ------- ----- ------- ----- ---------- ---- ----- ---------
I like to clean my output on db_hosts, as the nmap string I like to use for quick doesn't fill a number of the fields. Here's how.
Code:
msf > db_hosts -h
Usage: db_hosts [-h|--help] [-u|--up] [-a <addr1,addr2>] [-c <column1,column2>] [-o output-file ]
-a <addr1,addr2> Search for a list of addresses
-c <col1,col2> Only show the given columns
-h,--help Show this help information
-u,--up Only show hosts which are up
-o <file> Send output to a file in csv format
Available columns: address, address6, arch, comm, comments, created_at, info, mac, name, os_flavor, os_lang, os_name, os_sp, purpose, state, updated_at
msf > db_hosts -c address,mac,name,state,updated_at,svcs,vulns
Hosts
=====
address mac name state updated_at svcs vulns
------- --- ---- ----- ---------- ---- -----
In the example above, there is nothing in the database. Entries can be added or otherwise manipulated manually with commands such as "db_add_host, db_add_port, db_del_host,etc." Of course nmap is a much simpler way of populating your database. Right now we are just going to add an individual host in with db_nmap, but you can certainly scan in a subnet instead.
...continues...