Advertisement
Guest User

asdasd

a guest
Dec 27th, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.98 KB | None | 0 0
  1. <?php
  2. set_time_limit(0);
  3. error_reporting(1);
  4.  
  5. class BasicBot
  6. {
  7. public $nome = "(hi)Guest";
  8. public $avatar = "2";
  9. public $home = "http://www.google.com/";
  10. public $admins = Array(
  11. 42
  12. );
  13. public $Wellcome = "xat";
  14. public $users;
  15. public $socket;
  16. public $chatID;
  17. public $botID = 150;
  18. public $port;
  19. public $ip;
  20. public $k1;
  21.  
  22. public function SocketConnect()
  23. {
  24. $this->socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
  25. $test = socket_connect($this->socket, '144.217.16.67', 10001);
  26. }
  27.  
  28. public function SocketDesconnect()
  29. {
  30. if (isset($this->socket) && $this->socket == True)
  31. {
  32. socket_close($this->socket);
  33. }
  34. $this->socket = False;
  35. }
  36.  
  37. public function parse($xml, $return = null)
  38. {
  39. $conteudo = @simplexml_load_string(trim($xml));
  40. foreach ($conteudo->Attributes() as $i => $u) $return[$i] = (string)((string)$u);
  41. return $return;
  42. }
  43.  
  44. public function sendPacket($packet)
  45. {
  46. echo "[BOT-LOG]-> {$packet}\n";
  47. return socket_write($this->socket, $packet, strlen($packet));
  48. }
  49. public function login()
  50. {
  51. $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
  52. socket_connect($sock, '144.217.16.67', 10001);
  53. $user = "switch";
  54. $pass = '34353815';
  55.  
  56. socket_write($sock, "<v r=\"8\" p=\"{$pass}\" n=\"{$user}\" />\0");
  57. $this->loginArray = $this->parse(socket_read($sock, 2048));
  58.  
  59. if(isset($this->loginArray["e"])) exit("Login error. [{$this->loginArray["e"]}]");
  60. socket_close($sock);
  61. }
  62.  
  63. public function EnterRoom()
  64. {
  65.  
  66. $this->SocketConnect();
  67. $this->login();
  68. $this->sendPacket('<y r="1" m="1" v="0" u="' . $this->loginArray["i"] . '" />');
  69. $x = $this->parse(socket_read($this->socket, 2048));
  70. var_dump($x);
  71. $y = $x['i'];
  72. $p = $x['p'];
  73. $i = $y;
  74.  
  75. $disable = array(213);
  76. $j2 = array();
  77. $j2 = $this->buildJ2($x, $this->loginArray, $disable);
  78. $this->write("j2", $j2);
  79. }
  80.  
  81. public function write($tag, $data) {
  82. $packet = "<".$tag;
  83. if(!empty($data) && is_array($data)) {
  84. foreach($data as $k => $v) {
  85. $packet .= " ".$k."=\"".$v."\"";
  86. }
  87. }
  88. $packet .= " />";
  89. if($packet{strlen($packet)-1} != chr(0))
  90. $packet .= chr(0);
  91. print_r($data);
  92. socket_write($this->socket, $packet);
  93. }
  94. public function verifyPowers($disabled) {
  95. foreach($disabled as $d) {
  96. $section = $d >> 5;
  97. $subid = pow(2, $d % 32);
  98.  
  99. $m[$section] += $subid;
  100. }
  101. return $m;
  102. }
  103. public function buildJ2($handshake, $details, $disabledPowers) {
  104. $j2 = array();
  105. $dp = $disabledPowers;
  106. $stra = explode("_", "100_100_5_100");
  107. $p_w = $stra[0];
  108. $p_h = $stra[1];
  109. $t = ($handshake['i'] % ($p_w * $p_h));
  110. $p_x = ($t % $p_w);
  111. $p_y = floor(($t / $p_w));
  112. $l5 = floor(2 << ($p_x % 94)) % $handshake['c'] + $handshake['i'];
  113. $l4 = floor(5 << ($handshake['i'] % (integer)$handshake['l3'])) % $p_y + $handshake['i'];
  114. $disabled = $dp;
  115.  
  116. for($di = 0; $di < 300; $di++) {
  117. if(isset($dp->{$di})) {
  118. array_push($disabled, $di);
  119. }
  120. }
  121. $m = $this->verifyPowers($disabled);
  122. $j2["l6"] = 0;
  123. $j2["l5"] = $l5;
  124. $j2["l4"] = $l4;
  125. $j2["l3"] = rand(1000, 5000);
  126. $j2["l2"] = 0;
  127. $j2["i"] = $handshake["i"];
  128. $j2["cb"] = $handshake['c'];
  129. $j2["y"] = $handshake['i'];
  130. $j2["q"] = 1;
  131. $j2["k"] = $details["k1"];
  132. $j2["k3"] = $details["k3"];
  133. $j2["p"] = 0;
  134.  
  135. if(isset($details['d1']))
  136. $j2["d1"] = $details["d1"];
  137.  
  138. $j2["c"] = 1;
  139. $j2["r"] = '';
  140. $j2["u"] = $details["i"];
  141.  
  142. for($i = 0; $i <= 25; $i++) {
  143. if(isset($m[$i])) {
  144. $j2["m".$i] = $m[$i];
  145. }
  146. if(isset($details["d".$i]) && $i != 1) {
  147. $j2["d".$i] = $details["d".$i];
  148. }
  149. }
  150.  
  151. if(isset($details['dO']))
  152. $j2["dO"] = $details["dO"];
  153. if(isset($details['dx']))
  154. $j2["dx"] = $details["dx"];
  155. if(isset($details['dt']))
  156. $j2["dt"] = $details["dt"];
  157.  
  158. $j2["N"] = $details["N"];
  159. $j2["n"] = $details["n"];
  160. $j2["a"] = '';
  161. $j2["h"] = '';
  162. $j2["a"] = "";
  163. $j2["h"] = "";
  164. $j2["v"] = 2;
  165.  
  166. return $j2;
  167. }
  168. public function Load($ver = True, $variavel = True)
  169. {
  170. $x = "";
  171. try
  172. {
  173. $x = rtrim(socket_read($this->socket, 2048));
  174. $x = str_replace("", "", $x);
  175. }
  176. catch(Exception $e)
  177. {
  178. return "OFF";
  179. }
  180. if (!$x) return "OFF";
  181. if ($x[strlen($x) - 1] != ">") $x .= $this->Load(True);
  182. if ($ver) $this->packets($x, $variavel);
  183. return $x;
  184. }
  185.  
  186. public function packets($packet, $debug = True, $debug1 = False)
  187. {
  188. if (substr_count($packet, ">") > 1)
  189. {
  190. $packet = explode("/>", $packet);
  191. $debug1 = True;
  192. }
  193. foreach ((Array)$packet as $p)
  194. {
  195. if ($debug1) $p .= "/>";
  196. $p = trim($p);
  197. if (strlen($p) < 5) return;
  198. echo "[MAIN-PACKET]-> {$p}\n";
  199. $TypePacket = trim(strtolower(substr($p, 1, strpos($p . " ", " "))));
  200. $p = trim(str_replace("<" . $TypePacket, "", str_replace("/>", "", $p)));
  201. $p = str_replace("\"", "", str_replace("\" ", "&", str_replace("&", "__38", $p)));
  202. parse_str($p, $this->packet[$TypePacket]);
  203. foreach ($this->packet[$TypePacket] as $x => $v) $this->packet[$TypePacket][$x] = str_replace("__38", "&", str_replace("pl_", "+", $v));
  204. if ($debug) $this->Haddle($TypePacket, $this->packet[$TypePacket]);
  205. }
  206. }
  207.  
  208. public function Haddle($tipo, $packet)
  209. {
  210. switch ($tipo)
  211. {
  212. case "u":
  213. $uid = $this->parseU($packet['u']);
  214. $u = $this->fetchUser($packet['u']);
  215. $this->users[$this->parseU($packet['u'])] = $packet;
  216. $this->users[$packet['u']]['cb'] = @$packet['cb'];
  217. $this->users[$packet['u']]['s'] = @$packet['s'];
  218. $this->users[$packet['u']]['f'] = (isset($packet['f'])) ? (int) $packet['f'] : 0;
  219. $this->users[$packet['u']]['id'] = $packet['u'];
  220. $this->users[$packet['u']]['d0'] = (isset($packet['d0'])) ? (int) $packet['d0'] : 0;
  221. $this->users[$packet['u']]['d2'] = (isset($packet['d2'])) ? @$packet['d2'] : 0;
  222. $this->users[$packet['u']]['q'] = (isset($packet['q'])) ? (int) $packet['q'] : 0;
  223. $this->users[$packet['u']]['registered'] = ((key_exists('N', $packet)) ? $packet['N'] : 'Unregistered');
  224. $this->users[$packet['u']]['name'] = @$packet['n'];
  225. $this->users[$packet['u']]['avatar'] = (isset($packet['a'])) ? @$packet['a'] : 'No Avatar';
  226. $this->users[$packet['u']]['home'] = (isset($packet['h'])) ? @$packet['h'] : 'No Homepage';
  227. $this->users[$packet['u']]['v'] = (@$packet['v']) ? @$packet['v'] : 0;
  228. $this->users[$packet['u']]['bride'] = (isset($packet['d2'])) ? @$packet['d2'] : 0;
  229. $this->users[$packet['u']]['rel'] = (@$packet['d0'] & 1) ? 1 : 2;
  230. $this->users[$packet['u']]['dx'] = $packet['xats'];
  231. $this->users[$packet['u']]['sub'] = (isset($packet['p0'])) ? 1 : 0;
  232. $user = ( $packet['N']) ? $packet['N'] : $packet['u'];
  233. $userid = $packet['i'];
  234. $this->member($packet['u']);
  235. $this->sendPrivateMessage("Bem Vindos", $packet["u"]);
  236. break;
  237.  
  238. case "z":
  239. $this->sendPrivateMessage("....", $packet["u"]);
  240. break;
  241.  
  242. case "m":
  243. case "p":
  244. if (isset($packet["i"]) && $packet["i"] > 0)
  245. {
  246. break;
  247. }
  248.  
  249. $msg = $message = explode(" ", $packet["t"]);
  250.  
  251. unset($msg[0]);
  252.  
  253. $msg = implode(" ", $msg);
  254.  
  255. if (isset($message[0]) && $message[0][0] != "@")
  256. {
  257. break;
  258. }
  259. switch (substr($message[0], 1))
  260. {
  261. case "say":
  262. $this->sendAllChat($msg);
  263. break;
  264.  
  265. case "info":
  266. $this->sendPrivateMessage("Guest Bot", $packet["u"]);
  267. break;
  268.  
  269. }
  270. }
  271. }
  272. function member($id, $time = null) {
  273. if (!$time)
  274. $time = 0;
  275. $id = $this->parseU($id);
  276. $this->sendC($id, '/e', $time);
  277. }
  278. function sendwelcome($message, $id, $f, $nome) {
  279. if (!$message) {
  280. return false;
  281. }
  282. $this->sendmsg($message, 'PM', $id);
  283. }
  284. public function sendC($id = 0, $com = '') {
  285. $this->sendPacket('<c u="' . $id . '" t="' . $com . '" />');
  286. }
  287. function sendmsg($message, $type = "MSG", $id = 0) {
  288. if (!$message) {
  289. return false;
  290. }
  291. switch ($type) {
  292. case "MSG":
  293. $this->sendPacket("<m t=\"{$message}\" u=\"{$this->botID}\" />");
  294. break;
  295.  
  296. case "PM":
  297. $this->sendPacket("<p u=\"{$id}\" t=\"{$message}\" d=\"{$id}\" />");
  298. break;
  299.  
  300. case "PC":
  301. $this->sendPacket("<p u=\"{$id}\" t=\"{$message}\" d=\"{$id}\" s=\"2\" />");
  302. break;
  303. }
  304. }
  305. public function fetchUser($id) {
  306. $id = $this->parseU($id);
  307. if (isset($this->users[$id]))
  308. return $this->users[$id];
  309. else
  310. return false;
  311. }
  312. function parseU($id) {
  313. if (substr_count($id, '_') >= 1)
  314. $id = substr($id, 0, strpos($id, '_'));
  315. return $id;
  316. }
  317. public function reiniciar()
  318. {
  319. $this->SocketConnect();
  320. $this->EnterRoom();
  321. }
  322. function sendPrivateChat($string, $userid)
  323. {
  324. $this->sendPacket("<z u=\"{$this->botID}\" t=\"{$string}\" s=\"2\" d=\"{$userid}\" />");
  325. }
  326.  
  327. function sendPrivateMessage($string, $userid)
  328. {
  329. $this->sendPacket("<p u=\"{$userid}\" t=\"{$string}\" />");
  330. }
  331. function sendAllChat($string)
  332. {
  333. $this->sendPacket("<m u=\"{$this->botID}\" t=\"{$string}\" />");
  334. }
  335.  
  336. }
  337.  
  338. $BasicBot = new BasicBot();
  339.  
  340. while(1)
  341. {
  342. if ($BasicBot->Load() == "OFF")
  343. {
  344.  
  345.  
  346. $BasicBot->SocketDesconnect();
  347. $BasicBot->EnterRoom();
  348.  
  349. }
  350. }
  351.  
  352.  
  353.  
  354.  
  355. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement