Fwd: [PECL-DEV] N
| From: | Daniel Brown | Date: | Sun, 11 Oct 2009 01:09:57 +0000 |
| Subject: | Fwd: [PECL-DEV] N | ||
| References: | 1 2 | Groups: | php.pecl.dev |
| Request: | Send a blank email to pecl-dev+get-6687@lists.php.net to get a copy of this message | ||
Forwarding to the list. Gmail mobile apparently doesn't have reply-all.
---------- Forwarded message ----------
From: Daniel Brown <parasane@gmail.com>
Date: Sat, 10 Oct 2009 21:06:02 -0400
Subject: Re: [PECL-DEV] N
To: Nicholas Williams <nicholas@dnscrawler.com>
I had actually written a PING, traceroute, netstat, whois, and finger
extension a couple of years ago. I'll see if I still have the source,
and if I do, you can have it to give you something with which to
start.
On 10/10/09, Nicholas Williams <nicholas@dnscrawler.com> wrote:
> I've come across the need for the ability to ping and traceroute without
> making use of an exec() call. I've thoroughly examined the source code
> for the Linux-native ping and traceroute, and believe this is something
> I could, theoretically, port to PHP.
>
> The problem I've come across in my research is two-fold:
>
> 1) In order to perform traceroutes, specifically, I need to be able to
> manipulate the actual raw IP headers at the top of each outgoing packet.
> Specifically, I need to be able to manipulate the time-to-live (TTL) for
> outgoing packets and inspect the contents of the headers of received
> packets. It doesn't appear as if using the SOCK_RAW option and the IP
> (raw) protocol flag (0) in socket_create actually gives me control over
> the IP headers for each packet. It is exhibiting behavior that is not
> the same as what you get from similar C code. The fact that sock_connect
> and/or sock_sendto absolutely require an IP address, even with SOCK_RAW
> and 0 used in sock_create, leads me to believe that the native PHP
> socket functions are still adding standard internet headers to the top
> of the packets I'm trying to send.
>
> 2) Using the SOCK_RAW option requires being root. This obviously doesn't
> lend itself to using this with a web interface or anything else, for
> that matter, that isn't run as root.
>
> So it occurred to me that perhaps a PECL extension to allow the sending
> and receiving of individual packets and (controlled, for security
> reasons) manipulation of their headers would perhaps solve my problems
> and allow me to utilize this new extension for implementing ping and
> traceroute natively. I'm sure this would solve my first problem.
> However, because I'm unfamiliar with the security restrictions placed on
> PHP running as an Apache module and in CLI, I don't know if this solves
> my problem of needing to be root to use raw packet sockets.
>
> Any insights and suggestions would be greatly appreciated. Can this be
> accomplished through some other means in PHP? Am I missing something or
> doing something wrong? Would a new PECL extension that enables the
> direct manipulation of packets and headers be possible and work for
> this? Or is this simply something that's going to be impossible to
> implement in PHP?
>
> Thanks in advance for any responses,
>
> Nick Williams
>
--
</Daniel P. Brown>
daniel.brown@parasane.net || danbrown@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Looking for hosting or dedicated servers? Ask me how we can fit your budget!
--
</Daniel P. Brown>
daniel.brown@parasane.net || danbrown@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Looking for hosting or dedicated servers? Ask me how we can fit your budget!