01-28-2019, 12:18 AM
делаю пакет AutchRequest
вот encrypt
получается я шифрую AuthRequest со 2 позиции.. после отправки на сервер какая то тарабарщина
логин постоянно один и тот же
Код:
int startlen = UserName.Length * 2 + 2;
byte[] AuthRequest = new byte[startlen + 33];
AuthRequest[0] = 0x2B;//???? это размер... не знаю правильно или нет
AuthRequest[1] = 0x00;
AuthRequest[2] = 0x2B;//AutchRequest(Client)
byte[] data = System.Text.Encoding.Unicode.GetBytes(UserName);//each char becomes 2 bytes
uint j = 3;
for (int i = 0; i < data.Length; i++)
{
AuthRequest[j] = data[i];
j++;
}
AuthRequest[j] = (0x00);j++;//null terminated string
AuthRequest[j] = (0x00); j++;//null terminated string
AuthRequest[j] = play_ok_[4]; j++;
AuthRequest[j] = play_ok_[5]; j++;
AuthRequest[j] = play_ok_[6]; j++;
AuthRequest[j] = play_ok_[7]; j++;
AuthRequest[j] = play_ok_[0]; j++;
AuthRequest[j] = play_ok_[1]; j++;
AuthRequest[j] = play_ok_[2]; j++;
AuthRequest[j] = play_ok_[3]; j++;
AuthRequest[j] = login_ok_[0]; j++;
AuthRequest[j] = login_ok_[1]; j++;
AuthRequest[j] = login_ok_[2]; j++;
AuthRequest[j] = login_ok_[3]; j++;
AuthRequest[j] = login_ok_[4]; j++;
AuthRequest[j] = login_ok_[5]; j++;
AuthRequest[j] = login_ok_[6]; j++;
AuthRequest[j] = login_ok_[7]; j++;
AuthRequest[j] = (0x01); j++;//
AuthRequest[j] = (0x00); j++;//
AuthRequest[j] = (0x00); j++;//
AuthRequest[j] = (0x00); j++;//
AuthRequest[j] = (0x3C); j++;//
AuthRequest[j] = (0x01); j++;//
AuthRequest[j] = (0x00); j++;//
AuthRequest[j] = (0x00); j++;//
AuthRequest[j] = (0x00); j++;//
AuthRequest[j] = (0x00); j++;//
AuthRequest[j] = (0x00); j++;//
AuthRequest[j] = (0x00); j++;//
AuthRequest[j] = (0x01);//
crypt_.encrypt(AuthRequest, 2, j );
connection_.send_packet(AuthRequest, startlen + 33, socket);
Код:
public void setKey(byte[] key)
{
_key[0] = key[0];
_key[1] = key[1];
_key[2] = key[2];
_key[3] = key[3];
_key[4] = key[4];
_key[5] = key[5];
_key[6] = key[6];
_key[7] = key[7];
_key[8] = key[8];
_key[9] = key[9];
_key[10] = key[10];
_key[11] = key[11];
_key[12] = key[12];
_key[13] = key[13];
_key[14] = key[14];
_key[15] = key[15];
enabled = true;
}
public void encrypt(byte[] raw , int offset, uint size)
{
if (!enabled)
return;
uint temp = 0;
for (int i = 0; i < size; i++)
{
uint temp2 = raw[offset+i] & (uint)0xff;
temp = (temp2 ^ _key[i & 15] ^ temp);
raw[offset+i] = (byte)temp;
}
uint old = ((uint)_key[8]) & (uint)0xff;
old |= (uint)(((uint)_key[9]) << 8 & (uint)0xff00);
old |= (uint)(((uint)_key[10] << 0x10) & (uint)0xff0000);
old |= (uint)(((uint)_key[11] << 0x18) & (uint)0xff000000);
old += (uint)size;
_key[8] = (byte)(old & 0xff);
_key[9] = (byte)(old >> 0x08 & 0xff);
_key[10] = (byte)(old >> 0x10 & 0xff);
_key[11] = (byte)(old >> 0x18 & 0xff);
}
Код:
...
Unknown Packet: 95 on State: CONNECTED Client: [IP: 127.0.0.1]
0000: 0d 17 71 37 83 a9 63 05 89 77 f3 cc 33 bf cc b0 ..q7..c..w..3...
0010: 21 19 14 37 f0 a9 17 05 89 77 73 65 24 72 97 bf !..7.....wse$r..
0020: 79 17 14 37 f0 a9 y..7..
....
....
Unknown Packet: 90 on State: CONNECTED Client: [IP: 127.0.0.1]
0000: 7d fb 9d e1 9b c1 1d 7c 53 4c 41 e5 da 57 8b d8 }......|SLA..W..
0010: 97 62 f8 e1 e8 c1 69 7c 53 4c f3 8b 03 e3 1f ba .b....i|SL......
0020: 09 fb f8 e1 e8 c1 68 7c ......h|
....
...
Unknown Packet: db on State: CONNECTED Client: [IP: 127.0.0.1]
0000: 48 15 5a ff c8 3d 5b 20 e0 d5 8f ec 49 7c 4e 4e H.Z..=[ ....I|NN
0010: 89 ea 3f ff bb 3d 2f 20 e0 d5 ..?..=/ ..
....