mirror of
https://port.numenaute.org/aleajactaest/clientbot.git
synced 2024-11-22 07:06:14 +00:00
update
This commit is contained in:
parent
8c4e52f6f6
commit
65f0ee64cc
4 changed files with 59 additions and 66 deletions
29
spykhanat.py
29
spykhanat.py
|
@ -118,9 +118,9 @@ class SpyPcap():
|
|||
file = open( self.pcap_file , 'rb')
|
||||
pcapfile = savefile.load_savefile(file,verbose=False)
|
||||
for pkt in pcapfile.packets:
|
||||
print("pkt:", dir(pkt))
|
||||
print("pkt.header:", dir(pkt.header))
|
||||
print("pkt.packet:", dir(pkt.packet))
|
||||
#print("pkt:", dir(pkt))
|
||||
#print("pkt.header:", dir(pkt.header))
|
||||
#print("pkt.packet:", dir(pkt.packet))
|
||||
logging.getLogger(LOGGER).debug("raw: %s" % pkt.raw())
|
||||
logging.getLogger(LOGGER).debug("timestamp: %s (%s)" % (pkt.timestamp,datetime.fromtimestamp(pkt.timestamp).strftime("%Y/%m/%d %H:%M:%S")))
|
||||
eth_frame = ethernet.Ethernet(pkt.raw())
|
||||
|
@ -128,16 +128,16 @@ class SpyPcap():
|
|||
if eth_frame.type == 2048:
|
||||
ip_packet = ip.IP(binascii.unhexlify(eth_frame.payload))
|
||||
logging.getLogger(LOGGER).debug("ip packet: %s" % ip_packet)
|
||||
print("ip_packet:", dir(ip_packet))
|
||||
#print("ip_packet:", dir(ip_packet))
|
||||
logging.getLogger(LOGGER).debug("ip packet: %s ->%s" % (ip_packet.src.decode(), ip_packet.dst.decode()) )
|
||||
if ip_packet.p == 17:
|
||||
# UDP
|
||||
logging.getLogger(LOGGER).debug("ip packet: protocol UDP (%s)" % ip_packet.p)
|
||||
udp_packet = udp.UDP(binascii.unhexlify(ip_packet.payload))
|
||||
print("udp_packet:", dir(udp_packet))
|
||||
#print("udp_packet:", dir(udp_packet))
|
||||
logging.getLogger(LOGGER).debug("UDP packet: %s" % udp_packet)
|
||||
data = udp_packet.payload
|
||||
print("data:", dir(data))
|
||||
#print("data:", dir(data))
|
||||
logging.getLogger(LOGGER).debug("data packet: %s" % data)
|
||||
data = udp_packet.payload
|
||||
logging.getLogger(LOGGER).info("data packet: timestamp:%s src:%s:%d dst:%s:%d data:%s" % (pkt.timestamp,
|
||||
|
@ -240,8 +240,7 @@ class SpyPcap():
|
|||
#if msgin.needRead() < (8*8):
|
||||
if msgin.needRead() < 8:
|
||||
logging.getLogger(LOGGER).debug("too small no decodeVisualProperties [{0} > {1}]".format(msgin.sizeRead() + (8*8 ), msgin.sizeData() * 8 ))
|
||||
print("-"*80)
|
||||
print(properties)
|
||||
logging.getLogger(LOGGER).debug("properties:%s" % str(properties))
|
||||
return properties
|
||||
logging.getLogger(LOGGER).debug("too small no decodeVisualProperties [{0} > {1}]".format(msgin.sizeRead() + (8*8 ), msgin.sizeData() * 8 ))
|
||||
slot = msgin.readUint8("Slot")
|
||||
|
@ -541,7 +540,7 @@ class SpyPcap():
|
|||
) #, Reference = Parent, Name = "%s_%d" % (target, 0))
|
||||
logging.getLogger(LOGGER).info("impulse:%s" % str(impulse))
|
||||
if impulse:
|
||||
print("spykhanat.py:412", type(impulse))
|
||||
logging.getLogger(LOGGER).debug("type impulse:%s" % str(type(impulse)))
|
||||
database = None
|
||||
#database = impulse.readDatabases(self.client_state[dst]['world'], self.decodeDatabase)
|
||||
if database:
|
||||
|
@ -563,7 +562,7 @@ class SpyPcap():
|
|||
) #, Reference = Parent, Name = "%s_%d" % (target, 0))
|
||||
logging.getLogger(LOGGER).info("impulse:%s" % str(impulse))
|
||||
if impulse:
|
||||
print("spykhanat.py:429", type(impulse))
|
||||
logging.getLogger(LOGGER).debug("type impulse:%s" % str(type(impulse)))
|
||||
impulses.append(impulse)
|
||||
except Impulse.ImpulseNoElement:
|
||||
pass
|
||||
|
@ -608,7 +607,7 @@ class SpyPcap():
|
|||
Name = "%s_%d" % (target, 0)
|
||||
) #, Reference = Parent, Name = "%s_%d" % (target, 0))
|
||||
if impulse:
|
||||
print("spykhanat.py:429", type(impulse))
|
||||
logging.getLogger(LOGGER).debug("type impulse:%s" % str(type(impulse)))
|
||||
impulses.append(impulse)
|
||||
except Impulse.ImpulseNoElement:
|
||||
pass
|
||||
|
@ -940,20 +939,20 @@ def main():
|
|||
logging.basicConfig(format=FORMAT)
|
||||
|
||||
logger = []
|
||||
logger.append(logging.getLogger(LOGGER))
|
||||
#logger.append(logging.getLogger(LOGGER))
|
||||
# logger.append(logging.getLogger(CImpulseDecoder.LOGGER))
|
||||
# #logger.append(logging.getLogger(DecodeImpuls.LOGGER))
|
||||
# #logger.append(logging.getLogger(BitStream.LOGGER))
|
||||
# logger.append(logging.getLogger(CStringManager.LOGGER))
|
||||
#logger.append(logging.getLogger(CAction.LOGGER))
|
||||
#logger.append(logging.getLogger(CActionFactory.LOGGER))
|
||||
logger.append(logging.getLogger(BitStream.LOGGER))
|
||||
#logger.append(logging.getLogger(BitStream.LOGGER))
|
||||
#logger.append(logging.getLogger(DecodeDatabase.LOGGER))
|
||||
#logger.append(logging.getLogger(Impulse.LOGGER))
|
||||
logger.append(logging.getLogger(Impulse.LOGGER))
|
||||
#logger.append(logging.getLogger(TVPNodeBase.LOGGER))
|
||||
# CImpulseDecoder
|
||||
# logger.append(logging.getLogger('CGenericMultiPartTemp'))
|
||||
logger.append(logging.getLogger(DecodeDatabase.LOGGER))
|
||||
#logger.append(logging.getLogger(DecodeDatabase.LOGGER))
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--khanat-host-service", help="filter to detect khanat host:service (FES)")
|
||||
|
|
|
@ -28,13 +28,13 @@ def show_dico(dico, level=1):
|
|||
try:
|
||||
for ele in dico:
|
||||
if isinstance(dico[ele], dict):
|
||||
print("." * level, ele , ":")
|
||||
logging.getLogger(LOGGER).debug("%s %s %s" % ("." * level, ele , ":"))
|
||||
if isinstance(dico[ele], dict):
|
||||
show_dico(dico[ele], level+1)
|
||||
else:
|
||||
print("." * level, ele, ':', dico[ele])
|
||||
logging.getLogger(LOGGER).debug("%s %s %s" % ("." * level, ele, ':', dico[ele]))
|
||||
except:
|
||||
print("empty")
|
||||
logging.getLogger(LOGGER).debug("empty")
|
||||
|
||||
def child(ele):
|
||||
ret = {}
|
||||
|
@ -46,7 +46,7 @@ def child(ele):
|
|||
max_i = -1
|
||||
for k in ele.keys():
|
||||
ret[k] = ele.get(k)
|
||||
print(k, ele.get(k))
|
||||
logging.getLogger(LOGGER).debug("%s %s" % (str(k), str(ele.get(k))))
|
||||
for _child in list(ele):
|
||||
x = child(_child)
|
||||
if x['name'] == 'branch':
|
||||
|
@ -81,16 +81,14 @@ def child(ele):
|
|||
return ret
|
||||
|
||||
def count_elements(head):
|
||||
print("%" * 80)
|
||||
#print(head)
|
||||
if 'child' in head.keys():
|
||||
list_ele = [x for x in list(head['child'].keys()) if isinstance(x, int)]
|
||||
else:
|
||||
list_ele = [x for x in list(head.keys()) if isinstance(x, int)]
|
||||
print(list_ele)
|
||||
logging.getLogger(LOGGER).debug(str(list_ele))
|
||||
last_key = max(list_ele)
|
||||
print(last_key )
|
||||
print("%" * 80)
|
||||
logging.getLogger(LOGGER).debug(str(last_key ))
|
||||
try:
|
||||
last_key = max(list_ele)
|
||||
if 'child' in head.keys():
|
||||
|
@ -101,12 +99,12 @@ def count_elements(head):
|
|||
return 0
|
||||
|
||||
def get_element(head, id):
|
||||
print("id:", id)
|
||||
logging.getLogger(LOGGER).debug("id: %s" % str(id))
|
||||
for ele in head['child']:
|
||||
print("ele:", ele)
|
||||
print("head:", head)
|
||||
print("max:", head['child'][ele]['max'])
|
||||
print("min:", head['child'][ele]['min'])
|
||||
logging.getLogger(LOGGER).debug("ele:%s" % str(ele))
|
||||
logging.getLogger(LOGGER).debug("head:%s" % str(head))
|
||||
logging.getLogger(LOGGER).debug("max:%s", str(head['child'][ele]['max']))
|
||||
logging.getLogger(LOGGER).debug("min:%s", str(head['child'][ele]['min']))
|
||||
if id <= head['child'][ele]['max'] and id >= head['child'][ele]['min']:
|
||||
return head['child'][ele]
|
||||
return None
|
||||
|
@ -131,7 +129,7 @@ class LeafDatabase():
|
|||
return 1
|
||||
|
||||
def show(self, level=1):
|
||||
print(" " * level, level, " Leaf ", self.name, ":", self.count, ":", self.type)
|
||||
logging.getLogger(LOGGER).debug("%s %s Leaf %s : %s : %s" % (" " * level, str(level), self.name, str(self.count), str(self.type)))
|
||||
|
||||
def execute(self, msgin, name=""):
|
||||
if name:
|
||||
|
@ -273,7 +271,7 @@ class BranchDatabase():
|
|||
return level
|
||||
|
||||
def show(self, level=0, pos=0, filterlevel=None):
|
||||
print(" " * level, level, "pos:", pos, " Branch ", self.name, ":", self.count, ":", self.atom, self.getIdBits())
|
||||
logging.getLogger(LOGGER).debug( "%s %s pos:%s Branch:%s : %s : %s - %s" % (" " * level, str(level), str(pos), str(self.name), str(self.count), str(self.atom), str(self.getIdBits())))
|
||||
if filterlevel is not None:
|
||||
if filterlevel <= level:
|
||||
return
|
||||
|
@ -396,12 +394,9 @@ class DecodeDatabase():
|
|||
|
||||
def loadDatabase2(self, databaseXml):
|
||||
logging.getLogger(LOGGER).debug("loadDatabase")
|
||||
print("-"*80)
|
||||
base = BranchDatabase()
|
||||
print("-"*80)
|
||||
#base.loadXml(databaseXml, 'PLR')
|
||||
base.loadRootXml(databaseXml, 'PLR')
|
||||
print("-"*80)
|
||||
base.show(filterlevel=2)
|
||||
base.show()
|
||||
tmp = BitStream.BitStream()
|
||||
|
@ -409,8 +404,7 @@ class DecodeDatabase():
|
|||
tmp.internalSerial(0,1)
|
||||
tmp.internalSerial(13237038,32)
|
||||
base.execute_root(tmp)
|
||||
print(tmp.showAllData())
|
||||
print("-"*80)
|
||||
logging.getLogger(LOGGER).debug(tmp.showAllData())
|
||||
tmp = BitStream.BitStream()
|
||||
tmp.internalSerial(21, 5)
|
||||
tmp.internalSerial(8,5)
|
||||
|
@ -441,7 +435,7 @@ class DecodeDatabase():
|
|||
tmp.internalSerial(0,8)
|
||||
tmp.internalSerial(1,2)
|
||||
base.execute_root(tmp)
|
||||
print(tmp.showAllData())
|
||||
logging.getLogger(LOGGER).debug(tmp.showAllData())
|
||||
|
||||
raise "Stop"
|
||||
self.databaseXml = databaseXml
|
||||
|
@ -458,15 +452,12 @@ class DecodeDatabase():
|
|||
self.databasePlr['child'][id]['min'] = id
|
||||
self.databasePlr['child'][id]['max'] = id
|
||||
id += 1
|
||||
print(dir(ele))
|
||||
#print(dir(ele))
|
||||
nb = len(self.databasePlr) - 1
|
||||
self.databasePlr['min'] = 0
|
||||
self.databasePlr['max'] = nb
|
||||
print("-" * 80)
|
||||
show_dico(self.databasePlr)
|
||||
print("-" * 80)
|
||||
print("max", self.databasePlr['max'] )
|
||||
print("-" * 80)
|
||||
logging.getLogger(LOGGER).debug("max %d" % str(self.databasePlr['max']))
|
||||
#raise "Decode"
|
||||
|
||||
def execute2(self, msgin, world):
|
||||
|
@ -474,20 +465,17 @@ class DecodeDatabase():
|
|||
head = self.databasePlr
|
||||
listpath = []
|
||||
|
||||
print("="*80)
|
||||
print(head)
|
||||
print("="*80)
|
||||
logging.getLogger(LOGGER).debug(str(head))
|
||||
while True:
|
||||
print("---")
|
||||
logging.getLogger(LOGGER).debug("count_elements:" + str(count_elements(head)))
|
||||
nbchild = count_elements(head)
|
||||
print("count_elements(head):", nbchild)
|
||||
logging.getLogger(LOGGER).debug("count_elements(head):", nbchild)
|
||||
if nbchild == 0:
|
||||
print("Ahhhh", "+"*80)
|
||||
logging.getLogger(LOGGER).debug("Ahhhh", "+"*80)
|
||||
return True
|
||||
print("nbchild:", nbchild)
|
||||
logging.getLogger(LOGGER).debug("nbchild:", nbchild)
|
||||
nbBit = getPowerOf2.getPowerOf2_Bis(nbchild)
|
||||
print("nbBit:", nbBit)
|
||||
logging.getLogger(LOGGER).debug("nbBit:", nbBit)
|
||||
# res=1;
|
||||
# ret=0;
|
||||
# print("ret:", ret, "res:", res)
|
||||
|
@ -498,35 +486,35 @@ class DecodeDatabase():
|
|||
# print("ret:", ret)
|
||||
logging.getLogger(LOGGER).debug("nbBit:" + str(nbBit))
|
||||
id = msgin.readSerial(nbBit, name='DatabaseXML', typeName='Number:'+str(nbBit), emulate=True)
|
||||
print("id:", id)
|
||||
logging.getLogger(LOGGER).debug("id:", id)
|
||||
logging.getLogger(LOGGER).debug("XML DECODE : %3d -> %s" % (nbBit, ':'.join(listpath)) )
|
||||
|
||||
print("Ahhhh a", "-"*80)
|
||||
logging.getLogger(LOGGER).debug("Ahhhh a", "-"*80)
|
||||
show_dico(head)
|
||||
ele = get_element(head, int(id))
|
||||
print(ele)
|
||||
logging.getLogger(LOGGER).debug(str(ele))
|
||||
show_dico(ele)
|
||||
print(msgin.showAllData())
|
||||
logging.getLogger(LOGGER).debug(msgin.showAllData())
|
||||
name = ele['name']
|
||||
id = msgin.readSerial(nbBit, name='DatabaseXML', typeName='Number:'+str(nbBit), commentValue=name)
|
||||
listpath.append(name)
|
||||
fullname = ':'.join(listpath)
|
||||
print("fullname:", fullname)
|
||||
logging.getLogger(LOGGER).debug("fullname:", fullname)
|
||||
logging.getLogger(LOGGER).debug(fullname)
|
||||
if 'count' in ele:
|
||||
nbBit = getPowerOf2.getPowerOf2_Bis(int(ele['count']))
|
||||
count = msgin.readSerial(nbBit, name='DatabaseXML', typeName='count:'+str(ele['count']+':'+str(nbBit)))
|
||||
listpath.append(str(count))
|
||||
if 'type' in ele:
|
||||
print("Ahhhh 2", "+"*80)
|
||||
print(ele['type'])
|
||||
logging.getLogger(LOGGER).debug("Ahhhh 2", "+"*80)
|
||||
logging.getLogger(LOGGER).debug(str(ele['type']))
|
||||
if ele['type'] == 'I32':
|
||||
_ = msgin.readSerial(32, name='DatabaseXML', typeName=ele['type'])
|
||||
else:
|
||||
pass
|
||||
print(msgin.showAllData())
|
||||
logging.getLogger(LOGGER).debug(msgin.showAllData())
|
||||
return True
|
||||
head = ele
|
||||
print("Ahhhh 3", "-"*80)
|
||||
logging.getLogger(LOGGER).debug("Ahhhh 3", "-"*80)
|
||||
return False
|
||||
|
||||
|
|
|
@ -24,9 +24,9 @@ from enum import IntEnum
|
|||
def GetNameIntEnum(typeEnum, value):
|
||||
for key in typeEnum.__dict__:
|
||||
try:
|
||||
print("-"*80)
|
||||
print(key, dir(typeEnum.__dict__[key]))
|
||||
print(key, typeEnum.__dict__[key].value)
|
||||
#print("-"*80)
|
||||
#print(key, dir(typeEnum.__dict__[key]))
|
||||
#print(key, typeEnum.__dict__[key].value)
|
||||
if typeEnum.__dict__[key].value == value:
|
||||
return key
|
||||
except:
|
||||
|
|
|
@ -660,8 +660,16 @@ class impulseDatabaseInitPlayer(ImpulseBase):
|
|||
self.name = name.replace(':', '_')
|
||||
self.readUint32(msgin, '%s_serverTick' % id)
|
||||
propertyCount = self.readUint16(msgin, '%s_propertyCount' % id)
|
||||
for i in range(0, propertyCount):
|
||||
_ = self.readUint32(msgin, '%s_property' % id)
|
||||
# for i in range(0, propertyCount):
|
||||
# _ = self.readUint32(msgin, '%s_property' % id)
|
||||
for i in range(0, propertyCount):
|
||||
logging.getLogger(LOGGER).debug("read i:%d" % i)
|
||||
databaseXml.execute(msgin, world)
|
||||
#raise "TODO"
|
||||
if msgin.needRead() > 5:
|
||||
logging.getLogger(LOGGER).debug(msgin.showAllData())
|
||||
logging.getLogger(LOGGER).debug(msgin.showAllData())
|
||||
raise "TODO"
|
||||
|
||||
|
||||
class ImpulseConnectionDeleteChar(ImpulseBase):
|
||||
|
@ -669,8 +677,6 @@ class ImpulseConnectionDeleteChar(ImpulseBase):
|
|||
super().__init__()
|
||||
|
||||
def read(self, name, msgin, world, databaseXml):
|
||||
# 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(':', '_')
|
||||
|
@ -757,7 +763,7 @@ class impulseDatabaseUpdatePlayer(ImpulseBase):
|
|||
databaseXml.execute(msgin, world)
|
||||
#raise "TODO"
|
||||
if msgin.needRead() > 5:
|
||||
print(msgin.showAllData())
|
||||
logging.getLogger(LOGGER).debug(msgin.showAllData())
|
||||
#raise "TODO"
|
||||
#raise "TODO"
|
||||
|
||||
|
|
Loading…
Reference in a new issue