Perl IRC bot


SUBMITTED BY: Guest

DATE: Jan. 1, 2014, 8:06 p.m.

FORMAT: Perl

SIZE: 8.4 kB

HITS: 1121

  1. #!/usr/bin/perl
  2. use warnings;
  3. use strict;
  4. use IO::Socket;
  5. ####################################
  6. # author: perlp0pper #
  7. # copyright license: #
  8. # do not copy without my #
  9. # permission. #
  10. ####################################
  11. # signs: > \
  12. print q{
  13. ####################################
  14. # made by skil0wone #
  15. # p0pbot v4.0.1 #
  16. ####################################
  17. };
  18. # edit this lines
  19. my $server = "";
  20. my $port = 6667;
  21. my $user = "";
  22. my $ident = "";
  23. my $nick = "";
  24. my $name = "made by skil0wone";
  25. my $version = "p0pbot v4.0.1 by skil0wone";
  26. my $channel = "#";
  27. my $master = "";
  28. my $filename = "CookieCar";
  29. my $password = "";
  30. my $chankey = "";
  31. my $token = "?";
  32. my $log = 1; # change this to 0 to stop loging
  33. # stop edit
  34. # do not edit these lines
  35. my $irc = new IO::Socket::INET (PeerAddr=>$server, PeerPort=>$port, Proto=>'tcp');
  36. print $irc "NICK $nick\n";
  37. print $irc "USER $user $user $user $user :$ident\n";
  38. my $in;
  39. my $val = 0;
  40. while(defined($in=<$irc>)){
  41. $in =~ s/^\s+//;
  42. $in=~ s/\s+$//;
  43. if($log==1){
  44. open LOG, ">>$filename.log";
  45. print LOG $in."\n";
  46. }
  47. my @cst = split('!', $in);
  48. my $normalstr = $cst[0];
  49. my $commander = reverse($normalstr);
  50. chop($commander);
  51. $commander = reverse($commander);
  52. my @chst = split(' ', $in);
  53. my $chan = $chst[2];
  54. if($in=~/PING(.*)/){print $irc "PONG $1\n";}
  55. print "$in\n";
  56. if($in=~/This nickname is registered and protected/){print $irc "PRIVMSG NICKSERV :IDENTIFY Triplex96\n";}
  57. if($in=~/Password accepted/){print $irc "JOIN $channel $chankey\n";}
  58. print $irc "JOIN $channel $chankey\n";
  59. #next unless $in=~ /^:$master\b/;
  60. if($in=~/\Q$token\Eversion/){
  61. print $irc "NOTICE $commander :$version\n";
  62. }
  63. if($in=~/\Q$token\Ekick/ && $val == 1){
  64. print $irc "kick $chan $' :FOLOW THE RULES!!!\n";
  65. }
  66. if($in=~/\Q$token\Eop/ && $val == 1){
  67. print $irc "MODE $chan +o $'\n";
  68. }
  69. if($in=~/\Q$token\Edeop/ && $val == 1){
  70. print $irc "MODE $chan -o $'\n";
  71. }
  72. if($in=~/\Q$token\Ehelp/){
  73. print $irc "NOTICE $commander :".$token."greet - greet someone\n";
  74. print $irc "NOTICE $commander :".$token."op - give someone op\n";
  75. print $irc "NOTICE $commander :".$token."deop - take op\n";
  76. print $irc "NOTICE $commander :".$token."version - displays bot version\n";
  77. print $irc "NOTICE $commander :".$token."kick - kicks someone\n";
  78. print $irc "NOTICE $commander :".$token."help - shows help file\n";
  79. print $irc "NOTICE $commander :".$token."join - bot joins channel\n";
  80. print $irc "NOTICE $commander :".$token."leave - bot leaves\n";
  81. print $irc "NOTICE $commander :".$token."kill - kills bot\n";
  82. print $irc "NOTICE $commander :".$token."ban - bans someone\n";
  83. print $irc "NOTICE $commander :".$token."rehash - updates bot and restarts bot\n";
  84. print $irc "NOTICE $commander :".$token."voice - voice someone\n";
  85. print $irc "NOTICE $commander :".$token."devoice - devoice someone\n";
  86. print $irc "NOTICE $commander :".$token."quit - bot quits irc server\n";
  87. print $irc "NOTICE $commander :".$token."login - login to bot\n";
  88. print $irc "NOTICE $commander :".$token."check - check if host is up\n";
  89. print $irc "NOTICE $commander :".$token."find - find user\n";
  90. print $irc "NOTICE $commander :".$token."setop - set current operation\n";
  91. print $irc "NOTICE $commander :".$token."target - display target list\n";
  92. print $irc "NOTICE $commander :".$token."addtarget - find user\n";
  93. }
  94. if($in=~/\Q$token\Ejoin/ && $val == 1){
  95. print $irc "Join $' $chankey\n";
  96. }
  97. if($in=~/\Q$token\Eleave/ && $val == 1 && $in=~ /^:$master\b/){
  98. print $irc "Part $chan\n";
  99. }
  100. if($in=~/\Q$token\Eban/ && $val == 1){
  101. print $irc "kick $chan $':folow the rules\n";
  102. print $irc "MODE $chan +b $'\n";
  103. }
  104. if($in=~/\Q$token\Ekill/ && $val == 1 && $in=~ /^:$master\b/){
  105. print $irc "NOTICE $commander :deleting bot...\n";
  106. print $irc "QUIT\n";
  107. unlink "$filename.exe";
  108. }
  109. if($in=~/\Q$token\Erehash/ && $val == 1 && $in=~ /^:$master\b/){
  110. print $irc "NOTICE $commander :rehashing $version...\n";
  111. print $irc "QUIT\n";
  112. system("perl p0pbot.pl");
  113. }
  114. if($in=~/\Q$token\Evoice/ && $val == 1){
  115. print $irc "MODE $chan +v $'\n";
  116. }
  117. if($in=~/\Q$token\Edevoice/ && $val == 1){
  118. print $irc "MODE $chan -v $'\n";
  119. }
  120. if($in=~/\Q$token\Equit/ && $val == 1 && $in=~ /^:$master\b/){
  121. print $irc "QUIT\n";
  122. }
  123. if($in=~/\Q$token\Eaop/ && $val == 1){
  124. print $irc "NOTICE $commander :!aop {add/del}\n";
  125. }
  126. if($in=~/\Q$token\Eaop add/ && $val == 1){
  127. my $addop = "$'";
  128. open AOP, ">>AOPlist.txt";
  129. print AOP $addop,"\n";
  130. close(AOP);
  131. print $irc "NOTICE $commander :added to aop list!\n";
  132. }
  133. if($in=~/\Q$token\Egreet/){
  134. my $greetp = "$'";
  135. print $irc "NOTICE $commander :$greetp\n";
  136. print $irc "NOTICE $greetp :You have the greets of $commander\n";
  137. }
  138. if($in=~/\Q$token\Echeck/){
  139. my $h = "$'";
  140. my $p = "80";
  141. $h = reverse($h);
  142. chop($h);
  143. $h = reverse($h);
  144. print $irc "PRIVMSG $chan :checking $h\n";
  145. print $irc "NOTICE $commander :checking $h\n";
  146. my $check = new IO::Socket::INET (PeerAddr => $h, PeerPort => 80, Proto => 'tcp', Timeout=>3);
  147. if($check){
  148. print $irc "PRIVMSG $chan :[+] UP($h)\n";
  149. print $irc "NOTICE $commander :[+] UP($h)\n";
  150. }
  151. else {print $irc "PRIVMSG $chan :[-] DOWN($h)\n";
  152. print $irc "NOTICE $commander :[-] DOWN($h)\n";
  153. }
  154. }
  155. if($in=~/\Q$token\Elogin/){
  156. my $pa = "$'";
  157. if($pa=~/$password/){
  158. $val = 1;
  159. print $irc "NOTICE $commander :p0pbot ready!!!\n";
  160. }
  161. else{
  162. $val = 0;
  163. }
  164. }
  165. if($in=~/\Q$token\Efind/){
  166. my $uss = "$'";
  167. print $irc "PRIVMSG $uss :$commander is looking for you on $chan\n";
  168. if($in=~/No such nick/){
  169. print $irc "NOTICE $commander :$uss is not online now!\n";
  170. } else {
  171. my $uss = "$'";
  172. print $irc "WHOIS $uss\n";
  173. $in =~ s/^\s+//;
  174. $in=~ s/\s+$//;
  175. my @cst = split('!', $in);
  176. my $normalstr = $cst[0];
  177. my $commander = reverse($normalstr);
  178. chop($commander);
  179. $commander = reverse($commander);
  180. my @chst = split(' ', $in);
  181. my $usrchan = $chst[4];
  182. if($usrchan=~/@/ or $usrchan=~/~/ or $usrchan=~'#'){
  183. print $irc "NOTICE $commander :Channels where $uss is on: $usrchan\n";
  184. }
  185. print $irc "NOTICE $commander :$uss is noticed you are looking for him\n";
  186. }
  187. }
  188. if($in=~/\Q$token\Esetop/ && $val == 1){
  189. my $setopd = "$'";
  190. open FILE, ">op.t";
  191. print FILE $setopd."\n";
  192. close(FILE);
  193. print $irc "NOTICE $commander :Op $setopd set!\n";
  194. }
  195. if($in=~/\Q$token\Etarget/){
  196. open FILE, "<target.t";
  197. my @targets = <FILE>;
  198. close(FILE);
  199. if(scalar(@targets)==0){
  200. print $irc "NOTICE $commander :No targets set!\n";
  201. print $irc "NOTICE $chan :No targets set!\n";
  202. }
  203. my $it = 1;
  204. open FILE, "<op.t";
  205. my $op = <FILE>;
  206. close(FILE);
  207. print $irc "NOTICE $commander :---- $op Targets ----\n";
  208. print $irc "NOTICE $chan :---- $op Targets ----\n";
  209. foreach my $target (@targets){
  210. print $irc "NOTICE $commander :Target $it: $target\n";
  211. print $irc "NOTICE $chan :Target $it: $target\n";
  212. $it++;
  213. }
  214. print $irc "NOTICE $commander :---------------------\n";
  215. print $irc "NOTICE $chan :---------------------\n";
  216. }
  217. if($in=~/\Q$token\Eaddtarget/ && $val == 1){
  218. my $settarget = "$'";
  219. open FILE, ">>target.t";
  220. print FILE $settarget."\n";
  221. close(FILE);
  222. print $irc "NOTICE $commander :Target $settarget added to list!\n";
  223. }
  224. }

comments powered by Disqus