The windows network share cannot be accessed in local mode
Problem Description
After the local mode is enabled, the windows network share cannot be accessed
Steps to reproduce the behavior:
- -m local start local mode
- Access a 10.26.18.4 windows network share
- there is no any response
System Information
Mitmproxy: 10.3.1 binary Python: 3.12.3 OpenSSL: OpenSSL 3.2.2 4 Jun 2024 Platform: Windows-11-10.0.22631-SP0
Use the wireshark to capture packets:
I ran into a similar problem and my workaround was editing the WinDivert filter (on mitmproxy_rs) to exclude tcp port 445
I suspect I am seeing a very similar problem with SSH in local mode and I think the problem is in addons.next_layer
# 5b) Check for raw tcp mode.
very_likely_http = context.client.alpn in HTTP_ALPNS
probably_no_http = not very_likely_http and (
# the first three bytes should be the HTTP verb, so A-Za-z is expected.
len(data_client) < 3
or not data_client[:3].isalpha()
# a server greeting would be uncharacteristic.
or data_server
)
if ctx.options.rawtcp and probably_no_http:
return layers.TCPLayer(context)
# 5c) Assume HTTP by default.
return layers.HttpLayer(context, HTTPMode.transparent)
For reasons that I am not quite familiar enough with the code base, for SSH, data_server is empty even though SSH definitely has a server greeting
You can work around by explicitly including your file server in tcp_hosts option which is probably easier than changing the windivert filter, but local mode probably needs a fix here
@niconorsk: thanks for the pointer! Fixed in https://github.com/mitmproxy/mitmproxy/pull/7041. :)