如何更改进程的套接字连接
一个进程正在连接到某个 ip 或域,但我不知道它是什么。 该进程无法连接到服务器。 我如何找到并更改它?
A process is connecting to a certain ip or domain, but I do not know what it is. The process can't connect to the server. How do I find and change it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
TCPView 和 netstat 最适合已建立的连接,这不是原始发布者的立场。
执行此任务的更好工具是数据包嗅探器,它可以观察连接尝试。 我推荐 Wireshark,它适用于所有主要平台。
详细信息:
如果您在没有大量其他网络活动的计算机上足够快地执行最后一步,则您将只捕获一个数据包。 否则,您将不得不翻阅列表才能找到您想要的。 该数据包将显示程序尝试使用的 TCP 端口。
TCPView and netstat work best for connections already established, which isn't the original poster's position.
A better tool for this task is a packet sniffer, which can observe the connection attempt. I recommend Wireshark, which is available for all major platforms.
Details:
If you do the last step fast enough on a machine without a lot of other network activity, you will have only one captured packet. Otherwise, you'll have to dig through a list to find the one you want. This packet will show the TCP port the program is trying to use.
在 cmd 提示符下键入 netstat 以查看活动进程正在使用哪些端口。 除此之外,您无法更改过程所使用的连接端口(除非您显然构建了应用程序)
Type netstat at the cmd prompt to see what ports are being used by active processes. Aside from that, you can't change the port being used by the proc to connect (unless you built the app obviously)
TCPView 是一个不错的小实用程序,它将显示所有打开的连接和本地计算机上的端点。
如果程序使用 DNS 名称(例如 example.com)进行连接,则可以使用主机文件 (c:\windows\system32\drivers\etc\hosts) 将该名称映射到不同的 IP 地址。
如果您的意思是以编程方式重定向连接,那就要复杂得多。 你不会写恶意软件吧?
TCPView is a nice little utility that will show you all the open connections and endpoints on the local machine.
If the program is connecting using a DNS name (e.g., example.com), you can use the hosts file (c:\windows\system32\drivers\etc\hosts) to make that name map to a different IP address.
If you mean redirect the connection programmatically, that is a lot more complicated. You're not writing malware, are you?