如何向 Metasploit 中增加自定义 exploit 模块?
tonghuaroot.com ;网络安全爱好者;不是黑客;
3 人
赞同了该文章
0x00 前言
在搞站的过程中,需要使用 Metasploit 自定义的exploit模块,我的Metasploit部署在公网的Linux上。网上公开的中文资料中,都没能解决我的问题。在网上搜索的资料中,都是向/usr/share/metasploit-framework/modules/exploits/目录下增加自定义模块,然而并不能解决我的问题。
![](https://i-blog.csdnimg.cn/blog_migrate/bbf5c7fc06c3f47345a2a4ee7b7c83da.png)
![](https://i-blog.csdnimg.cn/blog_migrate/cd190c02e05bbdbc4cca0ee20faca336.png)
我的系统不存在这个目录,whereis下也没有翻到。
![](https://i-blog.csdnimg.cn/blog_migrate/352d4d65e53dea096f95c742bac40125.png)
![](https://i-blog.csdnimg.cn/blog_migrate/5ca5f7369011d09d7e27f7ff9c82fd3f.png)
当然最终肯定是解决了,这里记录下我的解决过程。
0x01 基础环境
Ubuntu 16.04.3 LTS
Metasploit 4.16.29-dev-
0x02 解决方法
解决这个问题的思路就是在$HOME/.msf4目录下创建其相应的存储位置的目录结构。
第1步:创建目录,进入到创建的目录下
mkdir -p $HOME/.msf4/modules/exploits
mkdir -p $HOME/.msf4/modules/exploits/test
cd $HOME/.msf4/modules/exploits/test
![](https://i-blog.csdnimg.cn/blog_migrate/a6a1b9af1035d69a5975deedc10e5a4d.png)
![](https://i-blog.csdnimg.cn/blog_migrate/2bba5e60f06ff4687d2ff009837b4608.png)
第2步:将自定义的exploit导入到相应的目录下
![](https://i-blog.csdnimg.cn/blog_migrate/d3b2023a08a6ab9ca2a7ce3c87c7de6b.png)
![](https://i-blog.csdnimg.cn/blog_migrate/91be6799e65b4e1860273cda72f6df69.png)
第3步:启动Metasploit,并重新加载reload_all
msfconsloe
reload__all
![](https://i-blog.csdnimg.cn/blog_migrate/731f67175e48f09b84d9c2b524cb9c1e.png)
![](https://i-blog.csdnimg.cn/blog_migrate/8c51c9d53de041ef1980c3f2817cf298.png)
reload_all后,可以看到,成功加载,问题得到解决!!!
![](https://i-blog.csdnimg.cn/blog_migrate/64912c9cf60654bf0d9218e444de73cf.png)
![](https://i-blog.csdnimg.cn/blog_migrate/ff999bd79089bf202ba79c2b35d3c001.png)
0x03 exploit 模块使用说明
这里再搭车记录下exploit模块的使用过程。
第1步:查看exploit支持的选项
拿到一个新的exploit,最重要的就是查看下其支持的选项
show options
![](https://i-blog.csdnimg.cn/blog_migrate/2c98cfa4010546b1f73f83af89baefde.png)
![](https://i-blog.csdnimg.cn/blog_migrate/5f5ec0f6eb8fa50f65f0aa771ce04ac3.png)
第2步:设置RHOST
根据支持选项的提示,我们输入目标RHOST
set RHOST xxx.xxx.xxx.xxx
![](https://i-blog.csdnimg.cn/blog_migrate/dfacc7d2207f1ff6e6ef0323b10a6823.png)
![](https://i-blog.csdnimg.cn/blog_migrate/e77fb75dfafcb9493e07fbbcbcd062fb.png)
第3步:exploit!!!
![](https://i-blog.csdnimg.cn/blog_migrate/ca2e1aca742fcbe53664b843b2ab99c4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/0a7fc59efaabdc39dc0ce93d1797c1f2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/af711f4548cde02b4e85d661bf583196.png)