Ok all, here are my configs and access denied page for my WORKING self
generating hash setup.
-----------------------------------------
accessdenied.php
-----------------------------------------
<?php
#
#===========================================================================
=
# break up the query string into useable pieces
#===========================================================================
=
$url = explode("::",$_SERVER["QUERY_STRING"]);
foreach ($url as $temp){
$pieces = explode("==",$temp);
$value[$pieces[0]] = urldecode($pieces[1]);
}
$myurl=$value['DENIEDURL'];
$magic = "insertyourhashhere";
$clientip=$value['IP'];
// Obviously this is completely impossible if you use the
// random passphrase
$unixtimekey = time() + 300;
$time=time();
// If these lines are missing, some web browsers won't work
// properly
if (!eregi("https?://.+/.*", $myurl)){
$myurl = $myurl . "/";
}
// This is the most important part.
// The MD5 Hash MUST be hex encoded and uppercase with no
// padding, salt, etc other than what is shown here
// This can take some experimenting in Perl
// DO NOT just use the time() function at this point
$hash = strtoupper(md5($myurl . $magic . $clientip . $unixtimekey));
$hash .= $unixtimekey;
// If these lines are missing, some URL's won't work properly
if (eregi("\?", $url2)){
$bypass = $value['DENIEDURL'] . "&GBYPASS=" . $hash;
}else{
$bypass = $value['DENIEDURL'] . "?GBYPASS=" . $hash;
}
?>
<html>
<head>
<title>Access Denied</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style>
body,td,p {
font: x-small Verdana,Arial,Helevetica;
}
table.main {
border: 2px solid #cccccc;
width: 600px;
}
td.top_denied {
font: x-large Georgia;
font-weight: bold;
color: #ffffff;
padding: 10;
text-align: center;
background-color: #CC3333;
}
td.top_granted {
font: x-large Georgia;
font-weight: bold;
color: #ffffff;
padding: 10;
text-align: center;
background-color: #339933;
}
td.body {
background-color: #ffffff;
padding: 10;
}
td.bottom {
background-color: #eeeeee;
height: 25px
}
p.url_denied {
text-align: center;
font-size: medium;
color: #ff0000;
border: 1px dashed #ff0000;
background-color: #FFF0F0;
padding: 3;
}
p.url_granted {
text-align: center;
font-size: medium;
color: #339933;
border: 1px dashed #339933;
background-color: #EFFAEF;
padding: 3;
}
p.reason {
border: 1px dashed #ff0000;
background-color: #FFF0F0;
padding: 3;
}
input.text {
width: 100%;
border: 1px inset;
font-size: xx-small;
color: #666666;
font-weight: normal;
padding-left:2;
}
input.button {
width: 150px;
}
td.overide {
border: 1px dashed #339933;
background-color: #EFFAEF;
}
</style>
</head>
<body bgcolor="#f4f4f4">
<script>
// functions for navigation
function goBack(){
history.back();
}
function visitSite(){
document.location.href = "<?php print $bypass; ?>";
}
</script>
<?php if (!$value['ACTION']): ?>
<table border="0" align="center" cellpadding="0" cellspacing="0"
class="main">
<tr><td class='top_denied'>Access Denied!</td></tr>
<tr>
<td class='body'>
<p>Access to the page:</p>
<p class='url_denied'><?php print
$value['DENIEDURL']; ?></p>
<p>... has been denied for the following reason:</p>
<p class='reason'><?php print $value['REASON'];
?></p>
<table width="576" border="0" cellpadding="3" cellspacing="0">
<tr valign="top">
<td width="334"> <p>You are seeing this error because what you
attempted
to access appears to contain, or is labeled as containing,
material
that has been deemed inappropriate. </p>
<p>If you have any questions, please contact our technical
support
staff.</p>
<p><strong>Your Company Name</strong><br>
555-555-5555<br>
<a
href="mailto:support@...">support@...</a></p></td>
<td width="230" class='overide'> <p align="center"><strong>Overide
Filtering</strong></p>
<form
action="http://yourserver.com/accessdenied.php?ACTION==verify::<?php print
$url2; ?>" method="post">
<div align="center">Please enter your override
username/password:<br>
<table>
<tr>
<td>Username:</td><td><input type="text"
name="username" size="20"></td>
</tr>
<tr>
<td>Password:</td><td><input type="password"
name="passwd" size="20"></td>
</tr>
</table> <br>
<input type="submit" name="Submit" value="Overide"
class='button'>
<br>
<br>
<input type="button" name="Button" value="Go Back"
class='button' onClick="goBack()">
</div></form></td>
</tr>
</table> </td>
</tr>
<tr><td class='bottom'> </td></tr>
</table>
<?php endif; ?>
<?php if ($value['ACTION']):
###########################################
# Check credentials
###########################################
$username=$_POST['username'];
$passwd=$_POST['passwd'];
$file=file("path_to_your_access_file");
$ftemp=explode("/",$file[0]);
$found=false;
foreach ($ftemp as $line){
$f_temp=explode(":",$line);
if ($f_temp[0] == $username){
if ($f_temp[1] == $passwd){
$found=true;
?><table border="0" align="center" cellpadding="0" cellspacing="0"
class="main">
<tr><td class='top_granted'>Access Granted!</td></tr>
<tr>
<td class='body'> <p>Access to the following page has been
granted.</p>
<p class='url_granted'><?php print
$value['DENIEDURL']; ?></p>
<p class='reason'><?php print $value['REASON']; ?></p>
<p><input type="button" name="Button" value="Proceed" class='button'
onclick="visitSite()"></p>
</td>
</tr>
<tr><td class='bottom'> </td></tr>
</table>
<?
}
}
}
if ($found == false){
print "<script>document.location.href='accessdenied.php'</script>";
}
?>
<?php endif; ?>
</body>
</html>
--------------------------------------
Ok, obviously for now I am using a flat text file for authentication, in the
future I will probably be using a SQL database for that, so feel free to use
your own authentication method....
---------------------------------
dansguardian.conf
---------------------------------
# DansGuardian config file for version 2.8.0
# **NOTE** as of version 2.7.5 most of the list files are now in
dansguardianf1.conf
# Web Access Denied Reporting (does not affect logging)
#
# -1 = log, but do not block - Stealth mode
# 0 = just say 'Access Denied'
# 1 = report why but not what denied phrase
# 2 = report fully
# 3 = use HTML template file (accessdeniedaddress ignored) - recommended
#
reportinglevel = 1
# Language dir where languages are stored for internationalisation.
# The HTML template within this dir is only used when reportinglevel
# is set to 3. When used, DansGuardian will display the HTML file instead of
# using the perl cgi script. This option is faster, cleaner
# and easier to customise the access denied page.
# The language file is used no matter what setting however.
#
languagedir = '/usr/local/dansguardian-2.8.0.6/etc/dansguardian/languages'
# language to use from languagedir.
language = 'ukenglish'
# Logging Settings
#
# 0 = none 1 = just denied 2 = all text based 3 = all requests
loglevel = 2
# Log Exception Hits
# Log if an exception (user, ip, URL, phrase) is matched and so
# the page gets let through. Can be useful for diagnosing
# why a site gets through the filter. on | off
logexceptionhits = on
# Log File Format
# 1 = DansGuardian format 2 = CSV-style format
# 3 = Squid Log File Format 4 = Tab delimited
logfileformat = 1
# Log file location
#
# Defines the log directory and filename.
loglocation =
'/usr/local/dansguardian-2.8.0.6/var/log/dansguardian/access.log'
# Network Settings
#
# the IP that DansGuardian listens on. If left blank DansGuardian will
# listen on all IPs. That would include all NICs, loopback, modem, etc.
# Normally you would have your firewall protecting this, but if you want
# you can limit it to only 1 IP. Yes only one.
filterip =
# the port that DansGuardian listens to.
filterport = 8080
# the ip of the proxy (default is the loopback - i.e. this server)
proxyip = 127.0.0.1
# the port DansGuardian connects to proxy on
proxyport = 3128
# accessdeniedaddress is the address of your web server to which the cgi
# dansguardian reporting script was copied
# Do NOT change from the default if you are not using the cgi.
#
accessdeniedaddress = 'http://yourserver.com/accessdenied.php'
# Non standard delimiter (only used with accessdeniedaddress)
# Default is enabled but to go back to the original standard mode dissable
it.
nonstandarddelimiter = on
-----------------------------------------------
This isn't the entire file, but it is long and the rest does not pertain to
the hash stuff....
---------------------------------------
dansguardianf1.conf
---------------------------------------
# DansGuardian filter group config file for version 2.8.0
# Content filtering files location
bannedphraselist =
'/usr/local/dansguardian-2.8.0.6/etc/dansguardian/bannedphraselist'
weightedphraselist =
'/usr/local/dansguardian-2.8.0.6/etc/dansguardian/weightedphraselist'
exceptionphraselist =
'/usr/local/dansguardian-2.8.0.6/etc/dansguardian/exceptionphraselist'
bannedsitelist =
'/usr/local/dansguardian-2.8.0.6/etc/dansguardian/bannedsitelist'
greysitelist =
'/usr/local/dansguardian-2.8.0.6/etc/dansguardian/greysitelist'
exceptionsitelist =
'/usr/local/dansguardian-2.8.0.6/etc/dansguardian/exceptionsitelist'
bannedurllist =
'/usr/local/dansguardian-2.8.0.6/etc/dansguardian/bannedurllist'
greyurllist = '/usr/local/dansguardian-2.8.0.6/etc/dansguardian/greyurllist'
exceptionurllist =
'/usr/local/dansguardian-2.8.0.6/etc/dansguardian/exceptionurllist'
bannedregexpurllist =
'/usr/local/dansguardian-2.8.0.6/etc/dansguardian/bannedregexpurllist'
bannedextensionlist =
'/usr/local/dansguardian-2.8.0.6/etc/dansguardian/bannedextensionlist'
bannedmimetypelist =
'/usr/local/dansguardian-2.8.0.6/etc/dansguardian/bannedmimetypelist'
picsfile = '/usr/local/dansguardian-2.8.0.6/etc/dansguardian/pics'
contentregexplist =
'/usr/local/dansguardian-2.8.0.6/etc/dansguardian/contentregexplist'
# Naughtyness limit
# This the limit over which the page will be blocked. Each weighted phrase
is given
# a value either positive or negative and the values added up. Phrases to
do with
# good subjects will have negative values, and bad subjects will have
positive
# values. See the weightedphraselist file for examples.
# As a guide:
# 50 is for young children, 100 for old children, 160 for young adults.
naughtynesslimit = 50
# Temporary Denied Page Bypass
# It provides a link on the denied page to bypass the ban for a few minutes.
To be
# secure it uses a random hashed secret generated at daemon startup. You
define the
# number of seconds the bypass will function for before the deny will appear
again.
# To allow the link on the denied page to appear you will need to edit the
template.html
# or dansguardian.pl file for your language.
# 300 = enable for 5 minutes
# 0 = disable ( defaults to 0 )
# -1 = enable but you require a seperate program to generate a valid link
bypass = -1
# Temporary Denied Page Bypass Secret Key
# Rather than generating a random key you can specify one. It must be more
than 8 chars.
# '' = generate a random one (recommended and default)
# 'Mary had a little lamb.' = an example
# '76b42abc1cd0fdcaf6e943dcbc93b826' = an example
bypasskey = 'insertyourhashhere'
---------------------------------------
I really appreciate the help I have gotten here, and in true reciprocation I
will help any one else I can. If you all have any questions about the above
files, please let me know.
-Jason