예제 #1
0
def login():
    global loggedIn, SID;
    if(loggedIn): return 2;

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

    if(u not in ['Xunnamius']):
        Display.sysMsg("Invalid username/permissions.");
        return False;

    # 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();
    
    # Alert the user of the result, and display the proper options accordingly
    if response != False:
        if response == "Approved":
            Display.playerMsg("Login Successful.");
            Display.sysMsg('Loading...');
            loggedIn = True;
            return loggedIn;
                
        elif response == "Denied":
            Display.errorMsg("Invalid username/password combination.");
            Display.errorMsg("Remember your username/password is case sensitive!");
            
        elif response == "Malformed":
            Display.errorMsg("You have illegal characters in your username/password.");
            Display.errorMsg("(Usernames are only allowed letters and numbers!)");
            Display.errorMsg("Contact Dark Gray for assistance or create a new account.");
            
        else:
            if(not response): Display.errorMsg("Connection to server was dropped. Please try again.");
            else:
                Display.errorMsg("Error. The response received from server was unrecognizable.");
                Display.errorMsg(">>", response);
                
    else: Display.errorMsg("Connection to server was dropped. Please try again.");
    return False;
예제 #2
0
파일: MAIN.py 프로젝트: Xunnamius/pyGuess
            if(response != False):
                switch = True;
                KEY = response[0];
                SID = response[2];
            else:
                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;