命名管道(Named Pipes)在 Windows 上广泛用于进程间通信。它们被许多应用程序使用,包括 Windows 远程过程调用(RPC)。此工具旨在让安全研究人员和渗透测试人员能够对使用命名管道的应用程序进行安全评估。
本项目灵感来源于 CyberArk Labs 出色的 MITM_Intercept 项目。
该工具创建了一个管道客户端/服务器代理,并附带 WebSocket 客户端/服务器桥接。WebSocket 客户端通过 HTTP 代理(如 Burp)连接到 WebSocket 服务器。
重要提示: 此工具使用 win32 api 创建命名管道,因此仅适用于 Windows。目前,它需要在目标管道服务器和 HTTP 代理所在的同一台机器上运行。我可能会添加使用远程代理的选项,以及转发到远程管道服务器的选项,但该工具仍必须在 Windows 上运行。
流程图:

理解这一点很重要:该工具通过创建独立的管道服务器实例来工作,这些实例与目标服务器应用程序创建的实例相互独立,从而使目标客户端应用程序连接到这些代理实例。这意味着以下几点:
从上述几点可以看出,使用此工具可能会改变目标应用程序的行为。请记住,此工具主要用于安全测试,请勿在生产系统中使用。
该工具已在 Python 3.13.7 版本下测试。设置:
python -m venv .venv
.venv\Scripts\activate.bat
pip install -r requirements.txt
usage: pipe_intercept.py [-h] --pipe-name PIPE_NAME [--ws-port WS_PORT] [--http-proxy-port HTTP_PROXY_PORT] [--log-level {CRITICAL,ERROR,WARNING,INFO,DEBUG}]
options:
-h, --help show this help message and exit
--pipe-name PIPE_NAME
The name of the pipe to be intercepted
--ws-port WS_PORT An available port number for the internal WebSocket server (if not specified, a random port will be used)
--http-proxy-port HTTP_PROXY_PORT
The port number of the HTTP proxy (if not specified, the default is 8080)
--log-level {CRITICAL,ERROR,WARNING,INFO,DEBUG}
Log level (if not specified, the default is INFO)
在根目录(pipe-intercept)中运行:
pytest
Windows 上的 Docker 使用命名管道在客户端和 docker 服务之间进行通信。管道名称为 "\\.\pipe\docker_engine"。让我们看看如何拦截这种通信。首先,我们运行该工具:
C:\pipe-intercept>python pipe_intercept.py --pipe-name docker_engine
INFO:websockets.server:server listening on 127.0.0.1:12037
现在我们可以启动 Burp,并从另一个 shell 创建一个 Windows 容器:
C:\pipe-intercept>docker run -it --name win mcr.microsoft.com/windows:1809-amd64 cmd
Microsoft Windows [Version 10.0.17763.2803]
(c) 2018 Microsoft Corporation. All rights reserved.
C:\>dir
Volume in drive C has no label.
Volume Serial Number is 5C09-8FFA
Directory of C:\
05/07/2020 06:16 AM 5,510 License.txt
04/04/2022 02:57 PM <DIR> PerfLogs
04/04/2022 04:13 PM <DIR> Program Files
04/04/2022 02:57 PM <DIR> Program Files (x86)
04/04/2022 04:17 PM <DIR> Users
04/04/2022 04:13 PM <DIR> Windows
1 File(s) 5,510 bytes
5 Dir(s) 21,188,812,800 bytes free
C:\>
现在,如果我们在 Burp 中打开 WebSocket 选项卡,就可以看到通信内容:

我们还可以打开拦截功能并修改消息:

Microsoft Windows [Version 10.0.17763.2803]
(c) 2018 Microsoft Corporation. All rights reserved.
C:\>dir
Volume in drive C has no label.
Volume Serial Number is 5C09-8FFA
Directory of C:\
05/07/2020 06:16 AM 5,510 License.txt
04/04/2022 02:57 PM <DIR> PerfLogs
04/04/2022 04:13 PM <DIR> Modified Name
04/04/2022 02:57 PM <DIR> Program Files (x86)
04/04/2022 04:17 PM <DIR> Users
04/04/2022 04:13 PM <DIR> Windows
1 File(s) 5,510 bytes
5 Dir(s) 21,188,288,512 bytes free
C:\>