tubular

Pointed Stones

Oct 25th, 2011
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.97 KB | None | 0 0
  1. <?php // stealth rocks because it's quizler's birthday
  2.       // note that i quietly hid all of my backdoors :><:
  3.  
  4. function send($t, $m = 0, $chan = FALSE) {
  5.     global $socket;
  6.     if($chan === FALSE) $chan = $GLOBALS['channel'];
  7.     switch($m) {
  8.         case 2: $t = chr(1)."ACTION ".$t.chr(1);
  9.         case 1: $t = "PRIVMSG $chan :".$t;
  10.         case 0: fputs($socket, $t."\r\n"); break;
  11.         default: throw new Exception("send() error.");
  12.     }
  13.     echo $t."\r\n";
  14. }
  15.  
  16. $network = 'example.com';
  17. $netport = 6667;
  18. $stealth = FALSE;
  19. $channel = '#channel';
  20. $ircnick = 'Pointed_stones';
  21. $ircuser = 'ofAWESOME';
  22. $privs = array('user@host');
  23. if(($destfile = parse_ini_file('.\\stealthrock.ini')) !== FALSE) {
  24.     if(isset($destfile['network'])) $network = $destfile['network'];
  25.     if(isset($destfile['port'])) $netport = $destfile['port'];
  26.     if(isset($destfile['nick'])) $ircnick = $destfile['nick'];
  27.     if(isset($destfile['username'])) $ircuser = $destfile['username'];
  28.     if(isset($destfile['channel'])) $channel = $destfile['channel'];
  29.     if(isset($destfile['owner'])) {
  30.         if(is_array($destfile['owner'])) $privs = $destfile['owner'];
  31.         else $privs = array($destfile['owner']);
  32.     }
  33. }
  34.  
  35. try {
  36.     if(($socket = fsockopen($network, $netport, $neterr1, $neterr2, 30)) == FALSE) throw new Exception("Could not connect to server.");
  37.  
  38.     send("NICK $ircnick");
  39.     send("USER $ircuser 8 olo :Stealth Rock");
  40.     $theindex = 0;
  41.     while(TRUE) {
  42.         while($text = fgets($socket)) {
  43.             if(!$text) {
  44.                 if($theindex > 3) throw new Exception("Timed out.");
  45.                 ++$theindex;
  46.             }
  47.             $theindex = 0;
  48.             echo $text;
  49.             $word = explode(' ', rtrim($text, "\r\n"));
  50.             if($word[0] == 'PING') {
  51.                 send("PONG ".$word[1]);
  52.                 continue;
  53.             }
  54.             $unick = substr($word[0], 1, strpos($word[0], '!') - 1);
  55.             $uhost = substr($word[0], strpos($word[0], '!') + 1);
  56.             if($word[2] == 'Pointed_stones') $udest = $unick;
  57.             else $udest = $word[2];
  58.             if(in_array($uhost, $privs)) $upower = TRUE;
  59.             else $upower = FALSE;
  60.  
  61.             if($word[1] == '001') {
  62.                 send("MODE Pointed_stones +B");
  63.                 send("JOIN $channel");
  64.             }
  65.             elseif($word[1] == '433') throw new Exception("Nickname in use.");
  66.             elseif($word[1] == 'JOIN' && $stealth) {
  67.                 sleep(2);
  68.                 send("dug into $unick"."!", 2);
  69.                 send("MODE $channel -ohv $unick $unick $unick");
  70.             }
  71.             elseif($word[1] == 'PRIVMSG') {
  72.                 if(strtolower(substr(implode(' ', array_slice($word, 3)), 2, 24)) == "action used stealth rock" && !$stealth && $udest[0] == '#') {
  73.                     $stealth = TRUE;
  74.                     send("float in the air around the opponent's team!", 2);
  75.                 }
  76.                 elseif((strtolower(substr(implode(' ', array_slice($word, 3)), 2, 22)) == "action used rapid spin" ||
  77.                     strtolower(substr(implode(' ', array_slice($word, 3)), 2, 17)) == "action used defog") && $stealth && $udest[0] == '#') {
  78.                     $stealth = FALSE;
  79.                     send("around your team disappeared!", 2);
  80.                 }
  81.                 elseif($word[3] == ":!sr") {
  82.                     if($upower) {
  83.                         switch(strtolower($word[4])) {
  84.                             case 'raw':
  85.                                 if(strtolower($word[5]) != 'quit') send(implode(' ', array_slice($word, 5)));
  86.                                 break;
  87.                             case 'quit':
  88.                                 if(isset($word[5])) send("QUIT :".implode(' ', array_slice($word, 5)));
  89.                                 else send("QUIT :Manual shutdown.");
  90.                             case 'die':
  91.                                 if(isset($word[5])) throw new Exception("Manual shutdown requested.\r\n-> MSG: ".implode(' ', arrayslice($word, 5)));
  92.                                 else throw new Exception("Manual shutdown requested.");
  93.                                 break;
  94.                             case 'say':
  95.                                 if(@$word[5][0] == '#') send(implode(' ', array_slice($word, 6)), 1, $word[5]);
  96.                                 else send(implode(' ', array_slice($word, 5)), 1, $udest);
  97.                                 break;
  98.                             case 'act':
  99.                                 if(@$word[5][0] == '#') send(implode(' ', array_slice($word, 6)), 2, $word[5]);
  100.                                 else send(implode(' ', array_slice($word, 5)), 2, $udest);
  101.                                 break;
  102.                         }
  103.                     } //if upower
  104.                 } //elif !sr
  105.             } //elif privmsg
  106.         } //while fgets
  107.     } //while true
  108. } catch (Exception $e) {
  109.     die("\r\nYou whited out...\r\n-> ".$e->getMessage()."\r\n");
  110. }
  111.  
  112. ?>
Advertisement
Add Comment
Please, Sign In to add comment