如何使用 NetCat for Windows 将二进制文件发送到 TCP 连接?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2040817/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 07:02:22  来源:igfitidea点击:

How to use NetCat for Windows to send a binary file to a TCP connection?

windowsbinarytcpip-addressnetcat

提问by Lopper

If I want to transfer a binary file "binary.bin" (located in the same directory as NetCat) to IP address 127.0.0.1 port 1200 using TCP, how do I specify this using NetCatfor windows?

如果我想使用 TCP 将二进制文件“binary.bin”(与 NetCat 位于同一目录中)传输到 IP 地址 127.0.0.1 端口 1200,我如何使用NetCatfor windows指定它?

回答by Lopper

I found the solution. Its

我找到了解决方案。它的

nc 127.0.0.1 1200 < binary.bin

In addition, if the response needs to be saved then

此外,如果需要保存响应,则

nc 127.0.0.1 1200 < binary.bin > response.bin

回答by FalcoGer

If you want to send it from a linux distribution to anybody, including windows PCs you can do something like this:

如果您想将它从 linux 发行版发送给任何人,包括 Windows PC,您可以执行以下操作:

{ echo -ne "HTTP/1.0 200 OK\r\n\r\n"; cat path/to/your/file/binary.bin ; } | nc -l 1200

The receiving end then just needs to browse to your IP Address in his web browser and gets a prompt to download. Needless to say port 1200 needs to be forwarded if you're behind a router.

然后接收端只需要在他的网络浏览器中浏览到您的 IP 地址并得到下载提示。不用说,如果您在路由器后面,则需要转发端口 1200。