LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-18-2008, 08:49 AM   #1
anaki007
LQ Newbie
 
Registered: Jan 2008
Posts: 7

Rep: Reputation: 0
Standalone binary similiar to ifconfig?


Hi,

wondered if someone could perhaps assist

I am trying to find a standalone binary that i can execute from within php to query my servers mac address,

Reason is, i have a standalone app that was written to decrypt a file based on the servers mac addy, and then use the unencrypted data, i dont have access to the source so i can't change the way this works.

The only option i have is to obtain the mac addy on my server and then encrypt the file with the mac so my app can use it correctly, however i cannot seem to get perl scripts to run ifconfig, my host is a free host so i am very limited on some things.

Thanks in advance
 
Old 01-18-2008, 09:57 AM   #2
Emerson
LQ Guru
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~arch
Posts: 5,872

Rep: Reputation: Disabled
Welcome to LQ!

Since the MAC address is not going to change (hopefully) cant you just make up one? Or create a text file similar to ifconfig output and parse it instead of real infconfig output?
 
Old 01-18-2008, 03:21 PM   #3
anaki007
LQ Newbie
 
Registered: Jan 2008
Posts: 7

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Emerson View Post
Welcome to LQ!

Since the MAC address is not going to change (hopefully) cant you just make up one? Or create a text file similar to ifconfig output and parse it instead of real infconfig output?
Hi and thanks for your reply Emerson

The compiled app i want to use actually checks the real mac address itself, during one of its routines, so making one up won't be good enough as it will fail to decrypt, i believe it uses the server mac addy as an aes decrypt/encrypt key

This is also the reason i know it must be possible to query the real mac address, since this app does so
 
Old 01-18-2008, 03:44 PM   #4
Emerson
LQ Guru
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~arch
Posts: 5,872

Rep: Reputation: Disabled
OK, as I said MAC address hopefully won't change. Meaning you do not need to read it out every time using ifconfig. Don't make it up then, use the actual one. Just get it from a text file for instance.
 
Old 01-18-2008, 11:30 PM   #5
anaki007
LQ Newbie
 
Registered: Jan 2008
Posts: 7

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Emerson View Post
OK, as I said MAC address hopefully won't change. Meaning you do not need to read it out every time using ifconfig. Don't make it up then, use the actual one. Just get it from a text file for instance.
Thanks once more for your reply.

Yeah i see what you mean, only problem i have is obtaining the mac address, which is what i needed the standalone app for to begin with
 
Old 01-18-2008, 11:37 PM   #6
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 115Reputation: 115
<?php
echo exec('ifconfig');
?>

Might be necessary to specify full path to ifconfig. Also might be that server won't let you do that; that is a server administration issue.
 
Old 01-19-2008, 12:06 AM   #7
anaki007
LQ Newbie
 
Registered: Jan 2008
Posts: 7

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by jiml8 View Post
<?php
echo exec('ifconfig');
?>

Might be necessary to specify full path to ifconfig. Also might be that server won't let you do that; that is a server administration issue.
Thanks for your response.

Tried this and no output at all from the echo command, also tried /sbin/ifconfig, /usr/bin/ifconfig and /bin/ifconfig.

Is it possible to download ifconfig from somewhere, upload it via ftp and then exec it this way?
 
Old 01-19-2008, 01:15 AM   #8
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 115Reputation: 115
No response probably means the server has locked out external binaries or perhaps has whitelisted them. Typically, for instance, imagemagick will be available and usually if you do this:

<?php
echo exec('whoami');
">

you'll get a response (usually "apache").

Thing is that ifconfig could be dangerous to the server (security issue) so it and anything that might function like it commonly won't be allowed.
 
Old 01-19-2008, 01:32 AM   #9
anaki007
LQ Newbie
 
Registered: Jan 2008
Posts: 7

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by jiml8 View Post
No response probably means the server has locked out external binaries or perhaps has whitelisted them. Typically, for instance, imagemagick will be available and usually if you do this:

<?php
echo exec('whoami');
">

you'll get a response (usually "apache").

Thing is that ifconfig could be dangerous to the server (security issue) so it and anything that might function like it commonly won't be allowed.
I see, thanks for your input once more, i have just run whoami which returns my login username to the server.

I have an external ELF binary running on the server and i believe it is querying the mac address ok, its a shame i do not have the source to this custom written app, so i can remove this "security" feature it has, unfortunately i have lost contact with the code writer. Thus it is theoretically locked to my old host.

I also tried to find ifconfig via google so i could download, but no joy there either.

Last edited by anaki007; 01-19-2008 at 01:35 AM.
 
Old 01-19-2008, 12:48 PM   #10
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 115Reputation: 115
Actually, there is one thing I neglected.

the form:

<?php
exec('ifconfig',$output,$rtncode);
echo var_dump($output);
?>

might give you something. If $output is specified, it is an array returned with all the contents (every line) of output from the command that is executed. I don't think this will work since the simpler form didn't, but you might want to look at it.
 
Old 01-19-2008, 01:48 PM   #11
anaki007
LQ Newbie
 
Registered: Jan 2008
Posts: 7

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by jiml8 View Post
Actually, there is one thing I neglected.

the form:

<?php
exec('ifconfig',$output,$rtncode);
echo var_dump($output);
?>

might give you something. If $output is specified, it is an array returned with all the contents (every line) of output from the command that is executed. I don't think this will work since the simpler form didn't, but you might want to look at it.
Hi jiml8,

Reply much appreciated once again

$output returns array(0) { }
$rtncode returns int(127)

im guessing thats not a good sign.

also tried this

$command="ifconfig";
$output=shell_exec($command." 2>&1");
print "<pre>$output</pre>\n";

This prints

sh: line 1: ifconfig: command not found

Last edited by anaki007; 01-19-2008 at 02:10 PM.
 
Old 01-19-2008, 05:21 PM   #12
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 115Reputation: 115
well, you are working on the right track - if the server will let you do it at all. It doesn't appear that it will, but you might try shell_exec with the full path.
 
Old 01-19-2008, 06:13 PM   #13
dive
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Slackware
Posts: 3,232

Rep: Reputation: 299Reputation: 299Reputation: 299
Have you tried running 'which ifconfig' to see where it is installed, then putting full path?
 
Old 01-22-2008, 01:41 PM   #14
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 115Reputation: 115
as a followup, I am having a similar problem myself. Maybe if my question is answered, the answer will help you too.

See here.
 
Old 01-23-2008, 03:02 AM   #15
anaki007
LQ Newbie
 
Registered: Jan 2008
Posts: 7

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by jiml8 View Post
as a followup, I am having a similar problem myself. Maybe if my question is answered, the answer will help you too.

See here.
Thanks for the info jiml8, hope we both get a solution on this.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Program similiar to dameware phatbastard Linux - Software 6 09-19-2012 04:25 PM
connecting /sbin/ifconfig to bash command ifconfig flammable2 Fedora 4 11-12-2005 08:58 AM
Similiar to MAYA zenchicken Linux - Software 4 09-29-2005 11:45 PM
Slackware 10.1 Problems and similiar stuff Mr-Sale Slackware 17 07-22-2005 07:25 AM
anyone know that C forum that was setup similiar .. purpleburple Programming 2 09-30-2002 05:53 PM


All times are GMT -5. The time now is 08:41 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration