前景需要:
msf框架提供了python的接口,并且网上有好多以Python写的渗透测试代码,尤其是exploit-da等漏洞库中,可不可以把网上的python代码稍稍改动一下放到msf中使用呢(假如根据同一套的逻辑重写一个的话,不仅要对ruby有一些理解,而且要费事的重写)?
一、想直接将python-poc加入msf框架中的话需要用特定的格式写python(from metasploit import module和metadata中要给出这个modul的type,因为支持的模板可能就那么几种,模板在/usr/share/metasploit-framework/lib/msf/core/modules/external/templates中),想打印出东西的话得用logging模块,这里不支持print语句;
二、写好python-poc(test.py)之后将其放在/root/.msf4/modules/下面,你的python是哪种类型的module(例’type’: ‘single_scanner’,在/usr/share/metasploit-framework/lib/msf/core/modules/external/templates找到相应的模板查看,例如single_scannerr的模板中有include Msf::Auxiliary::Scanner)那么你需要在/root/.msf4/modules/下面再创建一个auxiliary/scanner目录,并将python-poc放到里面;
三、启动msfconsole
四、加载所有的模块(运行reload_all命令)
五、如果将exploit-db里面的rb加载到msf中是相同流程;
六、github上的帮助文档链接:
扩展python)https://github.com/rapid7/metasploit-framework/wiki/Writing-External-Python-Modules
其他)https://github.com/rapid7/metasploit-framework/wiki/
七:例子:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# standard modules
import logging
# extra modules
dependencies_missing = False
try:
import requests
except ImportError:
dependencies_missing = True
from metasploit import module
metadata