Thanks to my employer for allowing me to post this little program.
This is an interesting program to exactly two sets of people, those who need to keep a log of all visitors who try to use a web resource (and who are using a squid proxy), and those who are curious about seeing a very simple pyramid program of not much more complexity than “Hello, World” that actually does something useful. “On the shoulders of giants...”
Here is the background: our IDS reported that there appeared to be a worm active internally. We knew the IP address that was causing the alert, and that it was not one of our internal users – it was a visitor. We did not know who it was, and there were about a dozen visitors that day. So, we wanted to have a way of capturing information about which visitors access the web from our internal network.
We use squid3 as a transparent proxy server to reduce bandwidth. We already use squidGuard to block selected sites, and wish to continue doing so. So, we decided to use a redirector to force visiting users through a signin screen. There are three components to this solution: a pyramid program that takes care of getting and storing the desired information; a squid redirector program, weblogin_redirector.py, that redirects initial attempts to the pyramid screen and later atttempts through the squid; and zapchain.pl, which is used to chain the redirectors squidGuard and weblogin.py.
So, on to the programs.