2021年4月30日星期五

Reproduce checksum value for xmpp chat (int64)

Must generate/reproduce the Cs="" value to make a chat response to xmpp message. When value is incorrect or undefined, the client does not respond to the socket at all...

<ChatMsg Type="0" Uid="232079" Time="3937343468213379621" Cs="3937343535798810786"><From>UCHMIX</From><Msg>?</Msg></ChatMsg>  

Already understanding the Time="" value with help from stackoverflow:

Strange 64-bit time format from game, you can recognize it?

This question is a follow-up to that post.

I have this data from a server log:

<ChatMsg Type="0" Uid="151284" Time="5938757010598142773" Cs="5936325094958675083"><From>SMOKYGR</From><Msg>yo*</Msg></ChatMsg>  <ChatMsg Type="0" Uid="151284" Time="5938757012199602917" Cs="5938830641865198129"><From>SMOKYGR</From><Msg>YO</Msg></ChatMsg>  <ChatMsg Type="0" Uid="232224" Time="-7381889552328776379" Cs="-7383961889558969266"><From>SONGA</From><Msg>hello</Msg></ChatMsg>  <ChatMsg Type="0" Uid="232287" Time="-1066190397422500459" Cs="-3285877151149829651"><From>WEEX</From><Msg>why i can&apos;t use powerups ?</Msg></ChatMsg>  <ChatMsg Type="4" Uid="232262" Time="746328277856917749" Cs="6127972727948084209"><From>NEXAAR</From><Msg>ChatInviteToGroup,2610828.216425,NEXAAR,</Msg></ChatMsg>  <ChatMsg Type="5" Uid="226302" Time="746328278429519557" Cs="7807236613904539910"><From>LECHUU</From><Msg>PrivateMatchDeclined,0</Msg></ChatMsg>  <ChatMsg Type="5" Uid="232262" Time="746328277329616229" Cs="8131104557811575921"><From>NEXAAR</From><Msg>ChatHandshakeComplete</Msg></ChatMsg>  <ChatMsg Type="5" Uid="232306" Time="746328280247821893" Cs="8098106226351528940"><From>XJELIMANX</From><Msg>ChatAcceptInvite</Msg></ChatMsg>  <ChatMsg Type="0" Uid="232079" Time="3937343468213379621" Cs="3937343535798810786"><From>UCHMIX</From><Msg>?</Msg></ChatMsg>  

Notice when MSG is very short, the beginning of Time and Cs values are identical, so the two values are probably related in some way. Uid="" means userid and probably irrelevant for calculation of the checksum...

In hex the same values look like this:

Time: 526ab409 48102335, Cs: 52621038 cc3fb48b, Msg: 'yo*'  Time: 526ab409 a7847ae5, Cs: 526af700 e5948a31, Msg: 'YO'  Time: 998e4290 2646a545, Cs: 9986e5c8 89d0c44e, Msg: 'hello'  Time: f134217b 82b30595, Cs: d2663823 ee2451ed, Msg: 'why i can&apos;t use powerups ?'  Time: 0a5b7d9d 4f7d98f5, Cs: 550aeeba 8aa083f1, Msg: 'ChatInviteToGroup,2610828.216425,NEXAAR,'  Time: 0a5b7d9d 719ecec5, Cs: 6c58e055 f9342106, Msg: 'PrivateMatchDeclined,0'  Time: 0a5b7d9d 300f9d65, Cs: 70d77c83 cfeb2c71, Msg: 'ChatHandshakeComplete'  Time: 0a5b7d9d ddffe645, Cs: 706240b5 0f0fdbec, Msg: 'ChatAcceptInvite'  Time: 36a44105 fd902225, Cs: 36a44115 b9f7f8a2, Msg: '?'  

Have tried using a hash routine like this one below, and summing the result with the time value.

func calculatehash(buf:str):int64;  begin   multiplier:int64=4294967295; //ffffffff   flg:bool=yes;   for i:int32=1 to len(buf) do begin    c:char=mid(buf,i,1);    hash:int64=multiplier*33;    p:pointer=@hash;    hihash:int64=uint32(p+4)^;    lohash:int64=uint32(p)^;    himul:int64=hihash+uint8(flg));    lomul:int64=(lohash shl 32) shr 32+uint8(c);    flg:=hihash>himul;    q:pointer=@multiplier;    uint32(q+4)^:=himul;    uint32(q)^:=lomul;   end;   result:=multiplier;  end;  

I was not able to reproduce the same values as seen in the log from server.

Any suggestions/thoughs welcomed, Thanks in advance //mbs

https://stackoverflow.com/questions/67323145/reproduce-checksum-value-for-xmpp-chat-int64 April 30, 2021 at 02:27AM

没有评论:

发表评论