Hi, guys, it's me again!
Like maybe you remember, I'm currently designing an online multiplayer game. I'd like to post my design of the client login structure here and ask you, if you see any security glitches. I would really appreciate any comments and help
My main goals were to:
-prevent other applications to connect with my private server
-prevent more than 1 people logged on the same account at the same time
1. Client types his Nickname and Password into 2 edit boxes. After clicking "OK" button, the password gets changed into MD5 string and along with the login, it gets sent to a PHP file on my server (as for now it's just POST, but I'm probably gonna try adding SSL).
2. The PHP file on the server connects with a MySQL database and checks if the password for the given login is correct. If yes, then it sends information about successful log in to the client.
Also, it puts his nickname, a randomly generated number and the session expiration time into another MySQL table called "sessions".
3. The client connects with the server using the login as the nickname.
4. The server checks if there's no player with that nickname on the players' list. If there is, then it refuses connection. If there's no, it sends the username to a PHP file.
5. The PHP file checks if there's a record containing the username sent by the server in the table "sessions". If yes, then it returns to the server the randomly generated number for that user.
6. The server encrypts the received number using the password of the joining user as a key (from the MySQL database) and sends the encoded string to that user.
7. The client decodes the string from server, using the password typed earlier by the user and then sends back the decrypted number to the server.
8. The server receives the number from the client and sends it to the PHP file.
9. The PHP file checks the number with the one in the "sessions" table. If it's correct, then it removes the session expiration time from the record (it won't be needed, since the record's gonna get removed if the user disconnects) and sends an information about a successfull log in to the server.
10. The server adds the nickname of joining player to the players' list.
(11). Each time client disconnects, the server removes informations about that player from the MySQL table "sessions".
(12). Every 1 minute, the server's gonna run a PHP script checking if there're any expired sessions and removing them.
What it gives:
-If some other application tries to connect to my server, then it's gonna get disconnected, because there won't be information about it in the MySQL database (which only server can access). (5)
-If somebody runs my client and logs in using his game account, his nick's gonna get added to the MySQL database, so he could then run his own application and connects to my server using his nickname from the game, because it is in the MySQL database. However, he won't be able to, because the server checks if there're no more than 1 player with the same nickname (4).
-If somebody logs in and doesn't connect to the game, his session's gonna expire after 1 minute. If during that 1 minute, anybody tries to connect with the server using the nickname saved in the "sessions" table, he won't be able to without knowing the password.





Reply With Quote


