工具简介
-
交互式发送和接收 websocket 消息 -
自定义标头、ping/pong 消息和其他参数 -
处理 SSL 验证和重新连接 -
用于自动化复杂交互场景的插件支持 -
完整的日志记录和消息历史记录 -
支持curl命令行参数,以便从开发人员工具或Burp Suite轻松入门(使用“Copy as Curl”菜单并替换curl为wsrepl)
pip install wsrepl
wsrepl -u URL
wss://echo.websocket.org
要自动化 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.
示例插件
以下是向服务器发送预定义身份验证消息的插件示例:
from wsrepl import Plugin
import 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 -u URL -P auth_plugin.py
将URL替换为您的目标websocket URL,并将auth_plugin.py替换为包含插件的 Python 文件的路径。
原文始发于微信公众号(Hack分享吧):渗透测试人员的Websocket REPL
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论