def connectionMade(self): #self.transport.setTcpNoDelay(True) self.setTimeout(600) self.GAMEOBJ = None self.DATABUFF = "" self.transport.setTcpKeepAlive(True) if self.GAMEOBJ == None: self.GAMEOBJ = DataClass.BF3Server() self.GAMEOBJ.NetworkInt = self.transport Globals.Servers.append(self.GAMEOBJ) print "[BLAZE Server] GameOBJ Made" print "[BLAZE Server] ConMade"
def decodeOneChromosome(chromosome, sourceData): data = dataClass.DataClass(sourceData) chrLength = getChromosomeLength(sourceData) solution = list([None] * data.nNurses) usedNurses = 0 demandOrder = GetDemandOrder(chromosome, data.demand) i = 0 while i < chrLength and usedNurses <= data.nNurses: hourToDemand = demandOrder[i] added = False j = 0 while j < usedNurses and added == False: added = CanAddHour(hourToDemand, solution[j], data) if (added == True): solution[j]['schedule'][hourToDemand] = 1 solution[j]['workingHours'] += 1 solution[j]['ini'] = min(solution[j]['ini'], hourToDemand) solution[j]['end'] = max(solution[j]['end'], hourToDemand) j += 1 # Not added if (added == False): if (usedNurses < data.nNurses): solution[usedNurses] = { 'schedule': np.zeros(data.nHours), 'workingHours': 1, 'ini': hourToDemand, 'end': hourToDemand } solution[usedNurses]['schedule'] = solution[usedNurses][ 'schedule'].astype(int) solution[usedNurses]['schedule'][hourToDemand] = 1 usedNurses += 1 i += 1 valid = (usedNurses <= data.nNurses) if (valid == True): valid = CheckValidSolution(solution[:usedNurses], data) if (valid == True): result = {'solution': solution[:usedNurses], 'fitness': usedNurses} else: result = {'solution': [], 'fitness': data.nNurses * 100} return (result)
def ReceiveComponent(self, data, txn): if txn == 'NuLogin': SessionID = PacketDecoder.decode(data).GetVar('encryptedInfo') # Basic login data retrieve system, (Get AccountID, username and email from Database), if that data are missing return error to game try: AccountID = str(GetWebSession(SessionID)[0]) Username = GetUserName(AccountID) email = GetEmail(AccountID) except: AccountID = None Username = None email = None # Save client connection info if self.GAMEOBJ == None: self.GAMEOBJ = DataClass.BF2Client() self.GAMEOBJ.FESLNetworkInt = self.transport Globals.Clients.append(self.GAMEOBJ) self.GAMEOBJ.IsOnline = True self.GAMEOBJ.SessionID = SessionID self.GAMEOBJ.Username = Username self.GAMEOBJ.UserID = AccountID self.GAMEOBJ.EMail = email if AccountID == None or Username == None or email == None: print ConsoleColor('Warning') + '[FESLClient][acct] User tryed to login using dead or incorrect SessionID! Ignoring...' + ConsoleColor('End') LoginPacket = PacketEncoder.SetVar('TXN', 'NuLogin') LoginPacket += PacketEncoder.SetVar('localizedMessage', '"The user is not entitled to access this game"') LoginPacket += PacketEncoder.SetVar('errorContainer.[]', 0) LoginPacket += PacketEncoder.SetVar('errorCode', 120, True) LoginPacket = PacketEncoder.encode('acct', LoginPacket, 0xC0000000, self.PacketID) self.transport.getHandle().sendall(LoginPacket) self.transport.loseConnection() else: print ConsoleColor( 'Success') + '[FESLClient][acct] User ' + Username + ' Successfully logged in!' + ConsoleColor( 'End') self.GAMEOBJ.LoginKey = RandomStringGenerator.Generate(24) LoginPacket = PacketEncoder.SetVar('TXN', 'NuLogin') LoginPacket += PacketEncoder.SetVar('profileId', AccountID) LoginPacket += PacketEncoder.SetVar('userId', AccountID) LoginPacket += PacketEncoder.SetVar('nuid', Username) LoginPacket += PacketEncoder.SetVar('lkey', self.GAMEOBJ.LoginKey, True) LoginPacket = PacketEncoder.encode('acct', LoginPacket, 0xC0000000, self.PacketID) self.transport.getHandle().sendall(LoginPacket) elif txn == 'NuGetPersonas': # Get User Soldiers GetPersonasPacket = PacketEncoder.SetVar('TXN', 'NuGetPersonas') # For now I'm using static variables. HeroCount = len(GetHeroes(self.GAMEOBJ.UserID)) Heroes = GetHeroes(self.GAMEOBJ.UserID) loop = 0 while loop != HeroCount: CurrentHero = Heroes[loop] HeroName = CurrentHero[2] GetPersonasPacket += PacketEncoder.SetVar('personas.' + str(loop), HeroName) loop += 1 GetPersonasPacket += PacketEncoder.SetVar('personas.[]', len(GetHeroes(self.GAMEOBJ.UserID)), True) GetPersonasPacket = PacketEncoder.encode('acct', GetPersonasPacket, 0xC0000000, self.PacketID) self.transport.getHandle().sendall(GetPersonasPacket) elif txn == 'NuGetAccount': # Get Account data GetAccountPacket = PacketEncoder.SetVar('TXN', 'NuGetAccount') GetAccountPacket += PacketEncoder.SetVar('heroName', self.GAMEOBJ.Username) GetAccountPacket += PacketEncoder.SetVar('nuid', self.GAMEOBJ.EMail) # Birthday date Birthday = GetBirthday(self.GAMEOBJ.UserID).split('-') GetAccountPacket += PacketEncoder.SetVar('DOBDay', Birthday[0]) GetAccountPacket += PacketEncoder.SetVar('DOBMonth', Birthday[1]) GetAccountPacket += PacketEncoder.SetVar('DOBYear', Birthday[2]) GetAccountPacket += PacketEncoder.SetVar('userId', self.GAMEOBJ.UserID) # Not sure what is this GetAccountPacket += PacketEncoder.SetVar('globalOptin', 0) GetAccountPacket += PacketEncoder.SetVar('thidPartyOptin', 0) # Other required data GetAccountPacket += PacketEncoder.SetVar('language', 'enUS') GetAccountPacket += PacketEncoder.SetVar('country', 'US', True) GetAccountPacket = PacketEncoder.encode('acct', GetAccountPacket, 0xC0000000, self.PacketID) self.transport.getHandle().sendall(GetAccountPacket) elif txn == 'NuLookupUserInfo': # Load Soldiers info RequestedPersonas = int(PacketDecoder.decode(data).GetVar('userInfo.[]')) loop = 0 LookupUserInfoPacket = PacketEncoder.SetVar('TXN', 'NuLookupUserInfo') while loop != RequestedPersonas: CurrentHero = PacketDecoder.decode(data).GetVar('userInfo.' + str(loop) + '.userName') HeroID = GetHeroIDByName(CurrentHero) if HeroID == False: HeroID = 0 LookupUserInfoPacket += PacketEncoder.SetVar('userInfo.' + str(loop) + '.userName', CurrentHero) LookupUserInfoPacket += PacketEncoder.SetVar('userInfo.' + str(loop) + '.userId', HeroID) LookupUserInfoPacket += PacketEncoder.SetVar('userInfo.' + str(loop) + '.masterUserId', HeroID) LookupUserInfoPacket += PacketEncoder.SetVar('userInfo.' + str(loop) + '.namespace', 'MAIN') LookupUserInfoPacket += PacketEncoder.SetVar('userInfo.' + str(loop) + '.xuid', 24) loop += 1 LookupUserInfoPacket += PacketEncoder.SetVar('userInfo.[]', RequestedPersonas, True) LookupUserInfoPacket = PacketEncoder.encode('acct', LookupUserInfoPacket, 0xC0000000, self.PacketID) self.transport.getHandle().sendall(LookupUserInfoPacket) elif txn == 'NuLoginPersona': # For now - Always login self.GAMEOBJ.LoginKey = RandomStringGenerator.Generate(24) LoginPersonaPacket = PacketEncoder.SetVar('TXN', 'NuLoginPersona') LoginPersonaPacket += PacketEncoder.SetVar('lkey', self.GAMEOBJ.LoginKey) LoginPersonaPacket += PacketEncoder.SetVar('profileId', self.GAMEOBJ.UserID) LoginPersonaPacket += PacketEncoder.SetVar('userId', self.GAMEOBJ.UserID) self.GAMEOBJ.Name = GetUserName(self.GAMEOBJ.UserID) LoginPersonaPacket = PacketEncoder.encode('acct', LoginPersonaPacket, 0xC0000000, self.PacketID) self.transport.getHandle().sendall(LoginPersonaPacket) else: print ConsoleColor('Warning') + '[FESLClient][acct] Got unknown TXN (' + txn + ')' + ConsoleColor('End')
def getUserSessionFromAuth(self, data_e): if self.GAMEOBJ == None: self.GAMEOBJ = DataClass.BF3Client() self.GAMEOBJ.NetworkInt = self.transport packedIP = socket.inet_aton(self.transport.getPeer().host) self.GAMEOBJ.EXTIP = struct.unpack("!L", packedIP)[0] self.GAMEOBJ.IsUp = True packet = BlazeFuncs.BlazeDecoder(data_e) name = packet.getVar("AUTH") port = self.transport.getPeer().port print "Client connecting by port = " + str(port) for auth in Globals.authClients: if auth.Port == port: name = auth.Name print name + " Authed By Port" cwd = os.getcwd() path = cwd + "\\Users\\" + name + "\\" if name == "": print "No account..." #self.transport.loseConnection() return if not os.path.exists(path): print "No account folder exists..." #self.transport.loseConnection() return id = 0 for c in name: id += ord(c) self.GAMEOBJ.PersonaID = id self.GAMEOBJ.UserID = id self.GAMEOBJ.Name = name Globals.Clients.append(self.GAMEOBJ) reply = BlazeFuncs.BlazePacket("0023", "000a", packet.packetID, "1000") reply.writeBool("ANON", False) reply.writeBool("NTOS", False) #SESS STRUCT START reply.writeSStruct("SESS") reply.writeInt("BUID", self.GAMEOBJ.PersonaID) reply.writeBool("FRSC", False) reply.writeBool("FRST", False) reply.writeString("KEY ", "SessionKey_1337") reply.writeInt("LLOG", 1403663841) reply.writeString("MAIL", self.GAMEOBJ.EMail) #PDTL STRUCT START reply.writeSStruct("PDTL") reply.writeString("DSNM", self.GAMEOBJ.Name) reply.writeInt("PID ", self.GAMEOBJ.PersonaID) reply.writeInt("PLAT", 4) reply.writeEUnion() # END PDTL reply.writeInt("UID ", self.GAMEOBJ.PersonaID) reply.writeEUnion() #END SESS reply.writeBool("SPAM", True) reply.writeBool("UNDR", False) self.transport.getHandle().sendall(reply.build().decode('Hex')) reply = BlazeFuncs.BlazePacket("7802", "0008", "0000", "2000") reply.writeInt("ALOC", 1403663841) reply.writeInt("BUID", 321422442) reply.append("8E7A640982E003029DE68780808080C03F") reply.writeString("DSNM", self.GAMEOBJ.Name) reply.writeBool("FRSC", False) reply.writeBool("FRST", False) reply.writeString("KEY ", "SessionKey_1337") reply.writeInt("LAST", 1403663841) reply.writeInt("LLOG", 1403663841) reply.writeString("MAIL", self.GAMEOBJ.EMail) reply.writeInt("PID ", self.GAMEOBJ.PersonaID) reply.writeInt("PLAT", 4) reply.writeInt("UID ", self.GAMEOBJ.PersonaID) reply.writeInt("USTP", 0) reply.writeInt("XREF", 0) pack1, pack2 = reply.build() self.transport.getHandle().sendall(pack1.decode('Hex')) self.transport.getHandle().sendall(pack2.decode('Hex')) reply = BlazeFuncs.BlazePacket("7802", "0002", "0000", "2000") reply.writeSStruct("DATA") reply.append("864932067f") #ADDR reply.writeString("BPS ", "") reply.writeString("CTY ", "") reply.append("8f68720700") #CVAR reply.writeInt("HWFG", 0) reply.writeSStruct("QDAT") reply.writeInt("DBPS", 0) reply.writeInt("NATT", 0) reply.writeInt("UBPS", 0) reply.writeEUnion() #END QDAT #reply.writeInt("UATT", 0) reply.append("D61D3400808080D081A409") reply.append("D6CCF404090182E003029DE68780808080C03F") reply.writeEUnion() #END DATA reply.writeSStruct("USER") reply.writeInt("AID ", self.GAMEOBJ.UserID) reply.writeInt("ALOC", 1701729619) reply.writeInt("ID ", self.GAMEOBJ.PersonaID) reply.writeString("NAME", self.GAMEOBJ.Name) reply.writeInt("ORIG", self.GAMEOBJ.PersonaID) reply.writeInt("PIDI", self.GAMEOBJ.PersonaID) reply.writeEUnion() #END USER pack1, pack2 = reply.build() self.transport.getHandle().sendall(pack1.decode('Hex')) self.transport.getHandle().sendall(pack2.decode('Hex')) reply = BlazeFuncs.BlazePacket("7802", "0005", "0000", "2000") reply.writeInt("FLGS", 3) reply.writeInt("ID ", self.GAMEOBJ.PersonaID) pack1, pack2 = reply.build() self.transport.getHandle().sendall(pack1.decode('Hex')) self.transport.getHandle().sendall(pack2.decode('Hex'))
def render_POST(self, request): urlPath = request.path.split('/') #print request #print request.args #print request.content.read() #print request.content.getvalue() #print list(request.headers) #print urlPath #print "====================" #Error ints # 1 = No User found # 2 = Password error, check password.txt file or make one if(urlPath[1] == "login"): args = request.content.getvalue().split("&") name = "" password = "" if (args[0].split("=")[0] == "username"): name = args[0].split("=")[1] if(len(args) > 1): if (args[1].split("=")[0] == "password"): password = args[1].split("=")[1] #cwd = os.getcwd() #path = cwd+"\\Users\\"+name+"\\" print "[SQLite] User logging in, username: "******" password: "******"[SQLite] User login fail!" return str(1) else: for auth in Globals.authClients: if auth.Name == name: return str(auth.Port) port = self.getFreePort() authClient = DataClass.AuthClient() authClient.Name = name authClient.Port = port Globals.authClients.append(authClient) print "[SQLite] Added " + name + ":" + str(authClient.Port) + " To Authentication List" return str(authClient.Port) ''' if name == "" or os.path.exists(path) == False: return str(1) if (Globals.userPasswords): if(len(args) < 2): return str(2) if os.path.isfile(path+"password.txt") == False: return str(2) passwordFile = open(path+"password.txt") userPassword = str(passwordFile.readline()) passwordFile.close() if(userPassword != password): return str(2) ''' return '"528591967549a51344692b9e18294e4c8240b7b7"'
def SilentLogin(self,data_e): if self.GAMEOBJ == None: self.GAMEOBJ = DataClass.BF3Client() self.GAMEOBJ.NetworkInt = self.transport Globals.Clients.append(self.GAMEOBJ) packedIP = socket.inet_aton(self.transport.getPeer().host) self.GAMEOBJ.EXTIP = struct.unpack("!L", packedIP)[0] self.GAMEOBJ.IsUp = True packet = BlazeFuncs.BlazeDecoder(data_e) loginKey = packet.getVar("AUTH") PID = packet.getVar("PID ") id = 0 for c in loginKey: id += ord(c) #path2 = cwd+"\\Stats\\"+str(id)+"\\" #if not os.path.exists(path2): # os.makedirs(path2) self.GAMEOBJ.UserID = id self.GAMEOBJ.EMail = "*****@*****.**" self.GAMEOBJ.PersonaID = id self.GAMEOBJ.Name = loginKey self.GAMEOBJ.SessionKey = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(42)) self.GAMEOBJ.LoginKey = loginKey #if not os.path.isfile(path2+"userstats.txt"): # shutil.copy2('Stats/default/userstats.txt', path2) #if not os.path.isfile(path2+"usersettings.txt"): # shutil.copy2('Stats/default/usersettings.txt', path2) reply = BlazeFuncs.BlazePacket("0001","0032",packet.packetID,"1000") reply.writeInt("AGUP", 0) reply.writeString("LDHT", "") reply.writeBool("NTOS", False) reply.writeString("PCTK", "LoginKey_1337") reply.writeString("PRIV", "") #SESS STRUCT START reply.writeSStruct("SESS") reply.writeInt("BUID", self.GAMEOBJ.PersonaID) reply.writeBool("FRST", False) reply.writeString("KEY ", self.GAMEOBJ.SessionKey) reply.writeInt("LLOG", 0) reply.writeString("MAIL", self.GAMEOBJ.Name) #PDTL STRUCT START reply.writeSStruct("PDTL") reply.writeString("DSNM", self.GAMEOBJ.Name) reply.writeInt("LAST", 0) reply.writeInt("PID ",self.GAMEOBJ.PersonaID) reply.writeInt("STAS", 0) reply.writeInt("XREF", 0) reply.writeInt("XTYP", 0) reply.writeEUnion() #PDTL STRUCT END reply.writeInt("UID ",self.GAMEOBJ.UserID) #------------------ reply.writeEUnion() #SESS STRUCT END--- reply.writeBool("SPAM", False) reply.writeString("THST", "") reply.writeString("TSUI", "") reply.writeString("TURI", "") self.transport.getHandle().sendall(reply.build().decode('Hex')) reply = BlazeFuncs.BlazePacket("7802","0002","0000","2000") reply.writeSStruct("USER") reply.writeInt("AID ", self.GAMEOBJ.UserID) reply.writeInt("ALOC", 1701729619) reply.writeInt("ID ", self.GAMEOBJ.PersonaID) reply.writeString("NAME", self.GAMEOBJ.Name) reply.writeEUnion() #END USER pack1, pack2 = reply.build() self.transport.getHandle().sendall(pack1.decode('Hex')) self.transport.getHandle().sendall(pack2.decode('Hex')) reply = BlazeFuncs.BlazePacket("7802","0005","0000","2000") reply.writeInt("FLGS", 3) reply.writeInt("ID ", self.GAMEOBJ.PersonaID) pack1, pack2 = reply.build() self.transport.getHandle().sendall(pack1.decode('Hex')) self.transport.getHandle().sendall(pack2.decode('Hex'))
def getUserSessionFromAuth(self, data_e): if self.GAMEOBJ == None: self.GAMEOBJ = DataClass.BF3Client() self.GAMEOBJ.NetworkInt = self.transport packedIP = socket.inet_aton(self.transport.getPeer().host) self.GAMEOBJ.EXTIP = struct.unpack("!L", packedIP)[0] self.GAMEOBJ.IsUp = True packet = BlazeFuncs.BlazeDecoder(data_e) name = packet.getVar("AUTH") name = "" #print name cwd = os.getcwd() path = cwd + "\\Users\\" + name + "\\" ipPlayer = str(self.transport.getPeer()).split('\'') ipPlayerJoining = ipPlayer[1] matching = [s for s in Https.playersJoining if ipPlayerJoining in s] arrayItem = str(matching) if (arrayItem == "[]"): print( "[BETA-JOIN-SYSTEM] Error! Not authorized user, dropping connection..." ) self.transport.loseConnection() self.GAMEOBJ.IsUp = False print("[BETA-JOIN-SYSTEM] Connection Dropped!") else: print("[BETA-JOIN-SYSTEM] Authorized user joining...") itemRemove = str( arrayItem.replace("[", "").replace("]", "").replace("'", "")) itemRemoveSplit = itemRemove.split('|') playerIp = itemRemoveSplit[0] playerUsername = itemRemoveSplit[1] playerPassword = itemRemoveSplit[2] #print(str(playerUsername)) name = str(playerUsername) Https.playersJoining.remove(itemRemove) print("[BETA-JOIN-SYSTEM] User, IP: " + playerIp + " Username: "******" Joined!") #print name ''' if name == "": print "No account..." self.transport.loseConnection() if not os.path.exists(path): print "No account..." self.transport.loseConnection() ''' id = 0 for c in name: id += ord(c) self.GAMEOBJ.PersonaID = id self.GAMEOBJ.UserID = id self.GAMEOBJ.Name = name Globals.Clients.append(self.GAMEOBJ) reply = BlazeFuncs.BlazePacket("0023", "000a", packet.packetID, "1000") reply.writeBool("ANON", False) reply.writeBool("NTOS", False) #SESS STRUCT START reply.writeSStruct("SESS") reply.writeInt("BUID", self.GAMEOBJ.PersonaID) reply.writeBool("FRSC", False) reply.writeBool("FRST", False) reply.writeString("KEY ", "SessionKey_1337") reply.writeInt("LLOG", 1403663841) reply.writeString("MAIL", self.GAMEOBJ.EMail) #PDTL STRUCT START reply.writeSStruct("PDTL") reply.writeString("DSNM", self.GAMEOBJ.Name) reply.writeInt("PID ", self.GAMEOBJ.PersonaID) reply.writeInt("PLAT", 4) reply.writeEUnion() # END PDTL reply.writeInt("UID ", self.GAMEOBJ.PersonaID) reply.writeEUnion() #END SESS reply.writeBool("SPAM", True) reply.writeBool("UNDR", False) self.transport.getHandle().sendall(reply.build().decode('Hex')) reply = BlazeFuncs.BlazePacket("7802", "0008", "0000", "2000") reply.writeInt("ALOC", 1403663841) reply.writeInt("BUID", 321422442) reply.append("8E7A640982E003029DE68780808080C03F") reply.writeString("DSNM", self.GAMEOBJ.Name) reply.writeBool("FRSC", False) reply.writeBool("FRST", False) reply.writeString("KEY ", "SessionKey_1337") reply.writeInt("LAST", 1403663841) reply.writeInt("LLOG", 1403663841) reply.writeString("MAIL", self.GAMEOBJ.EMail) reply.writeInt("PID ", self.GAMEOBJ.PersonaID) reply.writeInt("PLAT", 4) reply.writeInt("UID ", self.GAMEOBJ.PersonaID) reply.writeInt("USTP", 0) reply.writeInt("XREF", 0) pack1, pack2 = reply.build() self.transport.getHandle().sendall(pack1.decode('Hex')) self.transport.getHandle().sendall(pack2.decode('Hex')) reply = BlazeFuncs.BlazePacket("7802", "0002", "0000", "2000") reply.writeSStruct("DATA") reply.append("864932067f") #ADDR reply.writeString("BPS ", "") reply.writeString("CTY ", "") reply.append("8f68720700") #CVAR reply.writeInt("HWFG", 0) reply.writeSStruct("QDAT") reply.writeInt("DBPS", 0) reply.writeInt("NATT", 0) reply.writeInt("UBPS", 0) reply.writeEUnion() #END QDAT #reply.writeInt("UATT", 0) reply.append("D61D3400808080D081A409") reply.append("D6CCF404090182E003029DE68780808080C03F") reply.writeEUnion() #END DATA reply.writeSStruct("USER") reply.writeInt("AID ", self.GAMEOBJ.UserID) reply.writeInt("ALOC", 1701729619) reply.writeInt("ID ", self.GAMEOBJ.PersonaID) reply.writeString("NAME", self.GAMEOBJ.Name) reply.writeInt("ORIG", self.GAMEOBJ.PersonaID) reply.writeInt("PIDI", self.GAMEOBJ.PersonaID) reply.writeEUnion() #END USER pack1, pack2 = reply.build() self.transport.getHandle().sendall(pack1.decode('Hex')) self.transport.getHandle().sendall(pack2.decode('Hex')) reply = BlazeFuncs.BlazePacket("7802", "0005", "0000", "2000") reply.writeInt("FLGS", 3) reply.writeInt("ID ", self.GAMEOBJ.PersonaID) pack1, pack2 = reply.build() self.transport.getHandle().sendall(pack1.decode('Hex')) self.transport.getHandle().sendall(pack2.decode('Hex'))
def ReceiveComponent(self, data, txn): if txn == 'NuLogin': try: ServerPassword = PacketDecoder.decode(data).GetVar('password') except: ServerPassword = None # Save client connection info if self.GAMEOBJ == None: self.GAMEOBJ = DataClass.BF2Server() self.GAMEOBJ.FESLNetworkInt = self.transport Globals.Servers.append(self.GAMEOBJ) if ServerPassword == None: print ConsoleColor( 'Warning' ) + '[FESLServer][acct] Server didnt send password! Disconnecting...' + ConsoleColor( 'End') LoginPacket = PacketEncoder.SetVar('TXN', 'NuLogin') LoginPacket += PacketEncoder.SetVar( 'localizedMessage', '"The password the user specified is incorrect"') LoginPacket += PacketEncoder.SetVar('errorContainer.[]', 0) LoginPacket += PacketEncoder.SetVar('errorCode', 122, True) LoginPacket = PacketEncoder.encode('acct', LoginPacket, 0xC0000000, self.PacketID) self.transport.getHandle().sendall(LoginPacket) self.transport.loseConnection() if CheckServerPassword(ServerPassword) == True: print ConsoleColor( 'Success' ) + '[FESLServer][acct] Server successfully logged in!' + ConsoleColor( 'End') self.GAMEOBJ.LoginKey = RandomStringGenerator.Generate(24) self.GAMEOBJ.UserID = CheckServerPassword(ServerPassword) LoginPacket = PacketEncoder.SetVar('TXN', 'NuLogin') LoginPacket += PacketEncoder.SetVar('lkey', self.GAMEOBJ.LoginKey) LoginPacket += PacketEncoder.SetVar( 'nuid', GetServerAuthData(self.GAMEOBJ.UserID)[1]) LoginPacket += PacketEncoder.SetVar('profileId', self.GAMEOBJ.UserID) LoginPacket += PacketEncoder.SetVar('userId', self.GAMEOBJ.UserID) LoginPacket = PacketEncoder.encode('acct', LoginPacket, 0xC0000000, self.PacketID) self.transport.getHandle().sendall(LoginPacket) else: print ConsoleColor( 'Warning' ) + '[FESLServer][acct] Server specified wrong password! Disconnecting...' + ConsoleColor( 'End') LoginPacket = PacketEncoder.SetVar('TXN', 'NuLogin') LoginPacket += PacketEncoder.SetVar( 'localizedMessage', '"The password the user specified is incorrect"') LoginPacket += PacketEncoder.SetVar('errorContainer.[]', 0) LoginPacket += PacketEncoder.SetVar('errorCode', 122, True) LoginPacket = PacketEncoder.encode('acct', LoginPacket, 0xC0000000, self.PacketID) self.transport.getHandle().sendall(LoginPacket) self.transport.loseConnection() elif txn == 'NuGetPersonas': PersonaPacket = PacketEncoder.SetVar('TXN', 'NuGetPersonas') PersonaPacket += PacketEncoder.SetVar('personas.[]', 0) PersonaPacket = PacketEncoder.encode('acct', PersonaPacket, 0xC0000000, self.PacketID) self.transport.getHandle().sendall(PersonaPacket) elif txn == 'NuGetAccount': AccountPacket = PacketEncoder.SetVar('TXN', 'NuGetAccount') AccountPacket += PacketEncoder.SetVar( 'heroName', GetServerAuthData(self.GAMEOBJ.UserID)[1]) AccountPacket += PacketEncoder.SetVar( 'nuid', GetServerAuthData(self.GAMEOBJ.UserID)[1]) AccountPacket += PacketEncoder.SetVar('DOBDay', 01) AccountPacket += PacketEncoder.SetVar('DOBMonth', 01) AccountPacket += PacketEncoder.SetVar('DOBYear', 1970) AccountPacket += PacketEncoder.SetVar('userId', self.GAMEOBJ.UserID) AccountPacket += PacketEncoder.SetVar('globalOptin', 0) AccountPacket += PacketEncoder.SetVar('thidPartyOptin', 0) AccountPacket += PacketEncoder.SetVar('language', 'enUS') AccountPacket += PacketEncoder.SetVar('country', 'US') AccountPacket = PacketEncoder.encode('acct', AccountPacket, 0xC0000000, self.PacketID) self.transport.getHandle().sendall(AccountPacket) elif txn == 'NuLoginPersona': LoginPacket = PacketEncoder.SetVar('TXN', 'NuLoginPersona') LoginPacket += PacketEncoder.SetVar('lkey', self.GAMEOBJ.LoginKey) LoginPacket += PacketEncoder.SetVar('profileId', self.GAMEOBJ.UserID) LoginPacket += PacketEncoder.SetVar('userId', self.GAMEOBJ.UserID) LoginPacket = PacketEncoder.encode('acct', LoginPacket, 0xC0000000, self.PacketID) self.transport.getHandle().sendall(LoginPacket) elif txn == 'NuLookupUserInfo': LookupPacket = PacketEncoder.SetVar('TXN', 'NuLookupUserInfo') LookupPacket += PacketEncoder.SetVar( 'userInfo.0.userName', GetServerAuthData(self.GAMEOBJ.UserID)[1]) LookupPacket += PacketEncoder.SetVar('userInfo.0.userId', self.GAMEOBJ.UserID) LookupPacket += PacketEncoder.SetVar('userInfo.0.masterUserId', self.GAMEOBJ.UserID) LookupPacket += PacketEncoder.SetVar('userInfo.0.namespace', 'MAIN') LookupPacket += PacketEncoder.SetVar('userInfo.0.xuid', 24) LookupPacket += PacketEncoder.SetVar('userInfo.0.cid', self.GAMEOBJ.UserID) LookupPacket += PacketEncoder.SetVar('userInfo.[]', 1) LookupPacket = PacketEncoder.encode('acct', LookupPacket, 0xC0000000, self.PacketID) self.transport.getHandle().sendall(LookupPacket) else: print ConsoleColor( 'Warning' ) + '[FESLServer][acct] Got unknown TXN (' + txn + ')' + ConsoleColor( 'End')