参考国光大佬的博客《macOS 下优雅的使用 Metasploit》https://www.sqlsec.com/2019/11/macmsf.html
问题一:安装msf后无法初始化数据库失败
Creating database at /Users/lmc/.msf4/db
Starting database at /Users/lmc/.msf4/db...failed
Creating database users
搜索了网上了其他文章后尝试进行初始化数据库和重新初始化数据库的操作
msf初始化数据库:msfdb init
如果出错使用:msfdb reinit
依然失败
[?] Would you like to init the webservice? (Not Required) [no]: yes
[?] Would you like to delete your existing data and configurations? []: yes
====================================================================
Running the 'init' command for the database:
Existing database found, attempting to start it
Starting database at /Users/lmc/.msf4/db...failed
====================================================================
====================================================================
Running the 'init' command for the webservice:
[?] Initial MSF web service account username? [lmc]: msf
[?] Initial MSF web service account password? (Leave blank for random password):
Generating SSL key and certificate for MSF web service
Attempting to start MSF web service...failed
[!] MSF web service failed and returned the following message:
No message returned.
Please see /Users/lmc/.msf4/logs/msf-ws.log for additional webservice details.
====================================================================
解决办法:端口被占用,重启
问题二:没有安装go或者go没有加入全局变量
没有安装go或者go没有加入全局变量时,启动ms能正常启动但有如下报错:
[!] The following modules could not be loaded!..\
[!] /opt/metasploit-framework/embedded/framework/modules/auxiliary/scanner/msmail/onprem_enum.go
[!] /opt/metasploit-framework/embedded/framework/modules/auxiliary/scanner/msmail/host_id.go
[!] /opt/metasploit-framework/embedded/framework/modules/auxiliary/scanner/msmail/exchange_enum.go
[!] Please see /Users/lmc/.msf4/logs/framework.log for details.
根据提示查看/Users/lmc/.msf4/logs/framework.log
,发现报错信息:
package metasploit/module is not in GOROOT (/usr/local/Cellar/go/1.16.6/libexec/src/metasploit/module)
安装go:
brew install go
加入全局变量:
export PATH=$PATH:/usr/local/bin/go
依然报错,输入:
go mod init
go env -w GO111MODULE=off
成功解决