mirror of
https://port.numenaute.org/aleajactaest/clientbot.git
synced 2024-11-28 10:18:16 +00:00
fix some issue
This commit is contained in:
parent
3121a918bb
commit
b21cf254cc
4 changed files with 19 additions and 4 deletions
19
spykhanat.py
19
spykhanat.py
|
@ -42,6 +42,7 @@ from tools import CImpulseDecoder
|
|||
from tools import CStringManager
|
||||
from tools import CAction
|
||||
import xml.etree.ElementTree as ET
|
||||
from datetime import datetime
|
||||
|
||||
LOGGER = 'SpyKhanat'
|
||||
|
||||
|
@ -86,7 +87,7 @@ class SpyPcap():
|
|||
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" % pkt.timestamp)
|
||||
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())
|
||||
logging.getLogger(LOGGER).debug("eth_frame: %s" % eth_frame)
|
||||
if eth_frame.type == 2048:
|
||||
|
@ -151,6 +152,7 @@ class SpyPcap():
|
|||
self.client_state.setdefault(clientid, {'CurrentReceivedNumber': 0,
|
||||
'CurrentSendNumber': 0,
|
||||
'LastReceivedAck': 0,
|
||||
'AckBitMask': 0,
|
||||
'RegisteredAction': {},
|
||||
'world': World.World(),
|
||||
'GenericMultiPartTemp': CGenericMultiPartTemp.GenericMultiPartTemp(),
|
||||
|
@ -219,8 +221,13 @@ class SpyPcap():
|
|||
self.initialize_client(clientid)
|
||||
self.client_state[clientid]['CurrentReceivedNumber'] = CurrentReceivedNumber
|
||||
if not SystemMode:
|
||||
'''
|
||||
khanat-opennel-code/code/ryzom/client/src/network_connection.cpp:2029 void CNetworkConnection::sendNormalMessage()
|
||||
'''
|
||||
LastReceivedAck = msgin.readSint32('LastReceivedAck')
|
||||
self.client_state[clientid]['LastReceivedAck'] = LastReceivedAck
|
||||
AckBitMask = msgin.readUint32('AckBitMask')
|
||||
self.client_state[clientid]['AckBitMask'] = AckBitMask
|
||||
logging.getLogger(LOGGER).info("[Client -> Khanat] Normal Mode {CurrentReceivedNumber:%d, src:%s, dst:%s, LastReceivedAck:%d}" % (CurrentReceivedNumber, clientid, dst, LastReceivedAck))
|
||||
#self.decode_server(msgin, _CurrentReceivedNumber, _CurrentReceivedNumber-1)
|
||||
self.decode_client_receive_normal_message(msgin, clientid, dst)
|
||||
|
@ -350,7 +357,8 @@ class SpyPcap():
|
|||
if not self.filter_host_service or self.filter_host_service.match("%s:%d" % (ip_packet.src.decode(), udp_packet.src_port)) or self.filter_host_service.match("%s:%d" % (ip_packet.dst.decode(), udp_packet.dst_port)):
|
||||
logging.getLogger(LOGGER).debug("-" * 80)
|
||||
if self.show_raw_packet:
|
||||
logging.getLogger(LOGGER).debug("[raw packet] timestamp:%s src:%s:%d dst:%s:%d data:%s" % (pkt.timestamp,
|
||||
logging.getLogger(LOGGER).debug("[raw packet] timestamp:%s [%s] src:%s:%d dst:%s:%d data:%s" % (pkt.timestamp,
|
||||
datetime.fromtimestamp(pkt.timestamp).strftime("%Y/%m/%d %H:%M:%S"),
|
||||
ip_packet.src.decode(), udp_packet.src_port,
|
||||
ip_packet.dst.decode(), udp_packet.dst_port,
|
||||
data.decode()))
|
||||
|
@ -358,12 +366,17 @@ class SpyPcap():
|
|||
msgin.fromBytes(binascii.unhexlify(data))
|
||||
src = "%s:%d" % (ip_packet.src.decode(), udp_packet.src_port)
|
||||
dst = "%s:%d" % (ip_packet.dst.decode(), udp_packet.dst_port)
|
||||
|
||||
if (self.khanat_host_service and self.khanat_host_service.match(src)) or ( not self.khanat_host_service and khanat_host == src):
|
||||
_provenance = 'Khanat -> Client'
|
||||
logging.getLogger(LOGGER).debug("[%s] (message received) [%s] %s" % (_provenance, datetime.fromtimestamp(pkt.timestamp).strftime("%Y/%m/%d %H:%M:%S"), msgin.showAllData()))
|
||||
self.decode_khanat_message(msgin, src, dst)
|
||||
else:
|
||||
_provenance = 'Client -> Khanat'
|
||||
logging.getLogger(LOGGER).debug("[%s] (message received) [%s] %s" % (_provenance, datetime.fromtimestamp(pkt.timestamp).strftime("%Y/%m/%d %H:%M:%S"), msgin.showAllData()))
|
||||
self.decode_client_message(msgin, src, dst)
|
||||
if self.show_message_decoded:
|
||||
logging.getLogger(LOGGER).debug("[message decoded] %s" % msgin.showAllData())
|
||||
logging.getLogger(LOGGER).debug("[%s] %s" % (_provenance, msgin.showAllData()))
|
||||
for client in self.client_state:
|
||||
logging.getLogger(LOGGER).debug("%s [server tick:%d, client tick:%d]" %(client, self.client_state[client]['CurrentSendNumber'], self.client_state[client]['CurrentReceivedNumber']))
|
||||
|
||||
|
|
|
@ -101,6 +101,7 @@ class CActionFactory:
|
|||
code = msgin.readSerial(2, 'code')
|
||||
else:
|
||||
code = msgin.readUint8('code')
|
||||
logging.getLogger(LOGGER).debug("[decoded] %s" % msgin.showAllData())
|
||||
action = self.create(CAction.INVALID_SLOT, code)
|
||||
if action:
|
||||
try:
|
||||
|
|
|
@ -61,6 +61,7 @@ class CImpulseDecoder:
|
|||
# lastAck = lAck[channel]
|
||||
while True:
|
||||
logging.getLogger(LOGGER).debug("*" * 40)
|
||||
logging.getLogger(LOGGER).debug("[decoded] %s" % msgin.showAllData())
|
||||
next = msgin.readBool('next:' + str(level) + ':' + str(channel))
|
||||
if not next:
|
||||
break
|
||||
|
|
|
@ -149,5 +149,5 @@ class CStringManager:
|
|||
self.decoded.append(ret)
|
||||
else:
|
||||
logging.getLogger(LOGGER).debug('Impossible to decode id:%d' % key)
|
||||
newUnknown.append((key, data))
|
||||
newUnknown.append((key, dataRead))
|
||||
self.unknown = newUnknown
|
||||
|
|
Loading…
Reference in a new issue