windows 为什么 ping 在没有管理员权限的情况下也能工作?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7687401/
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
Why does ping work without administrator privileges?
提问by dom0
as you may know one is unable to create RAW sockets using Windows Socketswithout having administrative priviliges. The problem is, that I need to send ICMP messages, thus I need RAW sockets. The Problem: My program needs to run without administrative privileges.
您可能知道,如果没有管理权限,就无法使用Windows 套接字创建 RAW 套接字。问题是,我需要发送 ICMP 消息,因此我需要 RAW 套接字。问题:我的程序需要在没有管理权限的情况下运行。
That lead me to the question, how does the ping tool send ICMP messages w/o administrative privileges?
这让我想到了一个问题,ping 工具如何在没有管理权限的情况下发送 ICMP 消息?
回答by Remy Lebeau
Although ICMP uses RAW sockets (which require admin rights on Win2K and later), Microsoft circumvents its own security rules to allow its ICMP APIs to get through. As such, don't use RAW sockets directly to send your own ICMP ping messages. Use IcmpSendEcho()
and related functions instead.
尽管 ICMP 使用 RAW 套接字(在 Win2K 和更高版本上需要管理员权限),但 Microsoft 绕过了自己的安全规则以允许其 ICMP API 通过。因此,不要直接使用 RAW 套接字发送您自己的 ICMP ping 消息。使用IcmpSendEcho()
和相关函数代替。