打赏

基于msfrpcd服务编写python的自动测试框架

msprpc 服务:  metasploit 提供的rpc调用接口 

参考 https://docs.rapid7.com/metasploit/rpc-api/

启动服务 

在msfrpcd目录下运行

./msfrpcd -U username -P passwd      
或者 运行msfconsole 在内部控制台 运行
msf5 > load msgrpc ServerHost=0.0.0.0 ServerPort=55553  -U username  -P passwd 
各个参数含义
-P <opt> - The password to access msfrpcd.
-S - Enables or disables SSL on the RPC socket. Set this value to true or false. SSL is on by default. 默认是有ssl的
-U <opt> - The username to access msfrpcd.
-a <opt> - The address msfrpcd runs on.
-p <opt> - The port the msfrpc listens on. The default port is 55553.

python 链接msf使用第三方库pymetasploit3

msfclient=MsfRpcClient(host, username,port,ssl)

 

使用这个库碰到的问题

1. 使用pip 安装库后一直连接不成功 ,原因 内部依赖包 msgpack,该包没有被依赖安装 导致一直编码不成功,手动安装后成功

2. 运行任务设置参数不能成功,比如需要设置payload的参数,会返回没有这个参数的错误 ,解决方案:

直接调用call函数 如

msfclient.call('module.execute', [jobtype, jobname, joboption])
 msfclient.call('module.execute', ['exploit', 'multi/handler', {
            'LHOST': '0.0.0.0',
            'LPORT': 4444,
            'PAYLOAD': 'linux/x86/meterpreter/reverse_tcp'
        }])

 

 

 

posted @ 2021-02-03 16:20  skycandy  阅读(788)  评论(0编辑  收藏  举报