Post Pacific  

Go Back   Post Pacific > Восстановленный архив > Темы без сохранившегося раздела

Notices

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 22.08.2007, 18:10   #6
adriahu
Архивный участник
 
Join Date: Oct 2006
Posts: 47
Default

I write simple perl script, which automaticaly kick and ban expoliting ppl :P

Note, writed on knee :P
Code:
use Data::Dumper;
use LWP::Simple;
use Win32::Console;

my $STDOUT = new Win32::Console(STD_OUTPUT_HANDLE);
$STDOUT->Title("L2 Adena Cheat Autoban");
$STDOUT->Cls($FG_LIGHTGRAY | $BG_BLACK);
$STDOUT->Attr($FG_LIGHTGRAY | $BG_BLACK);

$log_dir      = 'D:\SERVER\CacheD\log\err\\';
$watch_status = 'adena_cheat_status.txt';
$watch_banned = 'adena_cheat_banned.txt';
$watch_log    = 'adena_cheat_log.txt';

open STATUS, "$watch_status";
while (<STATUS>)
{
	chop($_);
	$f_status{$_}=1;
}
close STATUS;

my %banned;

open BAN, "$watch_banned";
while (<BAN>)
{
	chop($_);
	$banned{$_}=1;
}
close BAN;

open STATUS, ">>$watch_status";
open LOG,    ">>$watch_log";
open BAN,    ">>$watch_banned";

$| = 1, select $_ for select STATUS; #autoflush
$| = 1, select $_ for select LOG;    #autoflush
$| = 1, select $_ for select BAN;    #autoflush

my @log_files     = read_log_dir();
my $log_files_cnt = scalar @log_files;

$file_nr = 1;

while ($log_file = shift @log_files)
{
  if (defined $f_status{$log_file}) ## juz sprawdzany plik
  {
	$file_nr++;
	next;
  }
  open LOGFILE, $log_file;
  print STDERR "open $log_file\n";
  while (1) 
  {
    for ($cur_pos = tell LOGFILE; $_ = <LOGFILE>; $cur_pos = tell LOGFILE)
    {
      if ($_ =~ m{BuyItems error.\[(\d+)\]\[57\]})
	  {
		$char_id = $1;
		if (! defined ($banned{$char_id}))
		{
			my $ban_content = get("http://your.domain.com/yourbanandkickscript.php?char_id=".$char_id);
			print LOG localtime()." ban for $char_id [$ban_content]\n";
			print localtime()." ban for $char_id [$ban_content]\n";
			$banned{$char_id} = 1;
			print BAN "$char_id\n";
		}
		else
		{
			print "$char_id alredy banned\n";
		}
	  }
	}
    if ($file_nr < $log_files_cnt)
    {
      last;
    }
    else
    {
      my @log_files_tmp     = read_log_dir();
      my $log_files_cnt_tmp = scalar @log_files_tmp;
      if ($log_files_cnt_tmp > $log_files_cnt) #one file only :P
      {
        print STDERR "new file $log_files_tmp[$log_files_cnt]\n";
        push @log_files, $log_files_tmp[$log_files_cnt];
        $log_files_cnt = $log_files_cnt_tmp;
        last;
      }
    }
    sleep 1;
    seek LOGFILE, $cur_pos, 0;
  }
  close LOGFILE;
  print STATUS $log_file."\n";
  $file_nr++;
}

sub read_log_dir
{
  my @log_files;
  opendir LOGDIR, $log_dir;
  push (@log_files,  map($log_dir.$_, grep (m{^.*\.log$}, readdir LOGDIR)));
  closedir LOGDIR;
  return @log_files;
}
adriahu is offline  
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 14:48.