Sending ECHO_REQUEST (pinging) with python

Jean-Paul Calderone exarkun at divmod.com
Mon Mar 26 11:06:30 EDT 2007


On Mon, 26 Mar 2007 16:50:33 +0200, Thomas Dybdahl Ahle <lobais at gmail.com> wrote:
>Den Mon, 26 Mar 2007 06:30:04 -0500 skrev Nick Craig-Wood:
>
>> Michael Bentley <michael at jedimindworks.com> wrote:
>>>  On Mar 26, 2007, at 1:30 AM, Thomas Dybdahl Ahle wrote:
>>> > It seems however that I have to be root to send those imcp packages,
>>> > but I guess there must be a workaround since I can easily use the
>>> > "ping" command as ordinary user.
>>>
>>>  The workaround your ping command is using btw, is probably running
>>>  suid root.
>>
>> Under linux the only priviledge you need is CAP_NET_RAW.  It is possible
>> to give this to a process - a bit of searching with google will show you
>> how!
>
>How, I did google, but I wasn't able to find any way to do this in
>python..

You need a sendmsg wrapper (there are several, none in the stdlib), then
you need a privileged process which is willing to give you the privilege.

It's pretty inconvenient.

Jean-Paul




More information about the Python-list mailing list