Author Topic: [PERL] Example of connecting to IRC & Sending commands  (Read 1695 times)

0 Members and 1 Guest are viewing this topic.

Offline uNk

  • Knight
  • **
  • Posts: 197
  • Cookies: 9
    • View Profile
[PERL] Example of connecting to IRC & Sending commands
« on: March 27, 2011, 01:22:54 am »
Here's an example of what ever the title says:

Code: [Select]
#!/usr/bin/perl
#Example of connecting to IRC.
 
use IO::Socket::INET ;
use LWP::UserAgent;
use LWP::Simple;
use XML::Simple;
 
 

my $server = "irc.evilzone.org";
my $port = "6667";
my $nick ="uNksBot";
my $name = "unk bot 8 *";
my $channel = "#evilzone";
 
system('cls');
system('title uNkBot');
print "\n\n\n\n Welcome.\n" ;
print "Activating... [Please wait]\n" ;
 
print " \n\n                                                    Version 1.0 \n\n";
print "\n [+] Now connecting to $server [Please wait]...\n";
 

$connection = IO::Socket::INET->new(PeerAddr=>"$server",
                                                PeerPort=>"$port",
                                                Proto=>'tcp',
                                                Timeout=>'30') or print " [!] Error $server\n";
print " [-] Now connected to $server [uNkBot]\n\n";
 
                                                       
print $connection "USER $name\n";
print $connection "NICK $nick\r\n";
 

while($response = <$connection>)
{
     
   print $response;
   
   
     if($response =~ m/:(.*) 00(.*) (.*) :/)
     {
          print $connection "JOIN $channel\r\n";
         }
 
   
        if($response =~ m/:!hey/)
                {
                print $connection "PRIVMSG $channel :Ohai\r\n";
                }
 
 
 
               
         if( $response =~ m/:(.*)!~(.*) JOIN :/)
         {
             my $rc = $1 ;
                 print $connection "PRIVMSG $channel :$rc <Welcome.\r\n";   
         }
 
               
        if( $response =~ m/:(.*)!~(.*) QUIT :/)
        {
         my $rc = $1 ;
                print $connection "PRIVMSG $channel :Bye.\r\n";     
        }
 
 
           
        if($response =~ m/^PING (.*?)$/gi)
        {
         print $connection "PONG ".$1."\r\n";
        }
}

If you want to add more commands without !hey, just add one more of these lines just edit it like this:

Code: [Select]
        if($response =~ m/:!bitch/)
                {
                print $connection "PRIVMSG $channel :No you.\r\n";
                }

Offline ande

  • Owner
  • Titan
  • *
  • Posts: 2664
  • Cookies: 256
    • View Profile
Re: [PERL] Example of connecting to IRC & Sending commands
« Reply #1 on: March 27, 2011, 01:46:15 am »
Sweet, I will for real have use of this for a Snort module ;)
if($statement) { unless(!$statement) { // Very sure } }
https://evilzone.org/?hack=true