Advertisement
Guest User

Bot Boom

a guest
Mar 9th, 2012
557
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.21 KB | None | 0 0
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. use IO::Socket;
  5. use LWP::UserAgent;
  6. use Encode;
  7.  
  8. #ตั้งค่าบอท
  9. my $server = "irc.pong-host.com"; #เซิฟเวอร์ IRC นะครับ
  10. my $login = "Boom_Bot"; #username นะแหละ
  11. my $owner = "Bongtrop"; #ชื่อเจ้าของเอาไว้สั่งครับ
  12. my $channel = "#Bongtrop"; #ห้องของห้อง
  13. my $shell="http://103.22.180.158/bot_boom.php";
  14. my $nick;
  15.  
  16. my $pid=fork();
  17. my $thr=0;
  18.  
  19. #เชื่อมต่อ
  20. my $sock = new IO::Socket::INET(PeerAddr => $server,
  21. PeerPort => 6667,
  22. Proto => 'tcp') or
  23. die "ไม่สามารถเชื่อมต่อได้\n";
  24.  
  25. if ($pid) {
  26. $nick="BotBoom_Command";
  27. }
  28. elsif ($pid==0) {
  29. $nick="BotBoom_Run";
  30. } else {
  31. print $sock "PRIVMSG ",$channel," :[-] MultiProcress Error\r\n";
  32. }
  33.  
  34. my $ua = LWP::UserAgent->new();
  35. $ua->agent("Mozilla/5.0 (Windows; U; Windows NT 5.1; en; rv:1.9.0.4) Gecko/2008102920 Firefox/3.0.4");
  36.  
  37. #function Save LOG
  38. sub saveLOG {
  39. open LOG,">>log.txt";
  40. (my $str,my $own)=@_;
  41. if ($str eq "START") {
  42. $str="Procress in ".localtime." by ".$own."\n";
  43. }
  44. elsif ($str eq "END") {
  45. $str="------------------------END PROCRESS------------------------\n\n";
  46. }
  47. $str = encode("utf-8", decode("tis-620", $str));
  48. print LOG $str;
  49. close LOG;
  50. }
  51.  
  52. my $firstID;
  53.  
  54. #function SMF
  55. sub smf {
  56. saveLOG("START","Bot");
  57. my $url="http://picpost.mthai.com/category/sexy-girl";
  58. print $sock "PRIVMSG ",$channel," :7[+] เริ่มทำการดึงจากเว็บ $url\r\n";
  59. saveLOG("[+] เริ่มทำการดึงจากเว็บ $url\n");
  60. my $respone=$ua->get($url);
  61.  
  62. my @line=split(/\n/,$respone->content);
  63. my $c=0;
  64. foreach (@line) {
  65. if ((my $id)=$_=~/<h4><a href=\"\/view\/(.*)\" title=/) {
  66.  
  67. my $lastid;
  68. open INFILE,"id.txt";
  69. while (<INFILE>) {
  70. chomp;
  71. $lastid=$_;
  72. }
  73. close INFILE;
  74. if ($lastid eq $id) {
  75. print $sock "PRIVMSG ",$channel," :4[-] ไม่พบหัวข้อ Picpost ใหม่ฮะ\r\n";
  76. saveLOG ("[-] ไม่พบหัวข้อ Picpost ใหม่ฮะ\n","Bot");
  77. last;
  78. }
  79. if ($c==0) {
  80. open OUTFILE,">id.txt";
  81. print OUTFILE $id;
  82. close OUTFILE;
  83. }
  84.  
  85. $url="http://picpost.mthai.com/view/".$id;
  86. $respone=$ua->get($url);
  87. my ($subject)=$respone->content=~/<title>(.*) \| picpost/;
  88. my @line2=split(/\n/,$respone->content);
  89.  
  90. my $outsj = encode("tis-620", decode("utf-8", $subject));
  91.  
  92. print $sock "PRIVMSG ",$channel," :7[-] พบหัวข้อ Picpost $outsj ไอดี $id\r\n";
  93. saveLOG ("[-] พบหัวข้อ Picpost $outsj ไอดี $id\n","Bot");
  94. my $body="<center>";
  95. foreach (@line2) {
  96. if ((my $pic)=$_=~/<a href=\"\/pic\/$id\/(.*)\" class=\"fullsize\"/) {
  97. $body.='<img src="http://picpost.mthai.com/pic/'.$id.'/'.$pic.'"><br>';
  98. }
  99. }
  100. $body.='</center>';
  101. if ($subject=~/Page not found/ or $subject eq "" or $body eq "" or $body=~/Page not found/) {
  102. print $sock "PRIVMSG ",$channel," :4[-] เว็บ Mthai มีปัญหาเลยลามมาหากระปมเลย ><\r\n";
  103. saveLOG ("[-] เว็บ เดลินิวมีปัญหาเลยลามมาหากระปม ><\n","Bot");
  104. last;
  105. }
  106. $respone = $ua->post($shell,["subject"=>$subject,"body"=>$body,"idBoard"=>3]);
  107. print $sock "PRIVMSG ",$channel," :7[+] อัพโหลดสู่ SMF ".$respone->content."\r\n";
  108. saveLOG ("[+] อัพโหลดสู่ SMF ".$respone->content."\n","Bot");
  109. $c++;
  110. }
  111. }
  112. print $sock "PRIVMSG ",$channel," :7[+] รอสักครู่จะรันอีกทีนะฮะ ทำเรื่อยๆเดียวโดนบ๊อก\r\n";
  113. saveLOG ("[+] รอสักครู่จะรันอีกทีนะฮะ ทำเรื่อยๆเดียวโดนบ๊อก\n","Bot");
  114. saveLOG ("END","Bot");
  115. }
  116.  
  117. print $sock "NICK $nick\r\n";
  118. print $sock "USER $login 8 * :I'm botSMF\r\n";
  119.  
  120. while (my $input = <$sock>) {
  121. if ($input =~ /004/) {
  122. last;
  123. }
  124. elsif ($input =~ /433/) {
  125. die "4[-] ชื่อถูกใช้ไปแล้ว";
  126. }
  127. }
  128.  
  129. #เข้าสู่ห้อง
  130. print $sock "JOIN $channel\r\n";
  131.  
  132. my $count=0;
  133.  
  134. if ($pid) {
  135. while (my $input = <$sock>) {
  136. chop $input;
  137. chop $input;
  138. #ส่งค่ากลับเมื่อมีการ ping มา จาก server
  139. if ($input=~/PING/) {
  140. (my $pong)=$input=~m/PING (.*)/;
  141. print $sock 'PONG '.$pong." : \r\n";
  142. if ($thr==1 and $count>10) {
  143. $count=0;
  144. print $sock "PRIVMSG ",$channel," :12[+] กำลังเริ่มสั่งให้มันรัน อาจจะสั่งงานไม่ได้ซัก 2-5 วินาที รอแปปนะ\r\n";
  145. sleep 3;
  146. print $sock "PRIVMSG ",$channel," :9qcp34iwfipoj230cjaesff323r0ijasdfj2r0irskfjasv\r\n";
  147. }
  148. $count++;
  149. }
  150. if ($input=~/^\:$owner\!/ or $input=~/^\:thejestei2\!/) {
  151. (my $own)=$input=~/^\:(.*)\!/;
  152. saveLOG("START",$own);
  153. saveLOG($input."\n",$own);
  154. saveLOG("END",$own);
  155. if ($input=~/ปิดระบบ/) {
  156. print $sock "PRIVMSG ",$channel," :4[-] เริ่มทำการปิดระบบ\r\n";
  157. kill 'KILL' => $pid;
  158. last;
  159. }
  160. if ($input=~/ทดสอบ/) {
  161. print $sock "PRIVMSG ",$channel," :3เรียบร้อยทุกอย่างฮะ >< \r\n";
  162. }
  163. if ($input=~/ถอย/) {
  164. $thr=0;
  165. print $sock "PRIVMSG ",$channel," :4[-] สั่งให้บอทหยุดดึงเรียบร้อยแล้วฮะ \r\n";
  166. }
  167. if ($input=~/กี่cแล้ววะแม้ง/) {
  168. print $sock "PRIVMSG ",$channel," :4[!] อย่าพึ่งโกรธสิฮะ ตอนนี้ $count c แล้วฮะจักกะแปปป\r\n";
  169. }
  170. if ($input=~/คำสั่ง/) {
  171. print $sock "PRIVMSG ",$channel," :12[+] มีคำสั่ง 6 คำสั่ง\r\n";
  172. print $sock "PRIVMSG ",$channel," :\r\n";
  173. print $sock "PRIVMSG ",$channel," :3 1) ลุย ใช้เริ่มทำงาน\r\n";
  174. print $sock "PRIVMSG ",$channel," :3 2) สถานะ ตรวจสอบสถานะ Bot\r\n";
  175. print $sock "PRIVMSG ",$channel," :3 4) ไอดี ใช้ตรวจสอบไอดีล่าสุดของข่าว\r\n";
  176. print $sock "PRIVMSG ",$channel," :3 5) แก้ไอดี ใช้สำหรับแก้ไขไอดีล่าสุดของข่าว\r\n";
  177. print $sock "PRIVMSG ",$channel," :3 5) ถอย ใช้หยุดการทำงาน Bot ไม่ให้ดึงข่าว\r\n";
  178. print $sock "PRIVMSG ",$channel," :3 6) ล๊อก ใช้สำหรับเช๊คล๊อกว่ามะอะไรเปลี่ยนแปลงไปบ่าง\r\n";
  179. print $sock "PRIVMSG ",$channel," :3 7) ลบล๊อก ใช้สำหรับเคลียล๊อกที่ผ่านมา\r\n";
  180. print $sock "PRIVMSG ",$channel," :3 8) ปิดระบบ ใช้ออกจาก IRC\r\n";
  181. }
  182. if ($input=~/ลุย/) {
  183. print $sock "PRIVMSG ",$channel," :9qcp34iwfipoj230cjaesff323r0ijasdfj2r0irskfjasv\r\n";
  184. print $sock "PRIVMSG ",$channel," :12[+] สั่งงาน BotSMF_Run เรียบร้อยแล้ว\r\n";
  185. $thr=1;
  186. }
  187. if ($input=~/ลบล๊อก/) {
  188. unlink("log.txt");
  189. print $sock "PRIVMSG ",$channel," :12[+] ลบล๊อกสำเร็จแล้วฮะ ><\r\n";
  190. }
  191. elsif ($input=~/ล๊อก/) {
  192. print $sock "PRIVMSG ",$channel," :12[+] ไฟย์ล๊อก ก็ ไฟย์ log.txt ดูด้านข้าง";
  193. }
  194. if ($input=~/สถานะ/) {
  195. if ($thr==0) {
  196. print $sock "PRIVMSG ",$channel," :4[-] Bot ยังไม่ได้เริ่มทำงาน\r\n";
  197. } else {
  198. print $sock "PRIVMSG ",$channel," :12[+] Bot กำลังทำงานอยู่\r\n";
  199. }
  200. }
  201. if ((my $idedit)=$input=~/แก้ไอดีเป็น (.*)/) {
  202. open OUTFILE,">id.txt";
  203. print OUTFILE $idedit;
  204. close OUTFILE;
  205. print $sock "PRIVMSG ",$channel," :12[+] ทำการแก้ไอดีเป็น $idedit เสร็จแล้ว\r\n";
  206. }
  207. elsif ($input=~/ไอดี/) {
  208. open INFILE,"id.txt";
  209. my $sid;
  210. while (<INFILE>) {
  211. $sid=$_;
  212. }
  213. close INFILE;
  214. print $sock "PRIVMSG ",$channel," :12[+] ไอดีล่าสุดคือ $sid\r\n";
  215. }
  216. }
  217. }
  218. }
  219. elsif ($pid==0) {
  220. while (my $input = <$sock>) {
  221. chop $input;
  222. chop $input;
  223. if ($input=~/PING/) {
  224. (my $pong)=$input=~m/PING (.*)/;
  225. print $sock 'PONG '.$pong." : \r\n";
  226. }
  227. if ($input=~/^\:BotBoom_Command\!/) {
  228. if ($input=~/9qcp34iwfipoj230cjaesff323r0ijasdfj2r0irskfjasv/) {
  229. smf();
  230. }
  231. }
  232. }
  233. } else {
  234. print $sock "PRIVMSG ",$channel," :4[-] MultiProcress Error\r\n";
  235. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement