This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
ComputerCraftFan11's profile picture

[1.31+] Minecraft.net Login System

Started by ComputerCraftFan11, 26 May 2012 - 01:03 AM
ComputerCraftFan11 #1
Posted 26 May 2012 - 03:03 AM
I was making a 'minebook' (facebook for minecraft) inside of computercraft I this post is to share the login part of that site.


local status = "Please login first."
local x,y = term.getSize()
function connect()
while true do
  term.clear()
  term.setCursorPos(1,1)
  print(status.. "n")
  print("Minecraft Username: ")
  write("Minecraft Password: ")
  test = string.len("Minecraft Password: *")

  term.setCursorPos(test, 3)
  user = read()
  term.setCursorPos(test, 4)
  pass = read()
  http.request("http://login.minecraft.net/?user=" ..user.. "&password=" ..pass.. "&version=12")
  local event, url, response = os.pullEvent()
  if event == "http_success" then
   _sResponse = { response.readAll() }
   if string.find(tostring(_sResponse[1]), "deprecated") then
	term.setCursorPos(1, y-1)
	textutils.slowPrint("Logging in...")
	sleep(0.5)
	break
   else
	status = tostring(_sResponse[1])
   end
  else
   status = ("Unable to connect to minecraft.net")
  end

  response.close()
end
end
connect()


First, it asks for your username
Then, it asks for your password
It connects to http://login.minecraft.net/?user=<USER>&amp;password=<PASS>&amp;version=12

(from the wiki)
And it prints whatever is inside that page.

If it doesn't exist, the page returns "Bad login" and it prints that.
If it does exist, but the password is wrong, it prints it again.
If it does exist, but the account is migrated, it prints "Account migrated. Use email to login."
If it exists, it will return <random number>:"deprecated":<your username>:<a session id(?)>
Since we can't find out the random number, username, and session id, we just search for "deprecated" (I haven't testing on non-migrated accounts. It still logs in if your not premium)
Matthewaj #2
Posted 26 May 2012 - 03:47 AM
Nice!

and here's a meme to go along with this:
ComputerCraftFan11 #3
Posted 26 May 2012 - 03:54 AM
Nice!

and here's a meme to go along with this:

And to finish it:
*WHILE LOGGED INTO MINECRAFT
Matthewaj #4
Posted 26 May 2012 - 03:58 AM
oh btw whats the link for the wiki page for the minecraft login and it there any more apis for minecraft accounts?
Luanub #5
Posted 26 May 2012 - 04:04 AM
Nice work on this man, I'm going to play around with it when I get home. Already got a couple of idea's on how I can use it.
ComputerCraftFan11 #6
Posted 26 May 2012 - 04:42 AM
oh btw whats the link for the wiki page for the minecraft login and it there any more apis for minecraft accounts?

http://www.minecraftwiki.net/wiki/User:Oxguy3/Minecraft.net_API

I found it there
Noodle #7
Posted 26 May 2012 - 05:33 AM
Gimme a sec, my site will have this. Then anyone who registers at my site will just have to write it down on their computer to enable it!
Unless they have a floppy that someone with an account has made for them…
Nvm, I'll just do this for the first DIST of Noodle-Sh.
NEways, thx!
cant_delete_account #8
Posted 26 May 2012 - 06:03 AM
I would suggest using HTTPS when dan fixes the HTTPS error with the HTTP API.
(because then the connection is encrypted (hackers can't steal your password) )
Also, thanks! I'll be using this.
ComputerCraftFan11 #9
Posted 26 May 2012 - 06:08 AM
Also, this is the URL to check if you are premium incase you want a "VIP" section for your logins.


http://www.minecraft.net/haspaid.jsp?user=<USERNAME>
ComputerCraftFan11 #10
Posted 27 May 2012 - 12:44 AM
(This code is from this:
http://pastebin.com/X3RqHkXK
)

I currently got the login, and the logout right :)/>/>
Will make a separate post with minebook later….
Learning_inpaired #11
Posted 30 May 2012 - 11:51 PM
you should make a minecraft inside of minecraft and have it work in the screen but be like creative mode 0.0 EPIC wish i knew code -.-
Knox #12
Posted 31 May 2012 - 05:32 AM
I'm no professional, but from what I know of the login system, when you disconnect from the server (if on one) and try and connect to any other server, wouldn't it give you a bad login error since you renewed your sessionID?
MysticT #13
Posted 31 May 2012 - 06:34 PM
I'm no professional, but from what I know of the login system, when you disconnect from the server (if on one) and try and connect to any other server, wouldn't it give you a bad login error since you renewed your sessionID?
I'm not sure about this, but I think that the session id is given when you start minecraft, not when connecting to a server. And I don't think it would cause any problem anyway, your renewing you session id, what's the problem?

Edit:
From the minecraft wiki:

when a server with online-mode=true checks if it should allow a player to join the game. The session ID is generated by the launcher when you log in
Edited on 31 May 2012 - 04:36 PM
ComputerCraftFan11 #14
Posted 31 May 2012 - 09:22 PM
I'm no professional, but from what I know of the login system, when you disconnect from the server (if on one) and try and connect to any other server, wouldn't it give you a bad login error since you renewed your sessionID?
I'm not sure about this, but I think that the session id is given when you start minecraft, not when connecting to a server. And I don't think it would cause any problem anyway, your renewing you session id, what's the problem?

Edit:
From the minecraft wiki:

when a server with online-mode=true checks if it should allow a player to join the game. The session ID is generated by the launcher when you log in

When you login to a server, it connects to another page on minecraft.net that requires your session ID, then the server validates you like that (so people don't just fake their username)

When you login to this, it also generates a new Session ID, but the one that your launcher is currently using stays the same.

So (non tested) it might give you Bad Login

EDIT:
(http://) session.minecraft.net/game/joinserver.jsp?user=<USERNAME>&amp;sessionId=<SESSION ID>
warfighter67 #15
Posted 02 June 2012 - 05:27 AM
Now just make a mock-up Java compiler, and you can start working on Minecraft for Computercraft! Then you can play Minecraft on your computer in Minecraft!
PixelToast #16
Posted 02 June 2012 - 09:09 AM
now how do i send and receive chat messages? i dont have MCP on my laptop so i cant look at the source code
ComputerCraftFan11 #17
Posted 02 June 2012 - 09:21 AM
now how do i send and receive chat messages? i dont have MCP on my laptop so i cant look at the source code

I might post a tutorial or something when I find out

Off topic:
I made one for java too :)/>/>

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import javax.swing.JTextField;

public class Connecter
{
public static String user = "user";
public static String pass = "password";
public static void main(String[] args) {
  try {
  
   URL google = new URL("http://login.minecraft.net/?user=" + user + "&amp;password=" + pass + "&amp;version=12");
   URLConnection yc = google.openConnection();
   BufferedReader in = new BufferedReader(new InputStreamReader(yc
	 .getInputStream()));
   String inputLine;
   while ((inputLine = in.readLine()) != null) {
	System.out.println(inputLine);
   }
   in.close();
  } catch (Exception e) {
   e.printStackTrace();
  }
}
}
stumblinbear #18
Posted 05 June 2012 - 08:47 AM
Used this code in my startup file :)/>/>

Also added the os.pullEvent = os.pullEventRaw so players can't ctrl-t out of it :]
Now the players on my server have a reason to buy minecraft >:D/>/>
Pinkishu #19
Posted 05 June 2012 - 10:08 AM
Used this code in my startup file :)/>/>

Also added the os.pullEvent = os.pullEventRaw so players can't ctrl-t out of it :]
Now the players on my server have a reason to buy minecraft > :D/>/>

and distrust you for the possibility of stealing their pw :3
prasselpikachu #20
Posted 22 July 2012 - 12:18 PM
You'd better change the line

pass = read()
to

pass = read("*")
with this the password will be shown as following:
Password: ********
Wouto1997 #21
Posted 30 July 2012 - 04:41 AM
good code, but 1 bad thing. When using this on a server, your session id is changed by doing this so you can't re-join the server without restarting client…
koslas #22
Posted 09 September 2012 - 07:20 AM
Would you be-able to make this with it checking if they are premium, because I can't figure this out
ficolas #23
Posted 06 October 2012 - 09:42 PM
Holly shit im evil…
I made a pass breaker D:
Im not so evil so I wont test it xD
PixelToast #24
Posted 08 October 2012 - 02:53 AM
Holly shit im evil…
I made a pass breaker D:
Im not so evil so I wont test it xD
thats how you get your IP banned
cant_delete_account #25
Posted 08 October 2012 - 03:19 AM
Way safer way of doing this:

print("Username:")
local uInput = read()
local req = http.get("http://www.minecraft.net/haspaid.jsp?user="..uInput)
if req.readAll() == "true" then
--user is premium
else
--user isn't premium or MC servers are down
end
PixelToast #26
Posted 08 October 2012 - 07:06 PM
Way safer way of doing this:

print("Username:")
local uInput = read()
local req = http.get("http://www.minecraft.net/haspaid.jsp?user="..uInput)
if req.readAll() == "true" then
--user is premium
else
--user isn't premium or MC servers are down
end
forgot to use urlEncode so it dosent break with certain usernames :3
RunasSudo-AWOLindefinitely #27
Posted 27 December 2012 - 03:15 PM
*cough* keylogger
1lann #28
Posted 27 December 2012 - 03:33 PM
Holly shit im evil…
I made a pass breaker D:
Im not so evil so I wont test it xD
Minecraft.net servers block you after like 5 failed password attempts. Just telling you dat if you were thinking about brute forcing
AnDwHaT5 #29
Posted 21 February 2013 - 11:31 AM
I love it but what i have been trying to do is make it so i can use other sources like email or enjin. Preferably enjin.
Shnupbups #30
Posted 21 February 2013 - 12:55 PM
I love it but what i have been trying to do is make it so i can use other sources like email or enjin. Preferably enjin.
Noooo! Run while you still can! The necromancers are at it again! The dead are waking!

Don't revive dead threads. They kill innocent coders every day. They also kill guilty ones, but no one gives a damn about them.

EDIT: That line was pretty good… signature edit time…
EDIT 2: Even though that's my third line it tells me I can only have 3 lines… stupid limits…
AnDwHaT5 #31
Posted 21 February 2013 - 01:15 PM
And you help put it back at the top lol.
Cranium #32
Posted 22 February 2013 - 02:46 AM
Necromancy isn't so bad if you idiots would at least post some useful information. As it is now, I have to lock this.