PHP код:
<?php
// Prevent PHP from stopping the script after 30 sec
set_time_limit(0);
$time = time();
//Connect to server
$socket = fsockopen('irc.unkn0wn.eu',6667,$a=null,$a=null,10);
// Send auth info
fputs($socket,"USER Gnome-Bot Gnome^Bot.gnomex.net Gnomex's bot :Gnome bot\n");
fputs($socket,"NICK Gnome-bot\n");
fputs($socket,"PRIVMSG nickserv identify <your pass here>\n");
// Join channel
fputs($socket,"JOIN #unkn0wn\n");
// Force an endless while
while(1) {
// Continue the rest of the script here
while($data = fgets($socket, 1024)) {
echo nl2br($data);
flush();
// Separate all data
$ex = explode(' ', $data);
// Send PONG back to the server
if($ex[0] == "PING"){
send("PONG ".$ex[1]."\n");
}
//rejoin when kicked
if (strpos($line, "KICK ".$channel." ".$nickname)>0){
fwrite($socket, "JOIN ".$channel."\r\n");
}
//respond to ctcp version
if (strpos($line, "PRIVMSG ".$nickname." :\100VERSION\100\r\n")>0){
$nick = substr($line, 0, strpos($line, "!"));
$nick = str_replace(":", "", $nick );
fwrite($socket, "NOTICE ".$nick." :\001Gnomex's bot\001\r\n");
}
//Send Version
if($command == ":!version"){
send("PRIVMSG $ex[2] mIRC Exploit Database. Coded By Gnomex For Zloche.net\n");
logwrite("$ex[0] Executed Version \n");
}
//Milw0rm search command.
$milw0rm1 = explode(':!milw0rm',$data,2);
$milw0rm2 = str_replace( array( "\r", "\n", "\t" ), "", $milw0rm1[1]);
$command = str_replace(array(chr(10), chr(13)), '', $ex[3]);
if($command == ":!milw0rm"){
cURL( "http://milw0rm.com/search.php", $milw0rm, "dong=".$milw0rm2. "&Submit=Submit" );
$milw0rm = str_replace( array( "\r", "\n", "\t" ), "", $milw0rm );
eregi( "<td nowrap=\"nowrap\" width=\"375\"><a href=\"/exploits/(.*)\" target=\"_blank\" class=\"style14\">(.*)</a></td><td nowrap=\"nowrap\" width=40 align=\"left\">(.*)</td><td nowrap=\"nowrap\" width=\"9\" valign=\"middle\" align=\"center\">", $milw0rm, $matches );
$url = "http://www.milw0rm.com/exploits/" . (int) $matches[1];
$exploit = $matches[2];
send("PRIVMSG $ex[2] Exploit:".$exploit." | URL: ".$url."\n");
logwrite("$ex[0] Executed milw0rm search with $milw0rm2\n");
}
//commands you need to be admin for
// inser the hostmasks for your admins below. find them by loading the bot in your browser then speaking to it, the browser will look like this: :electronix!Gnomex@PlayBoy-33A1DF94.ganja.nl etc. the first bit is what you insert.
$hosts = array(':Gnomex!~dblencowe@gnomex.net');
if(in_array( $ex[0], $hosts)){
//Remote Quit
if($command == ":!stop"){
send("PRIVMSG $ex[2] Bot stopped!\n");
logwrite("$ex[0] Stopped the bot\n");
die();
}
// Join a channel
$joinchan = explode(':!join',$data,2);
$joinchan = $joinchan[1];
$command = str_replace(array(chr(10), chr(13)), '', $ex[3]);
if ($command == ":!join") {
send("JOIN $joinchan\n");
logwrite("$ex[0] joined bot to $joinchan\n");
}
// Part a channel
$partchan = explode(':!part',$data,2);
$partchan = $partchan[1];
$command = str_replace(array(chr(10), chr(13)), '', $ex[3]);
if ($command == ":!part") {
send("PART $partchan\n");
logwrite("$ex[0] parted the bot from $partchan\n");
}
//Change Nick
if ($command == ":!nick"){
$nickname = explode(':!nick',$data,2);
$nickname = $nickname[1];
send("NICK $nickname");
logwrite("$ex[0] chanegd bots nick to $nickname\n");
}
// Say something in the channel
$tobesaid = explode(':!sayit',$data,2);
$tobesaid = $tobesaid[1];
$command = str_replace(array(chr(10), chr(13)), '', $ex[3]);
if ($command == ":!sayit") {
send("PRIVMSG $tobesaid\n");
}
//Register the bot on the channel
if($command == ":!register"){
send("PRIVMSG nickserv register <your pass here> bot@gnomex.net\n");
send("PRIVMSG $ex[2] Nick registered\n");
logwrite("$ex[0] registered the bots nickname on $server\n");
}
}
usleep(100000);
}
}
function send($str)
{
global $socket;
fwrite($socket,$str.chr(10));
echo '<< '.$str . "\r\n";
}
//Write Logs
function logwrite($logdata){
$myFile = "botlog.txt";
$fh = fopen($myFile, 'a') or die("can't open file");
$stringData = $logdata;
fwrite($fh, $stringData);
fclose($fh);
}
//Curl Function
function cURL( $page, &$result, $postFields = "", $headers = "" )
{
$ch = curl_init( $page );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, TRUE );
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, TRUE );
if( !empty( $postFields ) )
{
curl_setopt( $ch, CURLOPT_POST, TRUE );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $postFields );
}
if( !empty( $headers ) && is_array( $headers ) )
curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers );
$result = curl_exec( $ch );
curl_close( $ch );
return $result;
}
?>