'ph_prst' => \@phpst, # persistent [true|false]
};
prep_report($tarpit,$out);
my_IPs($out,$look_n_feel,$out);
$rpt = \$out->{my_IPs};
}
##############
elsif ( $page eq 'trends' ) {
# print STDERR "trends\n";
my (@ports,@portstats,);
$out = {
# port statistics
'port_intervals' => $config->{port_intvls},
'port_intvls' => $config->{port_intvls},
'ports' => \@ports, # scanned port list
'portstats' => \@portstats,
};
prep_report($tarpit,$out);
port_stats($out,$look_n_feel,$out);
$rpt = \$out->{port_intervals};
$image_cache = make_image_cache($look_n_feel->{images});
}
##############
elsif ( $page eq 'others' ) {
# print STDERR "others\n";
$out = {
'other_sites' => undef,
};
$report = q|
This is the recent Hacktivity at other sites running
LaBrea::Tarpit. To include your site in this list send an email
To: Michael@BizSystems.com
Subject: LaBrea::Tarpit site
containing the exact URL of your report script - i.e.
http://www.foo.com/html_report.cgi
To get the most recent list of sites using LaBrea::Tarpit, see:
scans.bizsystems.net/other_sites.txt
or
www.bizsystems.net/downloads
|
|;
other_sites($out,$look_n_feel,$out);
$_ = 'onClick="return(please_wait(this));"';
$out->{other_sites} =~ s|(http:[^\"]+\")|$1 $_|g;
$out->{other_sites} =~ s//$report/o;
$rpt = \$out->{other_sites};
}
##############
elsif ( $page eq 'short' ) {
# print STDERR "short\n"; # prep short
$out = {};
gen_short($config,$out);
$error = $@;
$sht = \$short; # flag and pointer
short_report($sht,$out) unless $error;
undef $rpt;
}
$tarpit = {}; # destroy tarpit cache
if ( $error ) {
$upd = 1; # unconditional
undef $sht;
$page = 'error';
$report = qq|error, try again later.
The server said....
$error
|;
$rpt = \$report;
}
#elsif ( $upd && ! $sht ) { # new short report if update needed
# $sht = \$short;
# short_report($sht,$out);
#}
if ( $rpt ) { # if cache update needed
$logo_text = ' ' unless $logo_text;
## MAKE STANDARD TOP AND BUTTON BAR
$html = qq|
LaBrea::Tarpit $page| .
($image_cache || '') . q|
| | . $logo_text . qq| |
LaBrea::Tarpit $buttext{$page} |
|;
# make a two column page
@_ = (@buttons,@extras);
$html .= q|
| . make_buttons($look_n_feel,script_name,$page,\@_,$buttwidth) . q|
|
| . $$rpt . q| |
| |
| . make_buttons($look_n_feel,script_name,$page,\@buttons) . q| |
|;
$rpt = \$html;
}
## UPDATE CACHED PAGES
upd_cache($look_n_feel->{html_cache_file},$page,$rpt,$sht);
# the file
$_ = $look_n_feel->{html_cache_file} .'.'. $page;
$mtime = (stat($_))[9]; # file last modified
## SERVICE WEB REQUEST
local(*FH);
open(FH,$_);
my $size = (stat FH)[7];
my $ctype = ($page ne 'short') ? 'text/html' : 'text/plain';
my $xhead = 'X-LaBrea';
my $xhv = labrea_whoami;
####################################################
my $r;
eval { require Apache;
$r = Apache->request;
};
unless ($@) { # unless error, it's Apache
$r->status(200);
$r->content_type($ctype);
$r->header_out("Content-length","$size");
$r->header_out("Last-modified",http_date($mtime));
$r->header_out("Expires",http_date($mtime + $look_n_feel->{html_expire}));
$r->header_out($xhead,$xhv);
$r->send_http_header;
$r->send_fd(*FH);
close FH;
return 200; # HTTP_OK
} else { # sigh... no mod_perl
undef $/;
my $textp = ; # slurp file
close FH;
$/ = "\n";
print q
|Content-type: |, $ctype, q|
Content-length: |, $size, q|
Last-modified: |, http_date($mtime), q|
Connection: close
Expires: |, http_date($mtime + $look_n_feel->{html_expire}), qq|
$xhead: $xhv
$textp|;
}
# free memory resources for re-use
undef $rpt;
undef $sht;
undef $html;
undef $report;
undef $short;
undef $out;
1;