From 065b2907530ebb5e517a71e6478aeda845447040 Mon Sep 17 00:00:00 2001 From: AleaJactaEst Date: Fri, 8 May 2020 15:49:07 +0200 Subject: [PATCH] update spkykhanat --- spykhanat.py | 10 ++++++++++ tools/CAction.py | 3 ++- tools/CActionFactory.py | 8 +++++--- tools/Impulse.py | 15 ++++++++++++++- 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/spykhanat.py b/spykhanat.py index 122fa81..bd451b6 100755 --- a/spykhanat.py +++ b/spykhanat.py @@ -246,6 +246,11 @@ class SpyPcap(): pass except BitStream.OverflowError: noerror = False + except RuntimeError: + noerror = False + except TypeError as e: + logging.getLogger(LOGGER).debug("[Client -> Server] Impossible to decode %s (not read:%u, msg:%s)" % (e.__class__, msgin.needRead(), msgin.showAllData())) + #raise e except Exception as e: logging.getLogger(LOGGER).debug("[Client -> Server] end %s (not read:%u)" % (e.__class__, msgin.needRead())) raise e @@ -262,6 +267,11 @@ class SpyPcap(): ) #, Reference = Parent, Name = "%s_%d" % (target, 0)) if impulse: impulses.append(impulse) + except BitStream.OverflowError as e: + logging.getLogger(LOGGER).debug("[Client -> Server] error:%s : %s"% (e.__class__, msgin.showAllData())) + except AttributeError as e: + logging.getLogger(LOGGER).debug("[Client -> Server] error:%s : %s"% (e.__class__, msgin.showAllData())) + #raise "Bad message" except Impulse.ImpulseNoElement: pass ids += 1 diff --git a/tools/CAction.py b/tools/CAction.py index 175845a..182300c 100644 --- a/tools/CAction.py +++ b/tools/CAction.py @@ -332,6 +332,7 @@ class CActionGenericMultiPart(CAction): msgout.pushUint8(self.Number) msgout.pushUint16(self.Part) msgout.pushUint16(self.NbBlock) + raise "Missing size param" msgout.pushArrayUint8(self.PartCont) def reset(self): @@ -340,7 +341,7 @@ class CActionGenericMultiPart(CAction): self.Part = 0 self.NbBlock = 0 - def genericAction(self, decodeImpulse, world, cGenericMultiPartTemp, Reference, Name): + def genericAction(self, decodeImpulse, world, cGenericMultiPartTemp, Reference = None, Name = None): ''' khanat-opennel-code/code/ryzom/client/src/network_connection.cpp # void CNetworkConnection::genericAction (CActionGenericMultiPart *agmp) ''' diff --git a/tools/CActionFactory.py b/tools/CActionFactory.py index 63749bb..a36a0fb 100644 --- a/tools/CActionFactory.py +++ b/tools/CActionFactory.py @@ -96,11 +96,11 @@ class CActionFactory: khanat-opennel-code/code/ryzom/common/src/game_share/action_factory.cpp : CAction *CActionFactory::unpack (NLMISC::CBitMemStream &message, NLMISC::TGameCycle /* currentCycle */ ) ''' if msgin.needRead() >= 8: - shortcode = msgin.readBool('shortcode') + shortcode = msgin.readBool('CActionFactory:shortcode') if shortcode: - code = msgin.readSerial(2, 'code') + code = msgin.readSerial(2, 'CActionFactory:code') else: - code = msgin.readUint8('code') + code = msgin.readUint8('CActionFactory:code') logging.getLogger(LOGGER).debug("[decoded] %s" % msgin.showAllData()) action = self.create(CAction.INVALID_SLOT, code) if action: @@ -117,6 +117,8 @@ class CActionFactory: action.add_reference(Reference) if Name: action.set_name(Name) + else: + raise RuntimeError return action diff --git a/tools/Impulse.py b/tools/Impulse.py index 1907e03..1941561 100644 --- a/tools/Impulse.py +++ b/tools/Impulse.py @@ -639,6 +639,18 @@ class impulseDatabaseInitPlayer(ImpulseBase): propertyCount = self.readUint32(msgin, '%s_propertyCount' % id) +class ImpulseConnectionDeleteChar(ImpulseBase): + def __init__(self): + super().__init__() + + def read(self, name, msgin, world): + # khanat-opennel-code/code/ryzom/client/src/net_manager.cpp void impulseDatabaseInitPlayer(NLMISC::CBitMemStream &impulse) + # khanat-opennel-code/code/ryzom/server/src/simulation_service/simulated_editor.cpp void impulseDatabaseInitPlayer(NLMISC::CBitMemStream &impulse) + id = "ConnectionDeleteChar" + logging.getLogger(LOGGER).debug("read") + self.name = name.replace(':', '_') + self.readUint8(msgin, '%s_slot' % id) + class DecodeImpulseSimple: def __init__(self): ''' @@ -654,6 +666,7 @@ class DecodeImpulseSimple: self.GenericMsgHeaderMngr.setdefault( "BOTCHAT:SET_FILTERS", ImpulseBotchatSetFilters ) self.GenericMsgHeaderMngr.setdefault( "CONNECTION:ASK_NAME", ImpulseConnectionAskName ) self.GenericMsgHeaderMngr.setdefault( "CONNECTION:CREATE_CHAR", ImpulseConnectionCreateChar ) + self.GenericMsgHeaderMngr.setdefault( "CONNECTION:DELETE_CHAR", ImpulseConnectionDeleteChar ) self.GenericMsgHeaderMngr.setdefault( "CONNECTION:READY", ImpulseConnectionReady ) self.GenericMsgHeaderMngr.setdefault( "CONNECTION:SELECT_CHAR", ImpulseConnectionSelectChar ) self.GenericMsgHeaderMngr.setdefault( "CONNECTION:SHARD_ID", ImpulseConnectionShardId ) @@ -674,7 +687,7 @@ class DecodeImpulseSimple: self.GenericMsgHeaderMngr.setdefault( "STRING_MANAGER:STRING_RQ", ImpulseSringManagerStringRq ) self.GenericMsgHeaderMngr.setdefault( "ENCYCLOPEDIA:INIT", impulseEncyclopediaInit ) self.GenericMsgHeaderMngr.setdefault( "DB_INIT:INV", impulseInitInventory) -# self.GenericMsgHeaderMngr.setdefault( "DB_INIT:PLR", impulseDatabaseInitPlayer) + self.GenericMsgHeaderMngr.setdefault( "DB_INIT:PLR", impulseDatabaseInitPlayer) def execute(self, msgin, world, references = [], name=""): '''