?
Solved

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

Posted on 2009-12-21
19
Medium Priority
?
1,801 Views
Last Modified: 2013-12-13
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?
0
Comment
Question by:abrothman
  • 7
  • 6
  • 3
  • +1
17 Comments
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 26100683
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).
0
 

Author Comment

by:abrothman
ID: 26112586
In the world today, I find it hard to believe this information can't be captured using a scripting language like PHP.
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 26113571
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

0
Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

 
LVL 11

Expert Comment

by:VanHackman
ID: 26121080

Witch O.S are the PCs running?
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 26128027
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
0
 
LVL 11

Expert Comment

by:VanHackman
ID: 26128284

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

0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 26128371
Can't wait to see the PHP script that can get the free space off my hard drive!
0
 
LVL 11

Expert Comment

by:VanHackman
ID: 26128392
Mind wide open. ;)
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 26128413
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!
0
 
LVL 11

Expert Comment

by:VanHackman
ID: 26129299

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





0
 
LVL 11

Expert Comment

by:VanHackman
ID: 26129327
@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
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 26132339
@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
0
 
LVL 11

Expert Comment

by:VanHackman
ID: 26135111

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!!
0
 

Author Comment

by:abrothman
ID: 26140822
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.
0
 
LVL 1

Expert Comment

by:asbaum
ID: 26142293
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
0
 
LVL 11

Accepted Solution

by:
VanHackman earned 500 total points
ID: 26147661
I agree with asbaum, because I think that say:

"This thread went completely in the wrong direction where the two posters trying to help ended up argueing with one another about the points"

Is a wrong opinion, Why? Because Ray and me were arguing about the solution to the problem.
NO ABOUT POINTS.

I think that the solution is here:

http://www.experts-exchange.com/Software/Server_Software/File_Servers/Active_Directory/Q_24995527.html?cid=1573#26128284

and here:

http://www.experts-exchange.com/Software/Server_Software/File_Servers/Active_Directory/Q_24995527.html?cid=1573#26129299

Any way, I don't gonna fight for it, I am pretty happy just knowing that I found the solution for this very interesting problem.

Best wishes to everybody. ~VanHackman
0
 

Author Closing Comment

by:abrothman
ID: 31668754
Based on being forced to accept a solution that didn't work anyways, but atleast Vanhackman did give the most complete replies.
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Group policies can be applied selectively to specific devices with the help of groups. Utilising this, it is possible to phase-in group policies, over a period of time, by randomly adding non-members user or computers at a set interval, to a group f…
Compliance and data security require steps be taken to prevent unauthorized users from copying data.  Here's one method to prevent data theft via USB drives (and writable optical media).
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.
Suggested Courses
Course of the Month15 days, 9 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question