mirror of
https://port.numenaute.org/aleajactaest/clientbot.git
synced 2024-11-21 22:56:13 +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 CStringManager
|
||||||
from tools import CAction
|
from tools import CAction
|
||||||
import xml.etree.ElementTree as ET
|
import xml.etree.ElementTree as ET
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
LOGGER = 'SpyKhanat'
|
LOGGER = 'SpyKhanat'
|
||||||
|
|
||||||
|
@ -86,7 +87,7 @@ class SpyPcap():
|
||||||
print("pkt.header:", dir(pkt.header))
|
print("pkt.header:", dir(pkt.header))
|
||||||
print("pkt.packet:", dir(pkt.packet))
|
print("pkt.packet:", dir(pkt.packet))
|
||||||
logging.getLogger(LOGGER).debug("raw: %s" % pkt.raw())
|
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())
|
eth_frame = ethernet.Ethernet(pkt.raw())
|
||||||
logging.getLogger(LOGGER).debug("eth_frame: %s" % eth_frame)
|
logging.getLogger(LOGGER).debug("eth_frame: %s" % eth_frame)
|
||||||
if eth_frame.type == 2048:
|
if eth_frame.type == 2048:
|
||||||
|
@ -151,6 +152,7 @@ class SpyPcap():
|
||||||
self.client_state.setdefault(clientid, {'CurrentReceivedNumber': 0,
|
self.client_state.setdefault(clientid, {'CurrentReceivedNumber': 0,
|
||||||
'CurrentSendNumber': 0,
|
'CurrentSendNumber': 0,
|
||||||
'LastReceivedAck': 0,
|
'LastReceivedAck': 0,
|
||||||
|
'AckBitMask': 0,
|
||||||
'RegisteredAction': {},
|
'RegisteredAction': {},
|
||||||
'world': World.World(),
|
'world': World.World(),
|
||||||
'GenericMultiPartTemp': CGenericMultiPartTemp.GenericMultiPartTemp(),
|
'GenericMultiPartTemp': CGenericMultiPartTemp.GenericMultiPartTemp(),
|
||||||
|
@ -219,8 +221,13 @@ class SpyPcap():
|
||||||
self.initialize_client(clientid)
|
self.initialize_client(clientid)
|
||||||
self.client_state[clientid]['CurrentReceivedNumber'] = CurrentReceivedNumber
|
self.client_state[clientid]['CurrentReceivedNumber'] = CurrentReceivedNumber
|
||||||
if not SystemMode:
|
if not SystemMode:
|
||||||
|
'''
|
||||||
|
khanat-opennel-code/code/ryzom/client/src/network_connection.cpp:2029 void CNetworkConnection::sendNormalMessage()
|
||||||
|
'''
|
||||||
LastReceivedAck = msgin.readSint32('LastReceivedAck')
|
LastReceivedAck = msgin.readSint32('LastReceivedAck')
|
||||||
self.client_state[clientid]['LastReceivedAck'] = 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))
|
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_server(msgin, _CurrentReceivedNumber, _CurrentReceivedNumber-1)
|
||||||
self.decode_client_receive_normal_message(msgin, clientid, dst)
|
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)):
|
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)
|
logging.getLogger(LOGGER).debug("-" * 80)
|
||||||
if self.show_raw_packet:
|
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.src.decode(), udp_packet.src_port,
|
||||||
ip_packet.dst.decode(), udp_packet.dst_port,
|
ip_packet.dst.decode(), udp_packet.dst_port,
|
||||||
data.decode()))
|
data.decode()))
|
||||||
|
@ -358,12 +366,17 @@ class SpyPcap():
|
||||||
msgin.fromBytes(binascii.unhexlify(data))
|
msgin.fromBytes(binascii.unhexlify(data))
|
||||||
src = "%s:%d" % (ip_packet.src.decode(), udp_packet.src_port)
|
src = "%s:%d" % (ip_packet.src.decode(), udp_packet.src_port)
|
||||||
dst = "%s:%d" % (ip_packet.dst.decode(), udp_packet.dst_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):
|
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)
|
self.decode_khanat_message(msgin, src, dst)
|
||||||
else:
|
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)
|
self.decode_client_message(msgin, src, dst)
|
||||||
if self.show_message_decoded:
|
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:
|
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']))
|
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')
|
code = msgin.readSerial(2, 'code')
|
||||||
else:
|
else:
|
||||||
code = msgin.readUint8('code')
|
code = msgin.readUint8('code')
|
||||||
|
logging.getLogger(LOGGER).debug("[decoded] %s" % msgin.showAllData())
|
||||||
action = self.create(CAction.INVALID_SLOT, code)
|
action = self.create(CAction.INVALID_SLOT, code)
|
||||||
if action:
|
if action:
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -61,6 +61,7 @@ class CImpulseDecoder:
|
||||||
# lastAck = lAck[channel]
|
# lastAck = lAck[channel]
|
||||||
while True:
|
while True:
|
||||||
logging.getLogger(LOGGER).debug("*" * 40)
|
logging.getLogger(LOGGER).debug("*" * 40)
|
||||||
|
logging.getLogger(LOGGER).debug("[decoded] %s" % msgin.showAllData())
|
||||||
next = msgin.readBool('next:' + str(level) + ':' + str(channel))
|
next = msgin.readBool('next:' + str(level) + ':' + str(channel))
|
||||||
if not next:
|
if not next:
|
||||||
break
|
break
|
||||||
|
|
|
@ -149,5 +149,5 @@ class CStringManager:
|
||||||
self.decoded.append(ret)
|
self.decoded.append(ret)
|
||||||
else:
|
else:
|
||||||
logging.getLogger(LOGGER).debug('Impossible to decode id:%d' % key)
|
logging.getLogger(LOGGER).debug('Impossible to decode id:%d' % key)
|
||||||
newUnknown.append((key, data))
|
newUnknown.append((key, dataRead))
|
||||||
self.unknown = newUnknown
|
self.unknown = newUnknown
|
||||||
|
|
Loading…
Reference in a new issue