Guest User

Untitled

a guest
Mar 28th, 2016
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.17 KB | None | 0 0
  1. <?php
  2. /*
  3. Create two .txt files for storing ROBLOSECURITY and token.
  4. The script will automatically update the files when ROBLOSECURITY or token is no longer usable.
  5. */
  6. // Input
  7. //$subject = $_GET['subject'];
  8. //$body = $_GET['body']; //this was for something else
  9. //$target_user_id = $_GET['id'];
  10. // Login User Data
  11. $login_user = 'username=publicapi&password=';
  12. $file_path_rs = 'rs.txt';
  13. $file_path_token = 'token.txt';
  14. $current_rs = file_get_contents($file_path_rs);
  15. $current_token = file_get_contents($file_path_token);
  16. // [Function] Get ROBLOSECRUITY
  17. function getRS()
  18. {
  19. global $login_user, $file_path_rs;
  20. $get_cookies = curl_init('https://www.roblox.com/newlogin');
  21. curl_setopt_array($get_cookies,
  22. array(
  23. CURLOPT_RETURNTRANSFER => true,
  24. CURLOPT_HEADER => true,
  25. CURLOPT_POST => true,
  26. CURLOPT_POSTFIELDS => $login_user
  27. //CURLOPT_USERAGENT => "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.6 (KHTML, like Gecko) Chrome/16.0.897.0 Safari/535.6",
  28. //CURLOPT_FOLLOWLOCATION => true,
  29. //CURLOPT_REFERER => "http://www.roblox.com"
  30. )
  31. );
  32. $rs = (preg_match('/(\.ROBLOSECURITY=.*?);/', curl_exec($get_cookies), $matches) ? $matches[1] : '');
  33. file_put_contents($file_path_rs, $rs, true);
  34. curl_close($get_cookies);
  35. return $rs;
  36. }
  37. // [Function] Change User's Group Rank
  38. function changeRank($rs, $token, $target_user_id, $subject, $body)
  39. {
  40. global $subject, $body, $target_user_id, $file_path_token;
  41.  
  42. $promote_user = curl_init("http://www.roblox.com/messages/api/send-message");
  43. curl_setopt_array($promote_user,
  44. array(
  45. CURLOPT_RETURNTRANSFER => true,
  46. CURLOPT_POST => true,
  47. CURLOPT_HEADER => true,
  48. CURLOPT_HTTPHEADER => array("Cookie: $rs", "X-CSRF-TOKEN: $token", "Content-Type: application/json"),
  49. CURLOPT_POSTFIELDS => json_encode(array(
  50. "recipientId"=>$target_user_id, "subject" => $subject,
  51. "body" => $body)),
  52. CURLOPT_USERAGENT => "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.6 (KHTML, like Gecko) Chrome/16.0.897.0 Safari/535.6",
  53. CURLOPT_FOLLOWLOCATION => true,
  54. )
  55. );
  56. $resp = curl_exec($promote_user);
  57. $resp_header_size = curl_getinfo($promote_user, CURLINFO_HEADER_SIZE);
  58. $resp_header = substr($resp, 0, $resp_header_size);
  59. $resp_body = substr($resp, $resp_header_size);
  60. if (preg_match('/GuestData/', $resp_header)) {
  61. // RS invalid
  62. $resp_body = changeRank( getRS(), $token );
  63. } else if (preg_match('/Token Validation Failed/', $resp_header)) {
  64. // Token invalid
  65. $new_token = (preg_match('/X-CSRF-TOKEN: (\S+)/', $resp_header, $matches) ? $matches[1] : '');
  66. file_put_contents($file_path_token, $new_token, true);
  67. $resp_body = changeRank( $rs, $new_token );
  68. }
  69. curl_close($promote_user);
  70. return $resp_body;
  71. }
  72. // Change user's group rank and echo results
  73. echo changeRank(getRS(), $current_token, 21208890, "subject", "body");
  74. ?>
Add Comment
Please, Sign In to add comment