В синтаксисе делфи нет ничего сложного. З.Ы. могу кой-какие сорсы на с++ дать.
Цитата:
if isAion and(Size>0)then pck[0]:=(pck[0] + $AE) xor $EE; // и нафига это...
|
Шоб Аионский трафик норм пакетхаком хавался.
Инит ключа xor
Код:
switch(inptype)
{
case 0x2E://InitCrypt
{
if(!in.readC())
QMessageBox::information(NULL, "L2M Alfa:Omg",
"Wrong protocol version can be troubles :'(");
for(int x=0;x<8;x+=1)
{
inxorkey[x]=in.readC();
outxorkey[x]=inxorkey[x];
}
xorkeyaccepted=true;
out.writeC(0x2b);
l2m_mstr a;
l2m_uch tmp[28];
for(int x=0;x<28;x+=1)
tmp[x]=0;
for(int x=0;x<14;x+=1)
tmp[x*2]=ulogin[x];
a.fromuch(tmp,28);
a.killzero();
out.writeS(&a,true);
out.writeC(0x00);
out.writeD(playOK[1]);
out.writeD(playOK[0]);
out.writeD(loginOK[0]);
out.writeD(loginOK[1]);
out.writeD(0);
out.writeD(0);
out.writeD(0);
sendpacket();
}
break;
}
Расшифровка
Код:
void l2m_packets::unxorin()
{
l2m_uch tr=0;
l2m_uch tr2=0;
for(int x=0;x<in.buf.length;x+=1)
{
tr2=in.buf.str[x];
in.buf.str[x]=(tr2^inxorkey[x&15])^tr;
tr=tr2;
}
l2m_uint old = inxorkey[8] &0xff;
old |= (inxorkey[9] << 8) &0xff00;
old |= (inxorkey[10] << 0x10) &0xff0000;
old |= (inxorkey[11] << 0x18) &0xff000000;
old+=in.buf.length;
inxorkey[8] = old &0xff;
inxorkey[9] = (old >> 8) &0xff;
inxorkey[10] = (old >> 0x10) &0xff;
inxorkey[11] = (old >> 0x18) &0xff;
}
Шифровка
Код:
void l2m_packets::xorout()
{
l2m_uch tr=0;
l2m_uch tr2=0;
for(int x=0;x<out.buf.length;x+=1)
{
tr2=out.buf.str[x];
tr=tr2^outxorkey[x&15]^tr;
out.buf.str[x]=tr;
}
l2m_uint old = outxorkey[8] &0xff;
old |= (outxorkey[9] << 8) &0xff00;
old |= (outxorkey[10] << 16) &0xff0000;
old |= (outxorkey[11] << 24) &0xff000000;
old+=out.buf.length;
outxorkey[8] = old &0xff;
outxorkey[9] = (old >> 8) &0xff;
outxorkey[10] = (old >> 16) &0xff;
outxorkey[11] = (old >> 24) &0xff;
}
Имхо маешся фигнёй - зачем делать то что уже есть?