Guest User

tejasisbad

a guest
Jan 30th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.73 KB | None | 0 0
  1. <?php
  2.  
  3. /****************************************************************************************************************************/
  4.  
  5. //Change the following information to fit your needs
  6. date_default_timezone_set('America/New_York'); //Set your timezone. You can find a list of supported timezones at http://php.net/manual/en/timezones.php
  7. $accountLoginName = ''; //Current login username/email for Mojang.com
  8. $accountUsername = ' '; //Current in-game Minecraft username
  9. $accountPassword = ' '; //Current account password
  10. $newName = ''; //Desired new username
  11. $time = ' '; //Set the time that the account name should change. YYYY-MM-DD HH:MM:SS format.
  12.  
  13. /****************************************************************************************************************************/
  14.  
  15.  
  16. /*****************************************************PROGRAM START. DO NOT TOUCH*****************************************************/
  17.  
  18. set_time_limit(0);
  19. $accountUrl = 'https://account.mojang.com/login';
  20. $cookiePath = $_SERVER['DOCUMENT_ROOT'] . "/cookie.txt";
  21. $isItTime = false;
  22. $strToTime = strtotime($time);
  23.  
  24.  
  25. $uuid = file_get_contents('https://api.mojang.com/users/profiles/minecraft/' . $accountUsername);
  26. if (!empty($uuid)) {
  27. $uuid = explode(':', $uuid);
  28. $uuid = explode(',', $uuid[1]);
  29. $uuid = str_replace('"', '', $uuid[0]);
  30. }
  31. else {
  32. die("Invalid username");
  33. }
  34.  
  35. $fields = array(
  36. 'username' => $accountLoginName,
  37. 'password' => $accountPassword,
  38. 'remember' => 'true'
  39. );
  40. $fields_string = '';
  41. foreach($fields as $key => $value) {
  42. $fields_string .= $key . '=' . $value . '&';
  43. }
  44. rtrim($fields_string, '&');
  45.  
  46. $ch = curl_init($accountUrl);
  47. curl_setopt($ch, CURLOPT_POST, count($fields));
  48. curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
  49. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  50. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  51. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  52. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  53. curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiePath);
  54. $result = curl_exec($ch);
  55.  
  56. if ($result == false) {
  57. die("Curl error: " . curl_error($ch));
  58. }
  59. else {
  60. curl_setopt($ch, CURLOPT_URL, 'https://account.mojang.com/me/renameProfile/' . $uuid);
  61. curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiePath);
  62. $result2 = curl_exec($ch);
  63. if ($result2 == false) {
  64. die("Curl error: " . curl_error($ch));
  65. }
  66. else {
  67. $authToken = explode('name="authenticityToken" value="', $result2);
  68. $authToken = explode('">', $authToken[1]);
  69. $authToken = $authToken[0];
  70. $fields = array(
  71. 'newName' => $newName,
  72. 'password' => $accountPassword,
  73. 'authenticityToken' => $authToken);
  74. $fields_string = '';
  75. foreach($fields as $key => $value) {
  76. $fields_string .= $key . '=' . $value . '&';
  77. }
  78. rtrim($fields_string, '&');
  79. curl_setopt($ch, CURLOPT_POST, count($fields));
  80. curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
  81. while ($isItTime == false) {
  82.  
  83. if ($strToTime <= time()) {
  84. $result3 = curl_exec($ch);
  85. if (stripos($result3, 'errors') !== false || stripos($result3, 'error') !== false || stripos($result3, 'not found') !== false) {
  86. echo "An error occured:<br /><br />" . $result3;
  87. }
  88. else {
  89. echo "Username changed successfully.<br /><br />Old Username: " . $accountUsername . "<br />New username:" . $newName;
  90. }
  91. $isItTime = true;
  92. }
  93. else {
  94. continue;
  95. }
  96. }
  97. }
  98. }
  99.  
  100. curl_close($ch);
Add Comment
Please, Sign In to add comment