pro ^^s"]) if passwordHash == "": if len(username)>=9: priv = -1 self.close() else: username = "*"+username priv = 0 username = self.server.checkAlreadyExistingGuest(username) else: username=username.lower() username=username.capitalize() priv = self.server.authenticate(username, passwordHash) if priv != 0: username=username.lower() username=username.capitalize() dbcur.execute('select * from userpermaban where name = ?', [username]) rrf = dbcur.fetchone() print rrf if rrf is None: pass else: print '-1' priv = -1 print "["+self.address[0]+" - "+username+"] Permabanned user tried to logon." self.sendPermaBan() #self.room.informAll(TransformiceClientHandler.sendPlayerDisconnect, [self.playerCode]) #self.room.removeClient(self) self.close() if priv == -1: #return False #self.close() self.sendData("\x1A" + "\x03", ["\x00"+"6"]) self.wrongPasswordAttempts+=1 if self.wrongPasswordAttempts>=4: self.sendData("\x1A" + "\x12",["0", "Too many incorrect password attempts"]) logging.info("Kick - Too many wrong passwords - %s" % self.address[0]) self.close() else: alreadyconnect = self.server.checkAlreadyConnectedAccount(username) if alreadyconnect == True: self.sendData("\x1A" + "\x03", ["\x01"]) else: self.username = username self.playerCode = self.server.generatePlayerCode() self.privilegeLevel = priv self.titleNumber = self.server.getCurrentTitle(username) self.roundCount = self.server.getRoundsCount(username) self.tribe = self.server.getTribeName(username) self.tribeName = self.server.getTribeName(username) self.tribeGreeting = self.server.getTribeGreeting(self.tribeName) self.tribeSettings = self.server.getTribeSettings(self.tribeName) self.tribeRank = self.server.getTribeRank(username) isDrawer = self.server.getDrawer(username) if str(isDrawer) == "1": self.isDrawer = True else: self.isDrawer = False if self.tribeName == "": pass else: self.sendData("\x10" + "\x12", ["2", self.tribeName, "0", self.tribeGreeting, self.tribeSettings, self.tribeRank]) self.micesaves = self.server.getSavesCount(username) self.shamancheese = self.server.getShamanCheeseCount(username) self.firstcount = self.server.getFirstCount(username) self.cheesecount = self.server.getCheeseCount(username) self.shopcheese = self.server.getShopCheese(username) self.titleList = self.server.getTitleList(username) self.shopitems = self.server.getUserShop(username) self.look = self.server.getUserLook(username) self.fur = self.server.getFurColor(username) self.titleList = self.titleList.strip('[]') self.titleList = self.titleList.replace("\"","") self.titleList = self.titleList.replace(","," ") self.titleList = str(self.titleList) self.titleList = self.titleList.split(" ") print self.username print self.titleList self.sendTitleList() self.giftCount = 0 #self.sendTribeGreeting() # [Version] Game: 0.129Server: 1.012 self.sendPlayerLoginData() if passwordHash == "": logging.info("Authenticate %s - %s - Guest" % (self.address, username)) else: logging.info("Authenticate %s - %s" % (self.address, username)) print '%s has logged in!' % (self.username) if startRoom!="": self.enterRoom(startRoom) dbcur.execute('UPDATE users set lastroom = ? WHERE name = ?', [startRoom, self.username]) else: self.enterRoom(self.server.recommendRoom()) dbcur.execute('UPDATE users set lastroom = ? WHERE name = ?', [self.server.recommendRoom(), self.username]) if self.privilegeLevel>=3 and not self.isDrawer:#[M][Serveur] Felipinhooo vient de se deconnecter. self.sendAdminMessageChannel("Serveur", "%s conectou-se." % (self.username)) if self.privilegeLevel>=5 and not self.isDrawer:#has just logged in! self.sendModMessageChannel("Serveur", "%s conectou-se." % (self.username)) if self.privilegeLevel==10 and self.isDrawer: self.sendModMessageChannel("Drawer", "%s conectou-se." % (self.username)) if self.privilegeLevel < 3: self.sendServeurMessage("%s(User) conectou-se." % (self.username)) self.sendFriendLog(self.username) if self.tribeName == "": pass else: self.sendTribeLogin(self.tribeName, self.username) return True class TransformiceAdminTools(object): def __init__(self, server): self.server = server def sendModMessage(self, message): for room in self.server.rooms.itervalues(): room.informAll(TransformiceClientHandler.sendModMessage, [ADMIN_NAME, message]) def playMusicInRoom(self, roomName, path): roomName = str(roomName) if self.server.rooms.has_key(roomName): self.server.rooms[roomName].playMusic(path)#from http://www.acooke.org/cute/BasicHTTPA0.htmlclass VerifyingXMLRPCServer(SimpleXMLRPCServer): def __init__(self, *args, **kargs): # we use an inner class so that we can call out to the # authenticate method class VerifyingRequestHandler(SimpleXMLRPCRequestHandler): # this is the method we must override def parse_request(myself): # first, call the original implementation which returns # True if all OK so far if SimpleXMLRPCRequestHandler.parse_request(myself): # next we authenticate if self.authenticate(myself.headers): return True else: # if authentication fails, tell the client myself.send_error(401, 'Authentication failed') return False # and intialise the superclass with the above SimpleXMLRPCServer.__init__(self, requestHandler=VerifyingRequestHandler, *args, **kargs) def authenticate(self, headers): basic, _, encoded = headers.get('Authorization').partition(' ') assert basic == 'Basic', 'Only basic authentication supported' username, _, password = base64.b64decode(encoded).partition(':') return username.lower() in ADMIN_NAMES and hashlib.sha256(password).hexdigest() == ADMIN_HASHif __name__ == "__main__": TEST = False server = TransformiceServer() adminTools = TransformiceAdminTools(server) rpcServer = VerifyingXMLRPCServer(('', 1110), allow_none=True) rpcServer.register_introspection_functions()