Skip to content

Instantly share code, notes, and snippets.

@Marcelektro
Last active January 12, 2024 17:09
Show Gist options
  • Save Marcelektro/771d4cccbf7499ad67e6d3807410b10a to your computer and use it in GitHub Desktop.
Save Marcelektro/771d4cccbf7499ad67e6d3807410b10a to your computer and use it in GitHub Desktop.
A script for mitmproxy making old rocket.chat servers work with newer client apps (the "Name is running an unsupported version of Rocket.Chat" screen)
import json
from mitmproxy import http
# A script for Mitmproxy to make RocketChat client apps always work with old server versions.
# by Marcelektro
API_VERSION_URL = "https://your-rocket-chat/api/info"
def response(flow: http.HTTPFlow) -> None:
# print(f"pretty_url: {flow.request.pretty_url}")
if flow.request.pretty_url == API_VERSION_URL:
flow.intercept()
responseText = flow.response.text
try:
responseJson = json.loads(responseText)
except json.JSONDecodeError as error:
print("Failed to decode response: ", error)
flow.resume()
return
# Set 'version' in response json to null.
# It somehow works lol
responseJson['version'] = None
flow.response.set_text(json.dumps(responseJson))
flow.resume()
print("Intercepted /api/info.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment