SourceFiles.org - Use the Source, Luke
Home | Register | News | Forums | Guide | MyLinks | Bookmark

Related Sites

Latest News
  General News
  Reviews
  Press Releases
  Software
  Hardware
  Security
  Tutorials
  Off Topic


Back to files

VNCTracker - 2006 Robert M. Cassell
Retrieve host info and format .vnc files for quick url link to Tight.VNC connections. http://sourceforge.net/projects/vnctracker

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. http://www.gnu.org/copyleft/gpl.html

Bundled software:
*feedcreator is released under the lgpl. lgpl.txt included. ####################################

DISCLAIMER
I am not a programmer. I am as Systems Administrator. If this breaks, I'm sorry. ;) There is NO WARRANTY other than your own skills as an admin + cards you are dealt. Other 'Roll-My-Own' apps could be released in the future...with this same disclaimer.

-Enjoy!

VNCTracker
What is it?

The premis of this tool is to keep track of mostly dynamic hosts on various dail-up accounts. Rather than call each user whenever I need a current IP for VNC, I have in place a url that when visited, updates the IP Address for that host. Apache/PHP can then build .vnc files for winvnc.exe or vncviewer to open during the 'Open/Save' dialog in my browser.

(watch for line wraps below!)
Have your user's pc visit your logip.php page like so:

http://vnc.mydomain.com/vnctracker/logip.php?hostname=robert&port=5900

The IP Address is retrieved with getenv('REMOTE_ADDR'); then the IP, PORT and HOSTNAME are inserted into the vnctracker database for viewing with showip.php

That link could be a batch file on Windows, a shell script in Linux or embedded into another app, which is my method. You could use wget (cross platform) to hit the logip.php page like so:

Linux (OSX too?):
wget -q "http://192.168.0.4/vnctracker/logip.php?hostname=testpc2&port=5956" >/dev/null

Windows
wget -q "http://192.168.0.4/vnctracker/logip.php?hostname=testpc&port=80" >NUL:

####################################
Requirements: typical stuff

HTTP Server [Apache]
PHP4 [others may work?]
MySQL [mysql Ver 14.7 Distrib 4.1.11, for mandrake-linux-gnu (i586)] bash [or some other eqiv shell] (might work with others?) grep [GNU grep 2.5.1]
gawk [GNU Awk 3.1.4]
sed [GNU sed version 4.1.4]
tac [for searching mail logs in reverse order] *Most apps are loose but these were in-use during development.

(optional)
RSS Reader [Sage FF plugin]
Sage [http://sage.mozdev.org/]

####################################
Install/Configuration:

First, extract/copy the vnctracker folder to some place accessible by your http server. /var/www/html/vnctracker seems reasonable and is assumed throughout.

  1. Edit the config.php file with the proper MySQL and other info. (check all of it!)
  2. Edit the top of update-hostips.sh at 'Start Basic Setup' with mysql info and if you changed the relative path to vnctracker, then adjust that accordingly also.
  3. Add to your httpd.conf or commonhttpd.conf file the following and restart httpd.

AddType application/vnc .vnc

4. Allow read access to your pop3/imap log from the httpd user (ie. apache).

5. Using the MySQL credentials from step 1, create the vnctracker MySQL database and

insert the included .sql schema.

mysql -u$db_user -p$db_pass $db_db <vnctracker.sql

        (for a default install)
        mysql -uvnctracker -pvnctracker vnctracker <vnctracker.sql

***6. *SKIP STEP 6. - HOSTS ARE NOW HANDLED VIA INDEX.PHP

Edit the 'userlist' file and put each username you want to track in there. One per line and they are case sensitive = usernames.

7. Use 'addhost.sh' to add hosts to the db from command line.

Usage: addhost.sh hostname phone contact-name connection os Like: addhost.sh testpc 555-555-1234 robert DSL W98

8. The last column in the results table is 'rm' and is used to remove a host

from the db. One click is all it takes. There is no confirmation!

9. Add host line now below main table. Use the usual format to add a new

new host. The date and time are provided.

10. RSS feeds. (I use SAGE) If you use the RSS feed, have your reader scan the

VNCTracker main 'showip.php' page or drag the RSS link on the footer to your reader. Clicking on the 'RSS link' link will run the 'Update from mail logs' script and clicking on each host will download/open the .vnc file. Hover your mouse over each host to get their basic details.

That should have you up and running. If not, then post your results here: http://sourceforge.net/forum/?group_id=162768 and we can figure out something.

####################################
Security:

External?
Not much (read: none) built into this. I use SSL and Apache's auth mod for access to VNCTracker, which seems like enough. Security is really a series of 'seems' but SSL and username/password are good enough...for me.

Internal?
Well - this could probably be very resource intensive for large userlists and long mail logs. I recently changed the behaviour of mail log searching and now use tac to search for the most recent (appended) login line. This should reduce the load and possibly the chances for laggy issues.

####################################
Performance:

I'm thinking a lot about that and may write this sorta seriously in perl or python, etc.. Not sure if it'll make that much diff. VNCTracker started out using tail to search the mail logs (intensive) but now it uses tac since the most recent logins are at the bottom of the log so we search for one hit and stop for each host.

Nothing really to complain about for me yet. I have this on a pretty loaded box (P4-3gz-1gb) and can scan the entire log file for 40+ usernames, update MySQL and build the .vnc files in 2.08 seconds. Not too shabby, IMHO. Just a refresh of the page with no mail log searching takes 0.191 seconds. Again, not too shabby. Those times were clocked using this method: http://www.totallyphp.co.uk/code/page_load_time.htm

Please use the sourceforge.net forums for comments: http://sourceforge.net/forum/?group_id=162768

####################################
Notes for viewing VNCTracker on Linux:

I've added a wrapper script for using these options.vnc files in Linux based browsers (vncviewerurl). I've tested this with Firefox 1.0.5(src) on Mandriva 2005le but it should work everywhere you can add an action for filetypes. vncviewerurl should be in your path for this to work.

In Firefox, it's in "Edit > Preferences > Downloads". When you first download a host.vnc file (probably unknown), Firefox should ask you what you want to do. Choose 'Open' and point the dialog to the vncviewerurl script provided in the vnctracker folder. This wrapper will strip the IP Address from the host.vnc file and launch "vncviewer $hostip", which should prompt you for a password, etc.. You might want to put vncviewerurl in your path somewhere like /usr/local/bin/ or similar. I will parse the options file for 'real' at some point but since I use the same options for every connect = fast and ugly, I haven't put any time into it yet.

If you use this, let me know on the sourceforge forums so I have an idea on where to take the project. I'm always interested in mo'betta. http://sourceforge.net/forum/?group_id=162768

Enjoy!


Other Sites

Discussion Groups
  Beginners
  Distributions
  Networking / Security
  Software
  PDAs

About | FAQ | Privacy | Awards | Contact
Comments to the webmaster are welcome.
Copyright 2006 Sourcefiles.org All rights reserved.