BLACK BURN HACKER. Powered by Blogger.

Real Money Instantly

 

Saturday, January 28, 2012

[php] IRC Bot Skeleton

1 comments
This is my little skeleton i worked on through out the day as i had time.

<?php/*
  Author:  Blosh or PaT
  Intention: IRC Bot Skeleton
         Start with this and you can create anything from a channel bot to a bot for a net.

  My Sites: bl0sh.org
         l3ot.us
         bl0sh.tk
         security.bl0sh.tk
         paste.bl0sh.tk
        
  Shouts: hackhound.org
*/
$bot_nick = "Blosh";
$nick = $bot_nick;//.randNum(1000,9999);
$chan = "#l3ot";
$master = "Blosh";
$masteru= "Blosh";

$s = stream_socket_client("tcp://irc-creative-developments.org:6667", $eno, $estr, 45);
function randNum($low, $high){  
         return mt_rand($low, $high);
}
function cleanwhitespace($str){
  $a = str_replace("\r","", $str);
  $a = str_replace("\n","", $a);
  $a = str_replace("\t","", $a);

  return $a;
}
function commands($usr, $target, $msg, $fromNotice = false){
  global $s;
  if ($fromNotice == true){
   $action = "NOTICE";
  }else{
   $action = "PRIVMSG";
  }
  if ($msg == ";die"){
   fwrite($s, "$action $target :Goodbye.\n");
   fclose($s);
   die("kill by ".$usr['nick']);
  }
  if ($msg == ";help"){
   fwrite($s, "$action $target :For help on a certain command: ;help (COMMAND)\n");
   fwrite($s, "$action $target :For a list of availible commands: ;commands\n");
  }elseif(substr($msg, 0, 6) == ";help "){
   $a = explode(";help ", $msg);
   $cmd = $a[1];
   switch($cmd){
        case "die";
         fwrite($s, "$action $target :HELP - COMMAND: $cmd - Closes irc connection and kills self.\n"); 
         fwrite($s, "$action $target :USAGE: ;die\n");  
        break;
   }
  }

  if($msg == ";commands"){
   fwrite($s, "$action $target :COMMAND: die - Closes irc connection and kills self.\n");       
   fwrite($s, "$action $target :USAGE: ;die\n");        
   sleep(1.5);
   fwrite($s, "$action $target :COMMAND: help - Closes irc connection and kills self.\n");      
   fwrite($s, "$action $target :USAGE: ;help [command]\n");     
   sleep(1.5);
   fwrite($s, "$action $target :COMMAND: commands - Lists all availible commands.\n");  
   fwrite($s, "$action $target :USAGE: ;commands\n");   
   //sleep(1.5);
  }
}
if (!$s){
  echo "error\r\n";
}else{  
  echo "\r\n\r\nconnected\r\n\r\n";
  fwrite($s, "NICK $nick\n");
  fwrite($s, "USER $nick \"\" \"\" :$nick\n");
  fwrite($s, "JOIN $chan\n");
  while (!feof($s)) {
   $d = fgets($s, 2048);
   echo $d;
   if( preg_match("/^PING :(?<pong>.*)$/i", $d, $m) ){
        fwrite($s, "PONG :".$m['pong']."\n");
   }
   /*
   :Blosh!Blosh@creative-developments-8348AC.dhcp.thtn.ga.charter.com $action #l3ot :;die
   */
   $d = cleanwhitespace($d);
  
   if( preg_match("/^:(?<nick>.*)!(?<usr>.*)@(?<usrhost>.*) PRIVMSG (?<chan>.*) :(?<msg>.*)$/i", $d, $m) ){
        $usr = array(
                "nick" => $m['nick'], "user" => $m['usr'], "host" => $m['host']
           );
  
        if ( $usr['nick'] == $master ){
         if ( $usr['user'] == $masteru ){
          if ($m['chan'] == $nick){ $m['chan'] = $usr['nick']; }
          commands($usr, $m['chan'], $m['msg'], false);
         }      
        }
  
  
   }elseif (preg_match("/^:(?<nick>.*)!(?<usr>.*)@(?<usrhost>.*) NOTICE (?<chan>.*) :(?<msg>.*)$/i", $d, $m)) {
        $usr = array(
                "nick" => $m['nick'], "user" => $m['usr'], "host" => $m['host']
           );
  
        if ( $usr['nick'] == $master ){
         if ( $usr['user'] == $masteru ){
          commands($usr, $m['nick'], $m['msg'], true);
         }      
        }
   }
  
  } //end while

  echo "\r\n\r\nclosed\r\n\r\n";
}
?>

http://l3ot.us/bot.txt

©2011, copyright BLACK BURN

1 comments:

  1. IRCFOrumlari is an independent organization from all individuals which is being given service about Turkish ircd and IRC Forums.

    ReplyDelete

 

7 Years Earning Experience

The Earning Source You Can Trust

Follow by Email