工具简介
wsrepl是一个专门为渗透测试而设计的交互式 websocket REPL。它提供了一个用于观察传入的 websocket 消息并发送新消息的界面,并提供了一个易于使用的框架来自动执行此通信。

工具特征
- 交互式发送和接收 websocket 消息
- 自定义标头、ping/pong 消息和其他参数
- 处理 SSL 验证和重新连接
- 用于自动化复杂交互场景的插件支持
- 完整的日志记录和消息历史记录
- 支持curl命令行参数,以便从开发人员工具或Burp Suite轻松入门(使用“Copy as Curl”菜单并替换curl为wsrepl)
安装使用
您可以使用 pip 下载并安装 wsrepl:
pip install wsrepl
启动wsrepl的基本命令如下:
wsrepl -u URL
将URL替换为您的目标websocket URL,例如:
wss://echo.websocket.org
有关更多选项和设置,可以使用 -h 或 –help 选项。
使用插件实现自动化
要自动化 websocket 通信,您可以通过扩展wsrepl 中的Plugin类来创建 Python 插件。该类允许您定义在 websocket 通信的不同阶段触发的各种钩子。
以下是如何定义插件的概述:
class MyPlugin(Plugin): # Messages that will be sent to the server on (re-)connect. messages = ["message1", "message2", "message3"] def init(self): # This method is called when the plugin is loaded. # Use it to set initial settings or generate self.messages dynamically. pass async def on_connect(self): # This method is called when the websocket connection is established. pass async def on_message_received(self, message: WSMessage): # This method is called when a message is received from the server. pass # ... Other hooks can be defined here.
请参阅Plugin类的源代码,了解可以使用的钩子的完整列表及其用途
示例插件
以下是向服务器发送预定义身份验证消息的插件示例:
from wsrepl import Pluginimport json class AuthPlugin(Plugin): def init(self): auth_message = { "messageType": "auth", "auth": { "user": "user-1234"", "password": "password-1234" } } self.messages = [json.dumps(auth_message)]
可以通过在运行 wsrepl 时指定它来使用该插件:
wsrepl -u URL -P auth_plugin.py
将URL替换为您的目标websocket URL,并将auth_plugin.py替换为包含插件的 Python 文件的路径。
docs/目录包含更多示例插件。
下载地址
https://github.com/doyensec/wsrepl
文章来源:Hack分享吧
黑白之道发布、转载的文章中所涉及的技术、思路和工具仅供以安全为目的的学习交流使用,任何人不得将其用于非法用途及盈利等目的,否则后果自行承担!
如侵权请私聊我们删文
END
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END














暂无评论内容