Underc0de

Programación Web => Back-end => Mensaje iniciado por: WHK en Abril 26, 2013, 04:23:50 PM

Título: Robot interpretador de php en el IRC de Underc0de
Publicado por: WHK en Abril 26, 2013, 04:23:50 PM
Hoy ingresé al irc de underc0de y pensé que nunca habia hecho un robot para irc a pesar de lo facil que era el protocolo de comunicación, asi que me decidí a hacer uno :) e interpreta código php :D de cualquier persona que le escriba:

[php] codigo_aca();

Por ejemplo
[php] echo 'hola';

Citar[15:44] <@ANTRAX> [php] $a="C"; $b="X"; if ($a<$b) { echo $a."is smaller than".$b; }
[15:44] <Robot_PHP> Interpretando ...
[15:45] <Robot_PHP> cis smaller thanx
[15:45] <@ANTRAX> nice!

Acá les dejo el código fuente, está hecho en php :)
Pueden modificarlo para crear sus propias respuestas automatizadas.

Enjoy.

Código (php) [Seleccionar]
<plaintext><?php
set_time_limit
(0);

$nick 'Robot_PHP';
$canal '#Underc0de';
$isLogged false;

$fp fsockopen('irc.freenode.net'8000);

$buffer '';

while (!
feof($fp)){
$buffer trim((string)fgets($fp2048));

if((!$isLogged) and (substr($buffer01) === ':')){
$isLogged true;
fwrite($fp'USER '.$nick.' '.$nick.' '.$nick.' '.$nick."\n");
fwrite($fp'NICK '.$nick."\n");
fwrite($fp'JOIN '.$canal."\n");

fwrite($fp'PRIVMSG '.$canal.' :.                                 .'."\n");
fwrite($fp'PRIVMSG '.$canal.' :            ,-,,-,   __             '."\n");
fwrite($fp'PRIVMSG '.$canal.' :     ______/     /_,\'  |           '."\n");
fwrite($fp'PRIVMSG '.$canal.' :     \______WHK_______/            '."\n");
fwrite($fp'PRIVMSG '.$canal.' :          |\) (/ |                 '."\n");
fwrite($fp'PRIVMSG '.$canal.' :       (  | oo   |                 '."\n");
fwrite($fp'PRIVMSG '.$canal.' :        ) `|  |--\'                 '."\n");
fwrite($fp'PRIVMSG '.$canal.' :       (___^^^^|                   '."\n");
fwrite($fp'PRIVMSG '.$canal.' :          (____\'                   '."\n");
fwrite($fp'PRIVMSG '.$canal.' :.                                 .'."\n");
  
fwrite($fp'PRIVMSG '.$canal.' :Hola soy el robot de WHK, tengo la capacidad de interpretar código php :)'."\n");
fwrite($fp'PRIVMSG '.$canal.' :ejemplo: [php] micodigo();'."\n");
fwrite($fp'PRIVMSG '.$canal.' :Recuerda escribir todo en una sola linea.'."\n");
}

$f explode(strtolower(' PRIVMSG '.$canal.' :'), strtolower($buffer));
if(count($f) === 2){
$msg trim($f[1]);

if(substr($msg06) === '[php] '){
fwrite($fp'PRIVMSG '.$canal.' :Interpretando ...'."\n");

$code file_get_contents('http://codepad.org/'falsestream_context_create(array(
'http' =>
array(
'method'  => 'POST',
'header'  => 'Content-type: application/x-www-form-urlencoded',
'content' => http_build_query(
array(
'lang' => 'PHP',
'run' => 'True',
'submit' => 'Submit',
'code' => '<'.'?php '.substr($msg6)
)
)
)
)));

$code explode('<a name="output">'$code);
$code explode('<td width="100%" style="vertical-align: top">'$code[1]);
$code explode('<div class="highlight">'$code[1]);
$code explode('<pre>'$code[1]);
$code explode('</pre>'$code[1]);
$code str_replace(array("\n""\r""\b""\x00"), ' 'trim(htmlspecialchars_decode(strip_tags($code[0]), ENT_QUOTES)));
fwrite($fp'PRIVMSG '.$canal.' :'.$code."\n");
}

unset($msg);
}
unset($f);

// echo $buffer."\n";

/* PING */
if(strtolower(substr($buffer06)) === 'PING :'){
$host explode(':'$buffer);
$host trim($host[1]);
fwrite($fp'PONG :'.$host."\n");
unset($host);
}

}
fclose($fp);
Título: Re:Robot interpretador de php en el IRC de Underc0de
Publicado por: ANTRAX en Abril 26, 2013, 04:45:39 PM
Esta excelente WHK!
Muchisimas gracias!
+Karma!