在 Linux 的 Windows 子系统上安装 mitmproxy (WSL)

Installing mitmproxy on Windows Subsystem for Linux (WSL)

我一直在使用 Fiddler 修改服务器发送的 HTTPS 响应,该响应由客户端的 POST 请求发起,工作正常。

Windows 上使用 Java 我想实施同样的中间人攻击,所以我正在寻找可以处理系统范围 HTTPS 流量的代码。将证书导入系统的信任库也是必要的,但我正在努力启动实际的 Java 代码。 mitmproxy for instance has a Windows installer but it does not ship the mitmproxy executable so it cannot be used。同样使用 WSL 我得到以下 Python 异常:

$ sudo apt-get -y install mitmproxy
[sudo] password for ubuntu:
Reading package lists... Done
Building dependency tree
Reading state information... Done
mitmproxy is already the newest version (2.0.2-3).
0 upgraded, 0 newly installed, 0 to remove and 106 not upgraded.
root@mypc:~$ mitmproxy --port 1080
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 574, in _build_master
    ws.require(__requires__)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 892, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 783, in resolve
    raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.ContextualVersionConflict: (urwid 2.0.1 (/usr/lib/python3/dist-packages), Requirement.parse('urwid<1.4,>=1.3.1'), {'mitmproxy'})

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/mitmproxy", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3088, in <module>
    @_call_aside
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3072, in _call_aside
    f(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3101, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 576, in _build_master
    return cls._build_from_requirements(__requires__)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 589, in _build_from_requirements
    dists = ws.resolve(reqs, Environment())
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 778, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'urwid<1.4,>=1.3.1' distribution was not found and is required by mitmproxy

LittleProxy-mitm's maven dependency causes a java.lang.NoClassDefFoundError: org/bouncycastle/util/Encodable.

我该如何解决这些问题,或者我还能使用什么来使用 Java 编程来捕获和修改任何系统范围的 HTTPS 流量?它只需要在 Windows.

上工作

pip3 installation guide 有效:

sudo apt install python3-pip && sudo pip3 install -U pip && sudo pip3 install mitmproxy

注意:此命令适用于Ubuntu

mitmproxy 的 Ubuntu 包尚未维护。 您有 3 个选项:

您可以按照 BullyWiiPlaza 的说明从 pip 安装它。

您可以从 https://mitmproxy.org/ 获得 linux 的已编译二进制文件。

或者您可以从 github 和 运行 下载源代码。