Link to home
Start Free TrialLog in
Avatar of abrothman
abrothman

asked on

PHP code to display internal IP, sub and gateway and other PC info

I am looking for a script that when a person on our internal network goes to a webpage the webpage will spitout information like the program BGinfo. Info I would like to display on the webpage is all internal values examples in brackets.

HostName: (PCName)
IP Address: (192.168.1.10)
Subnet Mask: (255.255.255.0)
Default Gateway: (192.168.1.1)
Logon Server: (ServerName)
Logon Domain: (DomainName)
User Name: (joesmith)
CPU Speed:Dual 2.40 GHz Core2 Duo
Free Space: C:\150.99GB NTFS
Memory: 2973 MB

Is this possible to pull this much data from a PC just visiting a webpage?
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

No, it is not possible to pull that.  You can get some of it via PHP, but for most of it you would need to place an application on the PC and have the client run the application to upload the information to the server.

The IP address is certainly available, possibly the user name (depends on your local apps).
Avatar of abrothman
abrothman

ASKER

In the world today, I find it hard to believe this information can't be captured using a scripting language like PHP.
Let me try to make this point again...
"for most of it you would need to place an application on the PC and have the client run the application"

Security issues abound when you have a server accessing a client machine.  That is why there are firewalls.  A PC placed on the internet without a firewall has about 15 minutes to live before the evilbots find it and destroy it.  The do their mischief by placing applications on the PC and causing it to run the application.  For what are obvious reasons, the PC user community is very careful about this sort of stuff.

"hard to believe this information can't be captured using a scripting language"
Take away the firewalls and you can get to the client machine.  Then you can get this information, and unfortunately you can also change the data on the client machine.  So on balance, the better solution is the firewall, and that means you simply cannot access certain things on client machines.  And if you find a way to access those things, there will be an army of security experts trying to close off access.

It's like trying to create a form with a prepopulated name of a file to be uploaded - it is not allowed because of the security exposure it creates.  The client, and only the client, gets to choose what files are sent from his machine to the internet.

If you want to see what is available to PHP, run this script and look near the bottom of the output at the environment variables, etc.
<?php phpinfo(); ?>

Open in new window


Witch O.S are the PCs running?
The OS of the PC can usually be inferred from the browser - in my case Windows XP - if you trust the browser to set it correctly.  Of course I could be a server running a CURL request, and they I could tell the PHP script anything I wanted, maybe pretending that I am Windows Explorer and referred by Google.  

$_SERVER["HTTP_USER_AGENT"] = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6';

http://php.net/manual/en/function.get-browser.php
http://www.siteware.ch/webresources/useragents/db.html

Best regards, ~Ray

Witch O.S are the PCs running?

@abrothman:

In each OS you will have a different set of Network commands that can help to get the information that you need , I mean, as you say that "a person on our internal network goes to a webpage"  I understood that the server running the script that pull the data will be in your internal network too.

So, if it is in this way is possible write a Php Script that use the the system() command to implement a "kind of shell pipeline" to get the information needed using the data about your visitors that you can get easily with php.  =)

Something difficult problems only need a little bit of imagination, and a good use of the resources available...

~VanHackman

Can't wait to see the PHP script that can get the free space off my hard drive!
Mind wide open. ;)
Yeah, I would really love to see how that is done.  I have absolutely no idea how a PHP script running over HTTP could get that information from my PC.  I'm not exactly a slouch in PHP, but I don't know everything!

Look, like you didn't read my answer:

"In each OS you will have a different set of Network commands..."
"I understood that the server running the script that pull the data
   will be in your internal network too... "
'a Php Script that use the the system() command to implement a "kind of shell pipeline" to get the information needed..."

As you can see, I never said that a Php Script can do all the job by itselft. I said that A PHP SCRIPT USING THE SYSTEM() FUNCTION AND NETWORK COMMANDS CAN GET INFORMATION LIKE THE PROVIDED.

Do you still not believing me?...

Ok, I'll give you a cup of humility buddy:

http://www.robvanderwoude.com/ntadmincommands.php
http://www.computerhope.com/issues/ch000444.htm


"Can't wait to see the PHP script that can get the free space off my hard drive!"
"Yeah, I would really love to see how that is done."

And surprise, surprise... :

http://www.robvanderwoude.com/ntadmincommands.php#Cmd18

JUST TO REMARK IT:

"I need an up-to-date list of disk space usage for all servers, on my desk in 5 minutes"  Sounds familiar?  With (native) Windows XP Professional or Windows Server 2003 commands: FOR /F %%A IN (servers.txt) DO (        WMIC /Node:%%A LogicalDisk Where DriveType="3" Get DeviceID,FileSystem,FreeSpace,Size /Format:csv | MORE /E +2 >> SRVSPACE.CSV    )  The only prerequisites are:  SRVSPACE.CSV should not exist or be empty,     a list of server names in a file named SERVERS.TXT, one server name on each line,     and WMIC.EXE, which is native in Windows XP Professional, Windows Server 2003 and Vista. " 

If you get it, now you must know that is possible get the information about free disk space, using a Php Script, the system() function and some of imagination under the conditions that I already said...

Finally : " I'm not exactly a slouch in PHP, but I don't know everything!"

I definitely agree with you. you look like a smart man with a lot of expertise in Php. But sometimes you have a very closed mind. Remember, If you can't see a creative solution, it doesn't mean that something is impossible.

My best wishes to you.


~VanHackman





@abrothman:

I almost forgot!.

Get the CPU, Computer System, and Logon info is possible too.

With the same WMIC tool:

http://ss64.com/nt/wmic.html

So, I think that with this command a php script and the system() function, your work is done ...

Here more info:

http://ss64.com/nt/wmic.html

My best wishes to you and hope that my answer helps you.

~VanHackman
@VanHackman: Thanks for your long explanation.  IIRC, the original question was, "...when a person on our internal network goes to a webpage the webpage will spitout information like the program BGinfo..."

What I think you should do to earn points for this question is post a link to the web page that acquires that data and echoes it on the browser screen.  I think "echos on the browser screen" is what the OP means by "spitout information"

Best regards, ~Ray

Jaja, It's unbelievable....

As you said to someone here in EE: I am not getting payed to answer questions, I am here to retrieve something to the community, the Experts post links, give guides to solve problems and don't provide full code solutions, if someone need a full code solution, well, that is a Freelancer Job...

Anyway, with the information that I provided, any person with good programing skills in Php and  batch scripting, can write a web page that get the information required under a local network environment with the S.O. specified (Do you remember that my first question was about witch O.S are the PCs running?) so...

I think that I already prove that is possible accomplish the target, and possible get the information (Do you remember that you mock to me, when I said that it is possible?) and of curse made echos in the browser screen, put it in a PDF or Do what ever do you want to do with the information... Ergo... My Work here is done.

@abrothman: If you read the links that I provide about Windows's network command and about the system() function in Php, you will be able to write a script that get the information that you need. Just remember the script will work only if the web server is in your local network and the others PCs access it through the LAN.

Bye!!
I found a completely different solution which works using VB and PHP combined. Thanks for posting your comments sorry it caused a fight between you two.
abrothman, you note "I found a completely different solution which works using VB and PHP combined".  Do you mind "sharing" the solution you found?  I was looking for exactly what you were looking for when I came upon this thread.

Please post, so that we can 1) all benefit from your find and 2) we can all decide if what you found is any more useful then the time these posters took to offer you a solution.

I vote for:

If what abrothman found is uniquely different than what VanHackman and Ray_Paseur posted, he can keep the points but only if he shows the links and related info that he found.

Otherwise, the 250 points are split evenly between VanHackman and Ray_Paseur
ASKER CERTIFIED SOLUTION
Avatar of VanHackman
VanHackman
Flag of El Salvador image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Based on being forced to accept a solution that didn't work anyways, but atleast Vanhackman did give the most complete replies.