Why does ping work without administrator privileges?
Asked Answered
B

1

14

as you may know one is unable to create RAW sockets using Windows Sockets without 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.

That lead me to the question, how does the ping tool send ICMP messages w/o administrative privileges?

Blemish answered 7/10, 2011 at 12:41 Comment(6)
Try making a system call to ping [hostname] within your application - I don't think that needs administrative privileges. Also, what have you tried, and if it's failing, what's the error message?Attalanta
I'm not sure it does work without admin privileges. I've previously had ping come back with some kind of "access denied" error message in Vista. My Win7 doesn't, but I have UAC turned off, so my current situation may be atypical.Cohbert
@normalocity: I don't need ping, I need some other ICMP messages. Thats why I want to know, how ping is able to send ICMP w/o admin rights... ;)Blemish
@Marcelo Cantos: Ping definitivly works w/o adminBlemish
Isn't this what IcmpSendEcho() is for?Neral
@Luke: Ow man... I can't believe there's a dedicated API function just for that. But yeah, you are right, that must be how it works. Good catch really.Jaggery
N
16

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.

Normalize answered 7/10, 2011 at 18:3 Comment(2)
@Remy Lebeau In which unit or wrapper is IcmpSendEcho implemented?Teacart
@user1580348: if you read the documentation, you will see that it is an exported function in Icmp.dll (Win2K) and Iphlpapi.dll (XP and later).Normalize

© 2022 - 2024 — McMap. All rights reserved.