Advertisement
Guest User

Untitled

a guest
Mar 24th, 2016
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.77 KB | None | 0 0
  1. z<?php
  2. /**
  3. * Free xat bot release
  4. * - Author: Ethan (xat.me/Xubuntu)
  5. * - Complexity: BASIC
  6. * - Bypass: NO (Rquires bot power)
  7. * ----------------------------------------
  8. * - WILL NOT provide assistance.
  9. * - WILL NOT write commands.
  10. * - WILL NOT write packet handlers.
  11. * ----------------------------------------
  12. * - * Python verson -> http://pastebin.com/L2tWppdd
  13. * ----------------------------------------
  14. * -Update Log
  15. * - 10/10/2015
  16. * -Updated server IPs
  17. *
  18. *
  19. **/
  20. set_time_limit(0);
  21. error_reporting(E_ALL);
  22. date_default_timezone_set(@date_default_timezone_get());
  23.  
  24. new bot();
  25.  
  26. class bot
  27. {
  28. public $username = "lockie9998"; // Username here
  29. public $password = ""; // Password here
  30.  
  31. public $name = "Bot";
  32. public $icon = 42;
  33. public $link = "google.com";
  34. public $room = "Bambie";
  35. public $char = "!";
  36. public $sock = null; /* DON'T TOUCH THIS IF YOU'RE A SKID. THX. */
  37.  
  38. public function __construct()
  39. {
  40. $this->login();
  41. $this->join();
  42. while(true)
  43. {
  44. $packet_glob = explode(chr(0), $this->read());
  45. foreach($packet_glob as $xml)
  46. {
  47. $xml = $this->xmlArray($xml);
  48. if(!$xml || empty($xml)) continue;
  49. switch($xml[chr(0)])
  50. {
  51. case "m":
  52. if(isset($xml["s"])) break;
  53.  
  54. if(substr($xml["t"], 0, 1) == $this->char)
  55. {
  56. $args = explode(" ", $xml["t"], 2);
  57. switch(substr($args[0], 1))
  58. {
  59. case "say":
  60. $this->sendMessage($args[1]);
  61. break;
  62. }
  63. }
  64. break;
  65. }
  66. }
  67. }
  68. }
  69.  
  70. public function sendMessage($txt)
  71. {
  72. $clean = htmlentities($txt);
  73. return $this->write("<m t=\"{$clean}\" u=\"{$this->xatID}\" />");
  74. }
  75.  
  76. public function getRoomID($name)
  77. {
  78. $load = file_get_contents("http://xat.com/web_gear/chat/roomid.php?d={$name}");
  79. return (integer) $load;
  80. }
  81.  
  82. public function connect($recon = false)
  83. {
  84. if($recon)
  85. {
  86. @socket_close($this->sock);
  87. $this->sock = null;
  88. }
  89. $servers = '107.182.224.235';
  90. $port = 10000 + ($this->getRoomID($this->room % 32));
  91. $serv = $servers;
  92. print "Connecting to {$serv}:{$port} ...". PHP_EOL;
  93. $this->sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
  94. socket_connect($this->sock, $serv, $port);
  95. return is_resource($this->sock);
  96. }
  97.  
  98. public function write($packet)
  99. {
  100. if(substr($packet, -1) != chr(0)) $packet .= chr(0);
  101. var_dump($packet);
  102. return socket_write($this->sock, $packet, strlen($packet));
  103. }
  104.  
  105. public function read()
  106. {
  107. $data = @socket_read($this->sock, 1204, PHP_BINARY_READ);
  108. if(strlen($data)) var_dump($data);
  109. return @trim($data);
  110. }
  111.  
  112. public function join($shake = true)
  113. {
  114. $this->connect();
  115. if($shake)
  116. {
  117. $this->write("<y r=\"{$this->getRoomID($this->room)}\" v=\"0\" u=\"{$this->xatID}\" />");
  118. $this->handshake = $this->xmlArray($this->read());
  119. }
  120.  
  121. $packet = "<j2 ";
  122. $packet .= "cb=\"{$this->handshake["c"]}\" ";
  123. $packet .= "y=\"{$this->handshake["i"]}\" ";
  124. $packet .= "q=\"1\" ";
  125. $packet .= "k=\"{$this->loginArray["k1"]}\" ";
  126. $packet .= "k3=\"{$this->loginArray["k3"]}\" ";
  127. $packet .= "p=\"0\" ";
  128.  
  129. if(isset($this->loginArray["d2"]))
  130. {
  131. $packet .= "d2=\"{$this->loginArray["d2"]}\" ";
  132. }
  133.  
  134. $packet .= "c=\"{$this->getRoomID($this->room)}\" ";
  135. $packet .= "r=\"\" ";
  136. $packet .= "f=\"0\" ";
  137. $packet .= "e=\"\" ";
  138. $packet .= "u=\"{$this->xatID}\" ";
  139.  
  140. for($i = 0; $i < 25; $i++)
  141. {
  142. $d_index = "d".$i;
  143. if(isset($this->loginArray[$d_index]))
  144. {
  145. $packet .= $d_index ."=\"{$this->loginArray[$d_index]}\" ";
  146. }
  147. }
  148.  
  149. $pvars = array("dO", "dx", "dt");
  150. foreach($pvars as $pv)
  151. {
  152. if(isset($this->loginArray[$pv]))
  153. {
  154. $packet .= $pv ."=\"{$this->loginArray[$pv]}\" ";
  155. }
  156. }
  157.  
  158. $packet .= "N=\"{$this->username}\" ";
  159. $packet .= "n=\"{$this->name}\" ";
  160. $packet .= "a=\"{$this->icon}\" ";
  161. $packet .= "h=\"{$this->link}\" ";
  162. $packet .= "v=\"0\" ";
  163. $packet .= "/>";
  164. return $this->write($packet);
  165. }
  166.  
  167. public function xmlArray($xs)
  168. {
  169. $xss = @simplexml_load_string(trim($xs));
  170. $rss = array();
  171.  
  172. if(!method_exists($xss, "getName")) return $rss;
  173.  
  174. $rss[chr(0)] = $xss->getName();
  175.  
  176. foreach($xss->attributes() as $x => $y) $rss[@(string) $x] = @(string) $y;
  177.  
  178. return $rss;
  179. }
  180.  
  181. public function login()
  182. {
  183. $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
  184. socket_connect($sock, "107.182.224.235", 10000);
  185. socket_write($sock, "<y r=\"8\" />\0");
  186. socket_read($sock, 1204);
  187.  
  188. $user = $this->username;
  189. $pass = "$". crc32($this->password);
  190.  
  191. socket_write($sock, "<v r=\"8\" p=\"{$pass}\" n=\"{$user}\" />\0");
  192. $this->loginArray = $this->xmlArray(socket_read($sock, 1204));
  193.  
  194. if(isset($this->loginArray["e"])) exit("Login error. [{$this->loginArray["e"]}]");
  195.  
  196. $this->xatID = (integer) $this->loginArray["i"];
  197. socket_close($sock);
  198. }
  199. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement