Re: Find MAC Address in PHP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Em Terça 24 Abril 2007 10:49, Tijnema ! escreveu:
> On 4/24/07, Davi <davividal@xxxxxxxxxxxxxxxx> wrote:
> > How you'll type your root pwd? =P
>
> Something with the proc_* functions as you need bi-directional streams
> (input/output). Something like this: (not tested, partly copied form
> example 1926)
> <?php
>
> $root_pwd="123456";
>
> $descriptorspec = array(
>    0 => array("pipe", "r"),  // stdin is a pipe that the child will read
> from 1 => array("pipe", "w"),  // stdout is a pipe that the child will
> write to 2 => array("file", "/tmp/error-output.txt", "a") // stderr is a
> file to write to
> );
>
> $process = proc_open('su - -c arp', $descriptorspec, $pipes);
>
> if (is_resource($process)) {
>     fwrite($pipes[0], $root_pwd."\r\n");
>     fclose($pipes[0]);
>
>     echo stream_get_contents($pipes[1]);
>     fclose($pipes[1]);
>
>     proc_close($process);
> }
> ?>
>

sounds cool... =]
I'll search for it...

> > > > > If not, you can't do that.
> > > >
> > > > And with a shell-script outputting the MAC to a .txt temp file,
> > > > reading it from the PHP script?
> >
> > #!/bin/bash
> >
> > if [ ! $# -eq 1 ]; then
> >        echo "Usage: $0 target_ip";
> >        exit;
> > fi;
> >
> > MAC_ADDR=`sudo arp | grep $1 | cut -d" " -f18`
> >
> > echo ${MAC_ADDR} > /your/html/pub/dir/mac_temp.txt
>
> Where's the root password? I guess you need it too when using sudo?

trick... =P
correctly configured, sudo doesn't need pwd for some commands...

see Ubuntu... ;)

>
> > <?php
> >
> > $mac=file("mac_temp.txt");
> >
> > foreach($mac_addr as $mac){
> >        echo $mac_addr;
> > }
> >
> > ?>
>
> Uhm, this is really weird code, i guess you meant this:
>
> <?php
>
> $mac=file("mac_temp.txt");
>
> foreach($mac as $mac_addr){
>        echo $mac_addr;
> }
>
> ?>
>

Yes... Sorry! =]

> But well, when you have root access to the server, it might be better
> to just cheat like i did, and make arp available to the PHP user :)

I'm some paranoic... =X
I wouldn't do it... =P


-- 
Davi Vidal
davividal@xxxxxxxxxxxxxxxx
davividal@xxxxxxxxx
--
"Religion, ideology, resources, land,
spite, love or "just because"...
No matter how pathetic the reason,
it's enough to start a war. "

Attachment: pgp6zyaa8OcHx.pgp
Description: PGP signature


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux