Exemplo n.º 1
0
                Display.errorMsg('Connection was rejected (probably due to too many people playing for too long).');
                Display.errorMsg('Please try again later.');
            
            while(not loggedIn and switch):
                i = Display.menu(OrderedDict([('login', 0), ('register', 1), ('back', 2)]), initMsg='Select an option:', prefix='# ');

                # We're attempting to log someone in
                if(i == 0):
                    u = Display.cooked_input("> Username: "******"> Password:"******"\n  Conversing with server...");

                    # Package the new data
                    conn1.params = {"u":u, "python":1, "type":"", "SID":SID};

                    # 1. Split the key in half
                    # 2. Place chunks at both the front and the end (double salt)
                    # 3. SHA-1 the whole thing again
                    eKeyPiece1 = KEY[0:20];
                    eKeyPiece2 = KEY[20:40];
                    p = str(hashlib.sha1(eKeyPiece1 + hashlib.sha1(hashlib.md5(p).hexdigest()).hexdigest() + eKeyPiece2).hexdigest());
                    u = str(hashlib.sha1(eKeyPiece1 + u + eKeyPiece2).hexdigest());
                    conn1.params["u"] = u;
                    conn1.params["p"] = p;
                    conn1.params["type"] = "lin";

                    # Authenticate the user's information
                    response = conn1.request();
                    
Exemplo n.º 2
0
            response = None;
            while(response != "Approved"):
                # Ask the user for his/her information
                Display.gameMsg('Type "Back" at any time to go back to the previous menu.');
                Display.gameMsg('(This means "Back" cannot be your username/password!)');
                u = Display.cooked_input("> Desired Username: "******"> Desired Password:"******"Conversing with server...");

                # Package the new data
                conn1.params = {"u":u, "python":1, "type":"", "SID":SID};

                # Simple validation
                if(len(u) > 25 or len(p) > 100 or len(u) < 4 or len(p) < 4):
                    Display.errorMsg("Your username/password must be between 4 and 25 characters in length.");
                    Display.errorMsg("Please try again.");
                    continue;

                # Finish packaging the data
                p = str(hashlib.sha1(hashlib.md5(p).hexdigest()).hexdigest());
                conn1.params["p"] = p;
                conn1.params["class"] = 4;
                conn1.params["type"] = "reg";

                # Send the data off for processing
                response = conn1.request();