def handle(self, txn, data): if txn == "Start": packet = packet_encoder.append('TXN', 'Start') packet += packet_encoder.append('id.id', 1) packet += packet_encoder.append('id.partition', '/eagames/bfwest-dedicated', True) packet = packet_encoder.encode('pnow', self.pid, packet) self.transport.getHandle().sendall(packet) self.log.debug(f'[{self.name}] Sent packet=Start') packet = packet_encoder.append('TXN', 'Status') packet += packet_encoder.append('id.id', 1) packet += packet_encoder.append('id.partition', '/eagames/bfwest-dedicated') packet += packet_encoder.append('sessionState', 'COMPLETE') packet += packet_encoder.append('props.{}.[]', 2) packet += packet_encoder.append('props.{resultType}', 'JOIN') if False: return else: self.log.warning(f'[{self.name}] There are no matches available.') packet += packet_encoder.append('props.{games}.[]', 0) packet = packet_encoder.encode('pnow', self.pid, packet) self.transport.getHandle().sendall(packet) self.log.debug(f'[{self.name}] Sent packet=Status')
def handle(self, data): packet = packet_encoder.append('TID', packet_reader.read_key(data, 'TID')) packet += packet_encoder.append('NAME', 'lucas') packet += packet_encoder.append('CID', '', True) packet = packet_encoder.encode('user', self.pid, packet) self.transport.getHandle().sendall(packet) self.log.debug(f'[{self.name}] Sent packet=user')
def handle(self, data): packet = packet_encoder.append('TID', packet_reader.read_key(data, 'TID')) packet += packet_encoder.append('TIME', str(time.time()).split('.')[0]) packet += packet_encoder.append('activityTimeoutSecs', 3600) packet += packet_encoder.append('PROT', packet_reader.read_key(data, 'PROT')) packet = packet_encoder.encode('CONN', self.pid, packet) self.transport.getHandle().sendall(packet) self.log.debug(f'[{self.name}] Sent packet=CONN')
def handle(self, data, addr): packet = packet_encoder.append('TID', packet_reader.read_key(data, 'TID')) packet += packet_encoder.append('TXN', '') packet += packet_encoder.append('IP', addr[0]) packet += packet_encoder.append('PORT', addr[1]) packet += packet_encoder.append('ERR', 0) packet += packet_encoder.append('TYPE', 1) packet = packet_encoder.encode('ECHO', self.pid, packet) self.transport.write(packet, addr) self.log.debug(f'[{self.name}] Sent packet=ECHO')
def handle(self, txn): if txn == "NuLogin": self.pid += 1 self.login_key = string_util.random_str(24) packet = packet_encoder.append('TXN', 'NuLogin') packet += packet_encoder.append('profileId', CONFIG['Settings']['AccountID']) packet += packet_encoder.append('userId', CONFIG['Settings']['AccountID']) packet += packet_encoder.append('nuid', 'lucas') packet += packet_encoder.append('lkey', self.login_key, True) packet = packet_encoder.encode('acct', self.pid, packet) self.transport.getHandle().sendall(packet) self.log.debug(f'[{self.name}] Sent packet=NuLogin') elif txn == 'NuGetPersonas': self.pid += 1 packet = packet_encoder.append('TXN', 'NuGetPersonas') personas = next(os.walk(json_personas.path))[2] i = 0 for persona in personas: pjson = json.load(open("src/heroes/"+persona, "r")) packet += packet_encoder.append('personas.'+str(i), pjson.get('heroName')) i += 1 packet += packet_encoder.append('personas.[]', str(i), True) packet = packet_encoder.encode('acct', self.pid, packet) self.transport.getHandle().sendall(packet) self.log.debug(f'[{self.name}] Sent packet=NuGetPersonas') elif txn == 'NuGetAccount': self.pid += 1 packet = packet_encoder.append('TXN', 'NuGetAccount') packet += packet_encoder.append('heroName', 'lucas') packet += packet_encoder.append('nuid', '*****@*****.**') packet += packet_encoder.append('DOBDay', '1') packet += packet_encoder.append('DOBMonth', '1') packet += packet_encoder.append('DOBYear', '2017') packet += packet_encoder.append('userId', CONFIG['Settings']['AccountID']) packet += packet_encoder.append('globalOptin', '0') packet += packet_encoder.append('thidPartyOptin', '0') packet += packet_encoder.append('language', 'enUS') packet += packet_encoder.append('country', 'US', True) packet = packet_encoder.encode('acct', self.pid, packet) self.transport.getHandle().sendall(packet) self.log.debug(f'[{self.name}] Sent packet=NuGetAccount') elif txn == 'NuLoginPersona': self.pid += 1 self.loginkey = string_util.random_str(24) packet = packet_encoder.append('TXN', 'NuLoginPersona') packet += packet_encoder.append('lkey', self.loginkey) packet += packet_encoder.append('profileId', CONFIG['Settings']['AccountID']) packet += packet_encoder.append('userId', CONFIG['Settings']['AccountID']) packet = packet_encoder.encode('acct', self.pid, packet) self.transport.getHandle().sendall(packet) self.log.debug(f'[{self.name}] Sent packet=NuLoginPersona') elif txn == 'NuLookupUserInfo': self.pid += 1 packet = packet_encoder.append('TXN', 'NuLookupUserInfo') personas = next(os.walk(json_personas.path))[2] i = 0 for persona in personas: pjson = json.load(open("src/heroes/"+persona, "r")) packet += packet_encoder.append('userInfo.'+str(i)+'.userName', pjson.get('heroName')) packet += packet_encoder.append('userInfo.'+str(i)+'.userId', pjson.get('heroId')) packet += packet_encoder.append('userInfo.'+str(i)+'.namespace', 'MAIN') packet += packet_encoder.append('userInfo.'+str(i)+'.xuid', '24') i += 1 packet += packet_encoder.append('userInfo.[]', str(i), True) packet = packet_encoder.encode('acct', self.pid, packet) self.transport.getHandle().sendall(packet) self.log.debug(f'[{self.name}] Sent packet=NuLookupUserInfo')
def handle(self, txn, data): if txn == "GetStats": self.pid += 1 heroId = packet_reader.read_key(data, 'owner') packet = packet_encoder.append('TXN', 'GetStats') packet += packet_encoder.append('ownerId', heroId) packet += packet_encoder.append( 'ownerType', packet_reader.read_key(data, 'ownerType')) total_keys = int(packet_reader.read_key(data, 'keys.[]')) key_names = [] i = 0 while i != total_keys: key_names.append(packet_reader.read_key(data, 'keys.' + str(i))) i += 1 i = 0 while i != total_keys: if int(heroId) != int( json_personas.CONFIG['Settings']['AccountID']): pjson = json.load( open(json_personas.path + heroId + '.json', "r")) else: pjson = json_personas.global_stats packet += packet_encoder.append('stats.' + str(i) + '.key', key_names[i]) packet += packet_encoder.append('stats.' + str(i) + '.value', pjson.get(key_names[i], "")) packet += packet_encoder.append('stats.' + str(i) + '.text', pjson.get(key_names[i], "")) i += 1 packet += packet_encoder.append('stats.[]', total_keys) packet = packet_encoder.encode('rank', self.pid, packet) self.transport.getHandle().sendall(packet) self.log.debug(f'[{self.name}] Sent packet=GetStats') elif txn == "GetStatsForOwners": self.pid += 1 ownerIds = [] ownerTypes = [] key_names = [] total_keys = int(packet_reader.read_key(data, 'keys.[]')) total_owners = int(packet_reader.read_key(data, 'owners.[]')) i = 0 while i != total_owners: ownerIds.append( packet_reader.read_key(data, 'owners.' + str(i) + '.ownerId')) ownerTypes.append( packet_reader.read_key(data, 'owners.' + str(i) + '.ownerType')) i += 1 packet = packet_encoder.append('TXN', 'GetStats') i = 0 while i != total_keys: key_names.append(packet_reader.read_key(data, 'keys.' + str(i))) i += 1 i = 0 while i != total_owners: pjson = json.load( open(json_personas.path + ownerIds[i] + '.json', "r")) packet += packet_encoder.append('stats.' + str(i) + '.ownerId', ownerIds[i]) packet += packet_encoder.append('stats.' + str(i) + '.ownerType', ownerTypes[i]) ii = 0 while ii != total_keys: packet += packet_encoder.append( 'stats.' + str(i) + '.stats.' + str(ii) + '.key', key_names[ii]) packet += packet_encoder.append( 'stats.' + str(i) + '.stats.' + str(ii) + '.value', pjson.get(key_names[ii], '')) packet += packet_encoder.append( 'stats.' + str(i) + '.stats.' + str(ii) + '.text', pjson.get(key_names[ii], '')) ii += 1 packet += packet_encoder.append('stats.' + str(i) + '.stats.[]', str(total_keys)) i += 1 packet += packet_encoder.append('stats.[]', total_owners) packet = packet_encoder.encode('rank', self.pid, packet) self.transport.getHandle().sendall(packet) self.log.debug(f'[{self.name}] Sent packet=GetStatsForOwners') elif txn == "UpdateStats": packet = packet_encoder.encode( 'rank', 0xC0000000, packet_encoder.append('TXN', 'UpdateStats')) self.transport.getHandle().sendall(packet) self.log.debug(f'[{self.name}] Sent packet=UpdateStats')
def handle(self, txn): if txn == 'NuLogin': self.pid += 1 self.login_key = string_util.random_str(24) packet = packet_encoder.append('TXN', 'NuLogin') packet += packet_encoder.append('lkey', self.login_key) packet += packet_encoder.append('nuid', 'test-server') packet += packet_encoder.append('profileId', '1000') packet += packet_encoder.append('userId', '1000') packet = packet_encoder.encode('acct', self.pid, packet) self.transport.getHandle().sendall(packet) self.log.debug(f'[{self.name}] Sent packet=NuLogin') elif txn == 'NuGetPersonas': self.pid += 1 packet = packet_encoder.append('TXN', 'NuGetPersonas') packet += packet_encoder.append('personas.[]', 0) packet = packet_encoder.encode('acct', self.pid, packet) self.transport.getHandle().sendall(packet) self.log.debug(f'[{self.name}] Sent packet=NuGetPersonas') elif txn == 'NuGetAccount': self.pid += 1 packet = packet_encoder.append('TXN', 'NuGetAccount') packet += packet_encoder.append('heroName', 'test-server') packet += packet_encoder.append('nuid', '*****@*****.**') packet += packet_encoder.append('DOBDay', '1') packet += packet_encoder.append('DOBMonth', '1') packet += packet_encoder.append('DOBYear', '2017') packet += packet_encoder.append('userId', '1000') packet += packet_encoder.append('globalOptin', '0') packet += packet_encoder.append('thidPartyOptin', '0') packet += packet_encoder.append('language', 'enUS') packet += packet_encoder.append('country', 'US') packet = packet_encoder.encode('acct', self.pid, packet) self.transport.getHandle().sendall(packet) self.log.debug(f'[{self.name}] Sent packet=NuGetAccount') elif txn == 'NuLoginPersona': packet = packet_encoder.append('TXN', 'NuLoginPersona') packet += packet_encoder.append('lkey', self.login_key) packet += packet_encoder.append('profileId', '1000') packet += packet_encoder.append('userId', '1000') packet = packet_encoder.encode('acct', self.pid, packet) self.transport.getHandle().sendall(packet) self.log.debug(f'[{self.name}] Sent packet=NuLoginPersona') elif txn == 'NuLookupUserInfo': packet = packet_encoder.append('TXN', 'NuLookupUserInfo') packet += packet_encoder.append('userInfo.0.userName', 'test-server') packet += packet_encoder.append('userInfo.0.userId', '1000') packet += packet_encoder.append('userInfo.0.masterUserId', '1000') packet += packet_encoder.append('userInfo.0.namespace', 'MAIN') packet += packet_encoder.append('userInfo.0.xuid', '24') packet += packet_encoder.append('userInfo.0.cid', '1000') packet += packet_encoder.append('userInfo.[]', '1') packet = packet_encoder.encode('acct', self.pid, packet) self.transport.getHandle().sendall(packet) self.log.debug(f'[{self.name}] Sent packet=NuLookupUserInfo')
def handle(self, txn): if txn == "Hello": mem_packet = packet_encoder.append('TXN', 'MemCheck') mem_packet += packet_encoder.append('memcheck.[]', 0) mem_packet += packet_encoder.append('salt', 5, True) mem_packet = packet_encoder.encode('fsys', 0xC0000000, mem_packet) session_packet = packet_encoder.append('TXN', 'GetSessionId', True) session_packet = packet_encoder.encode('gsum', 0x0, session_packet) self.pid += 1 packet = packet_encoder.append('curTime', strftime('%b-%d-%Y %H:%M:%S UTC')) packet += packet_encoder.append('messengerIp', '127.0.0.1') packet += packet_encoder.append('messengerPort', 13505) packet += packet_encoder.append('TXN', 'Hello') packet += packet_encoder.append('domainPartition.subDomain', 'bfwest-dedicated') packet += packet_encoder.append('theaterIp', '127.0.0.1') packet += packet_encoder.append('theaterPort', 18275) packet += packet_encoder.append('domainPartition.domain', 'eagames') packet += packet_encoder.append('activityTimeoutSecs', 3600, True) packet = packet_encoder.encode('fsys', self.pid, packet) self.transport.getHandle().sendall(mem_packet) self.log.debug(f'[{self.name}] Sent packet=MemCheck') self.transport.getHandle().sendall(session_packet) self.log.debug(f'[{self.name}] Sent packet=GetSessonId') self.transport.getHandle().sendall(packet) self.log.debug(f'[{self.name}] Sent packet=Hello') elif txn == "MemCheck": pass elif txn == "Goodbye": pass elif txn == "GetPingSites": self.pid += 1 packet = packet_encoder.append('TXN', 'GetPingSites') packet += packet_encoder.append('minPingSitesToPing', 2) packet += packet_encoder.append('pingSites.[]', 2) packet += packet_encoder.append('pingSites.0.addr', '127.0.0.1') packet += packet_encoder.append('pingSites.0.name', 'gva') packet += packet_encoder.append('pingSites.0.type', 0) packet += packet_encoder.append('pingSites.1.addr', '127.0.0.1') packet += packet_encoder.append('pingSites.1.name', 'nrt') packet += packet_encoder.append('pingSites.1.type', 0) packet = packet_encoder.encode('fsys', self.pid, packet) self.transport.getHandle().sendall(packet) self.log.debug(f'[{self.name}] Sent packet=GetPingSites') else: pass
def handle (self, txn): if txn == 'Hello': mem_packet = packet_encoder.append('TXN', 'MemCheck') mem_packet += packet_encoder.append('memcheck.[]', 0) mem_packet += packet_encoder.append('salt', 5, True) mem_packet = packet_encoder.encode('fsys', 0xC0000000, mem_packet) self.pid += 1 packet = packet_encoder.append('curTime', strftime('%b-%d-%Y %H:%M:%S UTC')) packet += packet_encoder.append('messengerIp', '127.0.0.1') packet += packet_encoder.append('messengerPort', 13505) packet += packet_encoder.append('TXN', 'Hello') packet += packet_encoder.append('domainPartition.subDomain', 'bfwest-server') packet += packet_encoder.append('theaterIp', '127.0.0.1') packet += packet_encoder.append('theaterPort', 18275) packet += packet_encoder.append('domainPartition.domain', 'eagames') packet += packet_encoder.append('activityTimeoutSecs', 3600, True) packet = packet_encoder.encode('fsys', self.pid, packet) self.transport.getHandle().sendall(mem_packet) self.log.debug(f'[{self.name}] Sent packet=MemCheck') self.transport.getHandle().sendall(packet) self.log.debug(f'[{self.name}] Sent packet=Hello') elif txn == "MemCheck": pass elif txn == "Goodbye": pass