Friday, May 4, 2012

Setting up apache and the linux cross reference tool on linux to examine nmap files.

When I am learning a new set of source code I like using a tool I found about 15 years ago.  It is something called LXR, or Linux cross reference.    It allows you to browse entire source trees and follow project logic by clicking between names. 

Just noticed that I found the old site first.  Going to try install the latest lxr from the new main site tomorrow.  They might have made installation easier.

The new site:

The old site:

The version I had was from late 1990's, it had some changes I made to handle embedded sql code, which I have not used for a long time. so I decided to get the latest version from the web site and try it out.

LXR is a module that runs under Apache.  I didn't have apache installed on my box, so I ran the synaptic package tool on my ubuntu box and searched for apache2.  You can just type:

sudo apt-get install apache2

I don't want the web server on my dev box to be visible from the outside.  I don't allow any ports to be visible on my dev machine from the outside. Mostly because I am paranoid.  So I am editing the  apache server to only be visible on localhost.

sudo bash

cd /etc/apache2

vi ports.conf

Change the following:

Listen 80


Listen localhost:80

And then restart the web server:

/etc/init.d/apache2 restart

Test your web browser to make sure the server is now only visible from your localhost.

Then I downloaded the latest lxr from:  git://

The command I used to get the source code was:

 git clone git://

Found a really nice git manual here:

Reading the INTALL file gave me a scattered list of modules to install:

apt-get install libdbd-pg-perl libcgi-simple-perl libcgi-ajax-perl libhtml-parser-perl libtemplate-perl libdevel-size-perl libterm-progressbar-perl exuberant-ctags inkscape texlive texlive-latex-recommended

The install instructions were very confusing.  So I found slightly clearer instructions here:


Then I realized that it wanted to create a postgres database and realized that I don't have time for all this.  The older version was all self contained, you just put it into a cgi-bin directory and it worked.  I prefer software that just works so I went and got the 15 year old version.

This version requires glimpse which is a very useful tool to mine for data.


And then I found out that the latest apache does not allow cgi-bin to work like it used to work, which is probably needed for some security holes they found over the past few years. So now I am struggling to get apache configured to let me view the source code through my old lxr as well.

Got apache to see the directories and execute a hello world script, but the old lxr is just having the error:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be availablein the server error log.

Good times.

And I finally got the permissions sorted out. I had to set all the directories to +x so that the web browser could see their contents. Copying to a usb thumb drive formated in msdos fat format had dropped all these settings.

I had to make a new conf file pointing to the new location of the copy of the nmap folder in the local source tree.
I changed to that source folder, copied the source into that location, and indexed the folder with

../../bin/genxref nmap

LXR lets you browse your source tree.

If you look at a file the function names, variables, and types are all clickable.

Clicking on a highlighted name shows where that name is defined, where it is prototyped  and where it is used.

One failing of this tool is that it is not very C+ smart and the nmap program appears to mostly be written in C++, so it doesn't recognize some names as classes and the like.

Another limitation is that lxr does no scope checking, so local variables that appear everywhere would be listed  everywhere when you check any instance.

Busy looking at the code with LXR today and tomorrow. :)

No comments:

Post a Comment