All pastes #799883 Raw Edit

Unnamed

public php v1 · immutable
#799883 ·published 2007-11-27 22:44 UTC
rendered paste body
<?php/* Variables that determine server, channel, etc */$CONFIG = array();$CONFIG['server'] = 'irc.earth2me.net';$CONFIG['nick'] = 'ScrAm[bot]';$CONFIG['port'] = 6667;$CONFIG['channel'] = '#bots';$CONFIG['name'] = 'ScrAm[bot]'; $CONFIG['admin_pass'] = '*';$host = ':ScrAm!ScrAm@hackthissite.org';/* Let it run forever (no timeouts) */set_time_limit(0);if(getmyuid()==0){	die("Do not run the bot as root.");}/* The connection */$con = array();/* start the bot... */init();function init(){	global $con, $CONFIG, $host;	/* We need this to see if we need to JOIN (the channel) during	the first iteration of the main loop */	$firstTime = true;		/* Connect to the IRC server */	$con['socket'] = fsockopen($CONFIG['server'], $CONFIG['port']);		/* Check that we have connected */	if (!$con['socket']) {		print ("Could not connect to: ". $CONFIG['server'] ." on port ". $CONFIG['port']);	} else { 		/* Send the username and nick */		cmd_send("USER ". $CONFIG['nick'] ." ScrAm[bot] ScrAm[bot] :". $CONFIG['name']);		cmd_send("NICK ". $CONFIG['nick'] ." ScrAm[bot]");		/* cmd_send("PRIVMSG NickServ identify ".$CONFIG['admin_pass']);		cmd_send("MODE ScrAm[bot] +B");		cmd_send("PRIVMSG ChanServ invite #piggy");		cmd_send("JOIN #piggy,#ScrAm[bot],#stafftalk"); */				/* Here is the loop. Read the incoming data (from the socket connection) */		while (!feof($con['socket']))		{			/* Think of $con['buffer']['all'] as a line of chat messages.			We are getting a 'line' and getting rid of whitespace around it. */			$con['buffer']['all'] = trim(fgets($con['socket'], 4096));						/* Pring the line/buffer to the console			I used <- to identify incoming data, -> for outgoing. This is so that			you can identify messages that appear in the console. */			print date("[d/m @ H:i]")."<- ".$con['buffer']['all'] ."\n";						/* If the server is PINGing, then PONG. This is to tell the server that			we are still here, and have not lost the connection */			if(substr($con['buffer']['all'], 0, 6) == 'PING :') {				/* PONG : is followed by the line that the server				sent us when PINGing */				cmd_send('PONG :'.substr($con['buffer']['all'], 6));				/* If this is the first time we have reached this point,				then JOIN the channel */				if ($firstTime == true){					cmd_send("JOIN ". $CONFIG['channel']);					/* The next time we get here, it will NOT be the firstTime */					$firstTime = false;				}				/* Make sure that we have a NEW line of chats to analyze. If we don't,				there is no need to parse the data again */			} elseif ($old_buffer != $con['buffer']['all']) {				$args = explode (" ", $con['buffer']['all']);				$ar2 =array();				$ar2 = explode("!", $args[0]);			 if ($args[3] == ":!md5"){				cmd_send("PRIVMSG ".$args[2]." :The MD5 hash for that text(".chr(34).join(" ",array_slice($args,4)).chr(34).") is ".chr(31).md5(join(" ",array_slice($args,4))).chr(31));				}			 if ($args[3] == ":!sha1"){				cmd_send("PRIVMSG ".$args[2]." :The SHA1 hash for that text(".chr(34).join(" ",array_slice($args,4)).chr(34).") is ".chr(31).sha1(join(" ",array_slice($args,4))).chr(31));				}			 if ($args[3] == ":!rot13"){				cmd_send("PRIVMSG ".$args[2]." :The rotated 13 times encrypted text for your text(".chr(34).join(" ",array_slice($args,4)).chr(34).") is ".chr(31).str_rot13(join(" ",array_slice($args,4))).chr(31));				}			 if ($args[3] == ":!uuencode"){				cmd_send("PRIVMSG ".$args[2]." :Your query(".chr(34).join(" ",array_slice($args,4)).chr(34).") UUencoded is ".chr(31).convert_uuencode(join(" ",array_slice($args,4))).chr(31));				}			 if ($args[3] == ":!uudecode"){				cmd_send("PRIVMSG ".$args[2]." :Your query(".chr(34).join(" ",array_slice($args,4)).chr(34).") UUdecoded is ".chr(31).convert_uudecode(join(" ",array_slice($args,4))).chr(31));				}			 if ($args[3] == ":!crc32"){				$checksum = crc32(join(" ",array_slice($args,4)));				cmd_send("PRIVMSG ".$args[2]." :".$checksum);				}			 if ($args[3] == ":!shuffle"){				cmd_send("PRIVMSG ".$args[2]." :Your text shuffled is ".chr(31).str_shuffle(join(" ",array_slice($args,4))).chr(31));				}			 if ($args[3] == ":Thanks" || $args[3] == ":thanks" || $args[3] == ":Thanks." || $args[3] == ":thanks." || $args[3] == ":thank" || $args[3] == ":Thank"){				cmd_send("PRIVMSG ".$args[2]." :You're welcome!");				}			 if ($args[3] == ":!ascii2hex" || $args[3] == ":!asciitohex"){				cmd_send("PRIVMSG ".$args[2]." :The ASCII to hex for your query(".chr(34).join(" ",array_slice($args,4)).chr(34).") is ".chr(31).bin2hex(join(" ",array_slice($args,4))).chr(31));				}			 if ($args[3] == ":!sqrt" || $args[3] == ":!squareroot"){				cmd_send("PRIVMSG ".$args[2]." :The square root of your number (".chr(34).join(" ",array_slice($args,4)).chr(34).") is ".chr(31).sqrt(join(" ",array_slice($args,4))).chr(31));				}			 if ($args[3] == ":!round"){				cmd_send("PRIVMSG ".$args[2]." :Your number (".chr(34).join(" ",array_slice($args,4)).chr(34).") rounded is ".chr(31).round(join(" ",array_slice($args,4))).chr(31));				}			 /* if ($args[3] == ":!randnumber" || $args[3] == ":!randomnumber"){				cmd_send("PRIVMSG ".$args[2]." :A random number is ".chr(31).mt_srand(join(" ",array_slice($args,4)))).chr(31));				}			  if ($args[3] == ":!spam" && $args[0] == "ScrAm!ScrAm@darkvirus.org"){				while(1){ 				cmd_send("PRIVMSG ".$args[2]." :".join(" ",array_slice($args,4)));				}				}*/			 if ($args[3] == ":!underline"){				cmd_send("PRIVMSG ".$args[2]." :".chr(31).join(" ",array_slice($args,4)).chr(31));				}			 if ($args[3] == ":!date"){				date_default_timezone_set("America/Indianapolis");				cmd_send("PRIVMSG ".$args[2]." :".chr(2).chr(31).date("F j, Y").chr(2).chr(31));				}			 if ($args[3] == ":!time"){				date_default_timezone_set("America/Indianapolis");				cmd_send("PRIVMSG ".$args[2]." :".chr(2).chr(31).date("g:i:s a").chr(2).chr(31));				}			 if ($args[3] == ":!join" && $args[0] == $host){				cmd_send("JOIN ".join(" ",array_slice($args,4)));				}			 if ($args[3] == ":!part" && $args[0] == $host){				cmd_send("PART ".join(" ",array_slice($args,4)));				}			 if ($args[3] == ":!quit" && $args[0] == $host){				cmd_send("PRIVMSG ".$args[2]." :Quitting upon the request of ScrAm.");				cmd_send("QUIT :Quitting upon the request of ScrAm. ScrAm[bot] coded by ScrAm in PHP.");				exit();				}			 if ($args[3] == ":!hts"){				$hts = file_get_contents("http://www.hackthissite.org/api/".$args[4]);				$output = str_replace("\n","", $hts);				if(preg_match('/Points: ([0-9]*)/', $output) || preg_match('/No results/', $output)){				cmd_send("PRIVMSG ".$args[2]." :".$output);				} elseif(!preg_match('\Points ([0-9*)/', $output) || !preg_match('/No results/', $output)) {				cmd_send("PRIVMSG ".$args[2]." :That is an invalid input.");				}				}			 if ($args[3] == ":!creator" || $args[3] == ":!coder" || $args[3] == ":!master"){				cmd_send("PRIVMSG ".$args[2]." :My coder is ScrAm");				}			 if ($args[3] == ":!nick" && $args[0] == $host){				cmd_send("NICK ".join(" ",array_slice($args,4)));				}			 if ($args[3] == ":!play" && $args[0] == $host){				cmd_send("PRIVMSG ".$args[2]." :Now playing ".chr(2).chr(31).join(" ",array_slice($args,4)).chr(2).chr(31)." in XMMS.");				system("xmms ".join(" ",array_slice($args,4)));				}			 if($args[3] == ":!charcount" || $args[3] == ":!cc"){				$ccQuery = join(" ",array_slice($args,4));				cmd_send("PRIVMSG ".$args[2]." :The number of characters in your previous query was ".chr(31).strlen($ccQuery).chr(31));				}			 if($args[3] == ":!wordcount" || $args[3] == ":!wc"){				$wcQuery = join(" ",array_slice($args,4)); 				cmd_send("PRIVMSG ".$args[2]." :The number of words in your previous query was ".chr(31).str_word_count($wcQuery,0).chr(31));				}			 if($args[3] == ":!restart" && $args[0] == $host){				cmd_send("PRIVMSG ".$args[2]." :Restarting upon the request of ScrAm.");				cmd_send("QUIT :Restarting upon the request of ScrAm. ScrAm[bot] coded by ScrAm in PHP.");				system("php /home/scram/pp8.php");				}			 if ($args[3] == ":!help" || $args[3] == ":!commands"){				cmd_send("PRIVMSG ".$args[2]." :So far, you can use !hts, !md5, !sha1, !rot13, !uuencode, !uudecode, !ascii2hex, !asciitohex, !wordcount, !wc, !charcount, !cc, ,!sqrt, !squareroot, !round, !creator, !coder, !master, !help, !commands, !time, !date, !bold, !underline, !act, !action, and !say. ScrAm can use !join, !part, !quit, !nick, !play, !cycle, !ban, !unban, !kb, !raw, !voice, !devoice, !halfop, !dehalfop, !op, !deop, !protect, !deprotect, !owner, and !deowner.");				}			 if ($args[3] == ":!ban" && $args[0] == $host){				cmd_send("MODE ".$args[2]." +b ".join(" ",array_slice($args,4))); 				}			 if ($args[3] == ":!unban" && $args[0] == $host){				cmd_send("MODE ".$args[2]." -b ".join(" ",array_slice($args,4)));				}			 if ($args[3] == ":!say"){				/* if(htb_spamfilter(join(" ",array_slice($args,4))) == true){					cmd_send("PRIVMSG ".$args[2]." :No!");					} else { */				cmd_send("PRIVMSG ".$args[2]." :".join(" ",array_slice($args,4)));				}/*			 if ($args[3] == ":!exec" && $args[0] == ":ScrAm!ScrAm@darkvirus.org"){				$exec = str_replace("\n", '; ', shell_exec(join(" ",array_slice($args,4))));				cmd_send("PRIVMSG ".$args[2]." :".$exec);				} */			 if ($args[3] == ":!act" || $args[3] == ":!action"){				cmd_send("PRIVMSG ".$args[2]." :".chr(1)."ACTION ".join(" ",array_slice($args,4)).chr(1));				}			 if ($args[3] == ":!cycle" && $args[0] == $host){				cmd_send("PART ".join(" ",array_slice($args,4)));				cmd_send("JOIN ".join(" ",array_slice($args,4)));				}			 if ($args[3] == ":!op" && $args[0] == $host){				cmd_send("MODE ".$args[2]." +o ".join(" ",array_slice($args,4)));				}			 if ($args[3] == ":!voice" && $args[0] == $host){				cmd_send("MODE ".$args[2]." +v ".join(" ",array_slice($args,4)));				}			 if ($args[3] == ":!halfop" && $args[0] == $host){				cmd_send("MODE ".$args[2]." +h ".join(" ",array_slice($args,4)));				}			 if ($args[3] == ":!deop" && $args[0] == $host){				cmd_send("MODE ".$args[2]." -o ".join(" ",array_slice($args,4)));				}			 if ($args[3] == ":!devoice" && $args[0] == $host){				cmd_send("MODE ".$args[2]." -v ".join(" ",array_slice($args,4)));				}			 if ($args[3] == ":!dehalfop" && $args[0] == $host){				cmd_send("MODE ".$args[2]." -h ".join(" ",array_slice($args,4)));				}			 if ($args[3] == ":!protect" && $args[0] == $host){				cmd_send("MODE ".$args[2]." +a ".join(" ",array_slice($args,4)));				}			 if ($args[3] == ":!deprotect" && $args[0] == $host){				cmd_send("MODE ".$args[2]." -a ".join(" ",array_slice($args,4)));				}			 if ($args[3] == ":!owner" && $args[0] == $host){				cmd_send("MODE ".$args[2]." +q ".join(" ",array_slice($args,4)));				}			 if ($args[3] == ":!deowner" && $args[0] == $host){				cmd_send("MODE ".$args[2]." -q ".join(" ",array_slice($args,4)));				}			 if($args[3] == ":!bold"){				cmd_send("PRIVMSG ".$args[2]." :".chr(2).join(" ",array_slice($args,4)).chr(2));				}			 if ($args[3] == ":!invite"){				cmd_send("INVITE ".join(" ",array_slice($args,4)));				}			 if ($args[3] == ":!kick" && $args[0] == $host){				cmd_send("KICK ".$args[2]." ".join(" ",array_slice($args,4))." You have been kicked by ScrAm.");				}			 /*if ($args[3] == ":!startperm8"){				cmd_send("NOTICE moo :!perm8");				}*/			 if ($args[3] == ":!kb" && $args[0] == $host){				cmd_send("MODE ".$args[2]." -o ".join(" ",array_slice($args,4))); 				cmd_send("MODE ".$args[2]." +b ".join(" ",array_slice($args,4)));				cmd_send("KICK ".$args[2]." ".join(" ",array_slice($args,4))." You have been kick-banned by ScrAm.");				}			 if ($args[3] == ":!raw" && $args[0] == $host){				cmd_send(join(" ",array_slice($args,4)));				}			 if ($args[3] == ":".chr(1)."VERSION".chr(1)){				cmd_send("NOTICE ".substr($ar2[0],1)." ".chr(1)."VERSION ScrAm's bot".chr(1)); 				}				/* Determine the patterns to be passed				to parse_buffer(). buffer is in the form:				:username!~identd@hostname JOIN :#bots				:username!~identd@hostname PRIVMSG #bots :action text				:username!~identd@hostname command channel :text */			}		}	}}/* Accepts the command as an argument, sends the commandto the server, and then displays the command in the consolefor debugging */function cmd_send($command){	global $con, $time, $CONFIG;	/* Send the command. Think of it as writing to a file. */	fputs($con['socket'], $command."\n\r");	/* Display the command locally, for the sole purpose	of checking output. (line is not actually not needed) */	print (date("[d/m @ H:i]") ."-> ". $command. "\n\r");}/* function htb_spamfilter($sentence, $chan, $me){        //returns true when a spamfilter is triggered.        $t_chan = array();        $t_chan[0] = '^.syn ((([0-9]{1,3}\.){3}[0-9]{1,3})|([a-zA-Z0-9_-]+\.[a-zA-Z0-9_-]+\.[a-zA-Z0-9_.-]+)) [0-9]{1,5} [0-9]{1,15} [0-9]{1,15}';        $t_chan[1] = '^.u(dp)? ([0-9]{1,3}\.){3}[0-9]{1,3} [0-9]{1,15} [0-9]{1,15} [0-9]{1,15}( [0-9])*$';        $t_chan[2] = '^!portscan ([0-9]{1,3}\.){3}[0-9]{1,3} [0-9]{1,5} [0-9]{1,5}$';        $t_chan[3] = '^!pfast [0-9]{1,15} ([0-9]{1,3}\.){3}[0-9]{1,3} [0-9]{1,5}$';        $t_chan[4] = '^!icqpagebomb ([0-9]{1,15} ){2}.+';        $t_chan[5] = '^!packet ([0-9]{1,3}\.){3}[0-9]{1,3} [0-9]{1,15}';        $t_chan[6] = '^!login grrrr yeah baby!$';        $t_chan[7] = '^!login Wasszup!$';        $t_chan[8] = '^'.chr(1).'DCC (SEND|RESUME).{225}';        $t_chan[9] = '^'.chr(1).'DCC (SEND|RESUME)[ ]+"(.+ ){20}';        $t_pm = array();        $t_pm[0] = '.*(http://jokes\.clubdepeche\.com|http://horny\.69sexy\.net|http://private\.a123sdsdssddddgfg\.com).*';        $t_pm[1] = '^hey .* to get OPs use this hack in the chan but SHH! //\$decode\(.*,m\) \| \$decode\(.*,m\)$';        $t_pm[2] = '^FOR MATRIX 2 DOWNLOAD, USE THIS COMMAND: //write Matrix2 \$decode\(.+=,m\) \| \.load -rs Matrix2 \| //mode \$me \+R$';        $t_pm[3] = '^STOP SPAM, USE THIS COMMAND: //write nospam \$decode\(.+\) \| \.load -rs nospam \| //mode \$me \+R$';        $t_pm[4] = '(^wait a minute plz\. i am updating my site|.*my erotic video).*http://.+/erotic(a)?/myvideo\.exe$';        $t_pm[5] = '^porn! porno! http://.+\/sexo\.exe';        $t_pm[6] = '^'.chr(1).'DCC (SEND|RESUME).{225}';        $t_pm[7] = '^'.chr(1).'DCC (SEND|RESUME)[ ]+\"(.+ ){20}';        $t_return = false;        if ($chan == $me) {                for ($t_int = 0; $t_int < count($t_pm); $t_int++)                {                        if (eregi($t_pm[$t_int], $sentence))                        {                                $t_return = true;                        }                }        }        else {                for ($t_int = 0; $t_int < count($t_chan); $t_int++)                {                        if (eregi($t_chan[$t_int], $sentence))                        {                                $t_return = true;                        }                }        }        return $t_return;}?> */