mirror of
https://port.numenaute.org/aleajactaest/clientbot.git
synced 2024-12-19 16:08:46 +00:00
adding check file msg.xml & database.xml (compare server and client)
This commit is contained in:
parent
1611385267
commit
3478c16243
1 changed files with 34 additions and 11 deletions
45
client.py
45
client.py
|
@ -41,6 +41,7 @@ import lzma
|
||||||
import socket
|
import socket
|
||||||
import struct
|
import struct
|
||||||
import xml.etree.ElementTree as ET
|
import xml.etree.ElementTree as ET
|
||||||
|
import hashlib
|
||||||
|
|
||||||
|
|
||||||
class BitStream():
|
class BitStream():
|
||||||
|
@ -144,10 +145,10 @@ class BitStream():
|
||||||
self.pushChar(x)
|
self.pushChar(x)
|
||||||
#y = ord(x)
|
#y = ord(x)
|
||||||
#self.internalSerial(y, 8)
|
#self.internalSerial(y, 8)
|
||||||
def pushArrayChar(self, valeur, size):
|
def pushArrayUint8(self, valeur, size):
|
||||||
' ex.: pushArrayChar([0,1,3,4]) '
|
' ex.: pushArrayChar([0,1,3,4]) '
|
||||||
for i in valeur:
|
for i in valeur:
|
||||||
self.pushChar(i)
|
self.pushUint8(i)
|
||||||
|
|
||||||
# ------------------------------------
|
# ------------------------------------
|
||||||
def readSerial(self, nbits):
|
def readSerial(self, nbits):
|
||||||
|
@ -240,10 +241,10 @@ class BitStream():
|
||||||
tmp += x
|
tmp += x
|
||||||
_size -= 1
|
_size -= 1
|
||||||
return tmp
|
return tmp
|
||||||
def readArrayChar(self, size):
|
def readArrayUint8(self, size):
|
||||||
ret = []
|
ret = []
|
||||||
for i in range(0, size):
|
for i in range(0, size):
|
||||||
ret.append(self.readChar())
|
ret.append(self.readUint8())
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
# ------------------------------------
|
# ------------------------------------
|
||||||
|
@ -277,8 +278,18 @@ class BitStream():
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def getTextMD5(dataRawXml):
|
def getTextMD5(dataRawXml):
|
||||||
|
log = logging.getLogger('myLogger')
|
||||||
|
dataNew = ''
|
||||||
for data in dataRawXml:
|
for data in dataRawXml:
|
||||||
pass
|
if data != '\r': # '\015' ignore caractère \r\n =>
|
||||||
|
dataNew += data
|
||||||
|
else:
|
||||||
|
log.debug("***** data:%d" % (ord(data)))
|
||||||
|
m = hashlib.md5()
|
||||||
|
m.update(dataNew.encode('utf-8'))
|
||||||
|
#print(m.hexdigest())
|
||||||
|
#print(m.digest())
|
||||||
|
return m.digest()
|
||||||
|
|
||||||
def Test():
|
def Test():
|
||||||
a = BitStream()
|
a = BitStream()
|
||||||
|
@ -1488,6 +1499,8 @@ class ClientNetworkConnection:
|
||||||
self._LastAckInLongAck = 0
|
self._LastAckInLongAck = 0
|
||||||
self._MsgXmlMD5 = None
|
self._MsgXmlMD5 = None
|
||||||
self._DatabaseXmlMD5 = None
|
self._DatabaseXmlMD5 = None
|
||||||
|
self.msgXml = None
|
||||||
|
self.databaseXml = None
|
||||||
|
|
||||||
def cookiesInit(self, UserAddr, UserKey, UserId):
|
def cookiesInit(self, UserAddr, UserKey, UserId):
|
||||||
self.UserAddr = UserAddr
|
self.UserAddr = UserAddr
|
||||||
|
@ -1581,10 +1594,20 @@ class ClientNetworkConnection:
|
||||||
_LatestSync = msg.readUint32()
|
_LatestSync = msg.readUint32()
|
||||||
self.log.debug("%d %d %d" %(_Synchronize, stime, _LatestSync))
|
self.log.debug("%d %d %d" %(_Synchronize, stime, _LatestSync))
|
||||||
# khanat-opennel-code/code/ryzom/client/src/network_connection.cpp : void CNetworkConnection::receiveSystemSync(CBitMemStream &msgin)
|
# khanat-opennel-code/code/ryzom/client/src/network_connection.cpp : void CNetworkConnection::receiveSystemSync(CBitMemStream &msgin)
|
||||||
MsgData = msg.readArrayChar(16)
|
MsgData = msg.readArrayUint8(16)
|
||||||
DatabaseData = msg.readArrayChar(16)
|
DatabaseData = msg.readArrayUint8(16)
|
||||||
self.log.debug("MsgData:" + str(MsgData))
|
self.log.debug("MsgData:" + str(MsgData))
|
||||||
self.log.debug("DatabaseData:" + str(DatabaseData))
|
self.log.debug("DatabaseData:" + str(DatabaseData))
|
||||||
|
md5Msg = bytes(MsgData)
|
||||||
|
md5Database = bytes(DatabaseData)
|
||||||
|
if md5Msg == self._MsgXmlMD5:
|
||||||
|
self.log.info("Check MD5 msg.xml : OK")
|
||||||
|
else:
|
||||||
|
self.log.error("Check MD5 msg.xml : KO")
|
||||||
|
if md5Database == self._DatabaseXmlMD5:
|
||||||
|
self.log.info("Check MD5 database.xml : OK")
|
||||||
|
else:
|
||||||
|
self.log.error("Check MD5 database.xml : KO")
|
||||||
self.log.error("TODO")
|
self.log.error("TODO")
|
||||||
#self.sendSystemAckSync()
|
#self.sendSystemAckSync()
|
||||||
|
|
||||||
|
@ -1592,10 +1615,10 @@ class ClientNetworkConnection:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def EmulateFirst(self, msgRawXml, databaseRawXml):
|
def EmulateFirst(self, msgRawXml, databaseRawXml):
|
||||||
msgXml = ET.fromstring(msgRawXml)
|
self.msgXml = ET.fromstring(msgRawXml)
|
||||||
ET.dump(msgXml)
|
#ET.dump(msgXml)
|
||||||
databaseXml = ET.fromstring(databaseRawXml)
|
self.databaseXml = ET.fromstring(databaseRawXml)
|
||||||
ET.dump(databaseXml)
|
#ET.dump(databaseXml)
|
||||||
|
|
||||||
self._MsgXmlMD5 = getTextMD5(msgRawXml)
|
self._MsgXmlMD5 = getTextMD5(msgRawXml)
|
||||||
self._DatabaseXmlMD5 = getTextMD5(databaseRawXml)
|
self._DatabaseXmlMD5 = getTextMD5(databaseRawXml)
|
||||||
|
|
Loading…
Reference in a new issue