查看有哪些数据库
msf5 > db_
db_connect db_disconnect db_export db_import db_nmap db_rebuild_cache db_remove db_save db_status
查看数据库状态
msf5 > db_status
[*] postgresql selected, no connection
状态异常,无法连接数据库
Exit退出
查看msfdb帮助
root@q:~# msfdb -h
[-] Error: unrecognized action '-h'
Manage the metasploit framework database
msfdb init # start and initialize the database
msfdb reinit # delete and reinitialize the database
msfdb delete # delete database and stop using it
msfdb start # start the database
msfdb stop # stop the database
msfdb status # check service status
msfdb run # start the database and run msfconsole
启动一下db,用命令看一下端口服务是否打开
root@q:~# msfdb start
[+] Starting database
root@q:~# netstat -pantu | grep 5432
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 3052/postgres
tcp6 0 0 ::1:5432 :::* LISTEN 3052/postgres
/*
如果还没有端口显示,可以启动一下postgresql数据库
root@q:~# service postgresql start
然后再
root@q:~# msfdb start
*/
进入在查看一下,已经打开
msf5 > db_status
[*] Connected to msf. Connection type: postgresql.
msf5 >
没有数据库的msf可以使用,但得到的结果不会保存到数据库
hosts可以查看数据库(-h查看帮助)
msf5 > hosts
Hosts
=====
address mac name os_name os_flavor os_sp purpose info comments
------- --- ---- ------- --------- ----- ------- ---- --------
msf5 >
services 可以搜索更多信息
msf5 > services -h
Usage: services [-h] [-u] [-a] [-r <proto>] [-p <port1,port2>] [-s <name1,name2>] [-o <filename>] [addr1 addr2 ...]
-a,--add Add the services instead of searching
-d,--delete Delete the services instead of searching
-c <col1,col2> Only show the given columns
-h,--help Show this help information
-s <name> Name of the service to add
-p <port> Search for a list of ports
-r <protocol> Protocol type of the service being added [tcp|udp]
-u,--up Only show services which are up
-o <file> Send output to a file in csv format
-O <column> Order rows by specified column number
-R,--rhosts Set RHOSTS from the results of the search
-S,--search Search string to filter by
-U,--update Update data for existing service
Available columns: created_at, info, name, port, proto, state, updated_at
msf5 >
用nmap扫描之后
msf5 > db_nmap 192.168.1.1
[*] Nmap: Starting Nmap 7.80 ( https://nmap.org ) at 2020-02-08 21:41 CST
[*] Nmap: Nmap scan report for TianYi.Home (192.168.1.1)
[*] Nmap: Host is up (0.040s latency).
[*] Nmap: Not shown: 992 closed ports
[*] Nmap: PORT STATE SERVICE
[*] Nmap: 23/tcp filtered telnet
[*] Nmap: 80/tcp open http
[*] Nmap: 139/tcp filtered netbios-ssn
[*] Nmap: 445/tcp open microsoft-ds
[*] Nmap: 5431/tcp open park-agent
[*] Nmap: 8080/tcp open http-proxy
[*] Nmap: 9080/tcp filtered glrpc
[*] Nmap: 32768/tcp open filenet-tms
[*] Nmap: MAC Address: 5C:A1:76:4B:07:30 (Sichuan Tianyi Comheart Telecomco.)
[*] Nmap: Nmap done: 1 IP address (1 host up) scanned in 3.41 seconds
msf5 > services
Services
========
host port proto name state info
---- ---- ----- ---- ----- ----
192.168.1.1 23 tcp telnet filtered
192.168.1.1 80 tcp http open
192.168.1.1 139 tcp netbios-ssn filtered
192.168.1.1 445 tcp microsoft-ds open
192.168.1.1 5431 tcp park-agent open
192.168.1.1 8080 tcp http-proxy open
192.168.1.1 9080 tcp glrpc filtered
192.168.1.1 32768 tcp filenet-tms open
msf5 >
Database Backend Commands
=========================
Command Description
------- -----------
analyze Analyze database information about a specific address or address range
db_connect Connect to an existing data service
db_disconnect Disconnect from the current data service
db_export Export a file containing the contents of the database
db_import Import a scan result file (filetype will be auto-detected)
db_nmap Executes nmap and records the output automatically
db_rebuild_cache Rebuilds the database-stored module cache (deprecated)
db_remove Remove the saved data service entry
db_save Save the current data service connection as the default to reconnect on startup
db_status Show the current data service status
hosts List all hosts in the database
loot List all loot in the database
notes List all notes in the database
services List all services in the database
vulns List all vulnerabilities in the database
workspace Switch between database workspaces