mitmproxy icon indicating copy to clipboard operation
mitmproxy copied to clipboard

The windows network share cannot be accessed in local mode

Open linuxlin365 opened this issue 1 year ago • 3 comments

Problem Description

After the local mode is enabled, the windows network share cannot be accessed

Steps to reproduce the behavior:

  1. -m local start local mode
  2. Access a 10.26.18.4 windows network share
  3. 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:

2159ef2f5e144dfd6d75942af8124da

linuxlin365 avatar Jul 15 '24 02:07 linuxlin365

I ran into a similar problem and my workaround was editing the WinDivert filter (on mitmproxy_rs) to exclude tcp port 445

Osherz5 avatar Jul 16 '24 12:07 Osherz5

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 avatar Jul 25 '24 05:07 niconorsk

@niconorsk: thanks for the pointer! Fixed in https://github.com/mitmproxy/mitmproxy/pull/7041. :)

mhils avatar Jul 25 '24 10:07 mhils