All pastes #56672 Raw Edit

Unnamed

public text v1 · immutable
#56672 ·published 2006-05-17 20:33 UTC
rendered paste body
<?php
/*
Shadow Bug Checker - Scans MU log files for shadow bug exploiters
Copyright (C) 2006  Muaddict.com

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

Contact:
	mike.livsey [at] gmail [dot] com (Mike Livsey)
	nheinen [at] gmail [dot] com (Norman Heinen)

Instructions:
	Avoid use of webbrowser use command line.
	Requires >=PHP-5.0
	Edit Configuration settings
	php shadowbugchecker.php

/* Set valid file extensions to scan */
$types = array("log");
/* Set to path of log files */
DEFINE('PATH', 'd:/documents and settings/nheinen/my documents/1/');
/* Set keywords to parse log files for */
$keywords = array("null", "Box", "Jewel", "Invisible", "Blood", "Rena", "Devil");
/* Set prekey and/or postkey to narrow search */
DEFINE('PREKEY', 'Before using Jewel of Bless : [');
DEFINE('POSTKEY', '');

/* #################################################### */
/* DO NOT EDIT BELOW UNLESS YOU KNOW WHAT YOU ARE DOING */
/* #################################################### */

if(!defined('PATH') || !defined('PREKEY') || !defined('POSTKEY')) {
	echo 'ERROR CONFIG: Please make sure PATH PREKEY and POSTKEY are defined';
	exit();
}
if(!is_array($types) || !is_array($keywords)) {
	echo 'ERROR CONFIG: Please make sure both $types and $keywords are arrays';
	exit();
}
if(!$files = @scandir(PATH)) {
	echo 'ERROR: Failed to find any files in set path';
	exit();
}
foreach($files as $file) {
	foreach($types as $type) {
		$pos = strrpos($file, '.');
		if(substr($file, $pos + 1, strlen($type)) == $type) $logs[] = $file;
	}
}
if(!is_array($logs)) {
	echo "Error: No files found with file type specificed";
	exit();
}
echo "====================\n";
echo "Shadow Bug Checker\n";
echo "Version 0.1.0\n";
echo "Copyright (C) 2006 Muaddict.com\n";
echo "====================\n";
foreach($logs as $log) {
	if($handle = @fopen(PATH.$log, 'r')) {
		$i = 1;
		$l = 1;
		$start = time();
		while(!feof($handle)) {
			$line = fgets($handle, 4096);
			foreach($keywords as $keyword) {
				$pos = strpos($line, PREKEY.$keyword.POSTKEY);
				if(!$pos === false) {
					list($time, $account, $char) = preg_split("/\s\[|\]\[|\].+/", $line);
					$data[$log]['infections'][] = array (
						'time' => $time,
						'line' => $i,
						'account' => $account,
						'char' => $char
					);
				}
			}
			if($i / $l == 25000) {
				$l++;
				echo '.';
			}
			$i++;
		}
		fclose($handle);
		$end = time();
		$data[$log]['run'] = $end - $start;
		echo "\n";
	} else {
		echo "ERROR: Failed to open ".PATH.$log;
		exit();
	}
}
foreach($data as $key_data => $value_data) {
	echo "\n====================\n";
	echo "Scanned file ".$key_data." in ".$value_data['run']." seconds.\n";
	echo "====================\n";
	if(!isset($value_data['infections'])) {
		echo "0 infections found.\n";
	} else {
		echo count($value_data['infections'])." infections found.\n";
		foreach($value_data['infections'] as $value_infect) {
			echo "@".$value_infect['time']." on line ".$value_infect['line']."\n";
			echo "Account: ".$value_infect['account']."\n";
			echo "Char: ".$value_infect['char']."\n";
		}
	}
}
echo "====================\n";
echo "END OF SCAN\n";
echo "====================\n";
?>