日期:2014-05-17 浏览次数:21008 次
typedef struct JJ_HEADER_tag
{
DWORD time; //时间
DWORD index; //序列号 从0开始 每次+1
DWORD cmd; //类型1
DWORD option; //类型2
DWORD unk; //未知
DWORD datalength; //数据长度(不包括包头)
}JJ_HEADER, *PJJ_HEADER;
int CJJNetwork::PacketData()
{
BYTE Data[sizeof(JJ_HEADER)+8] = {0};
PJJ_HEADER header = (PJJ_HEADER)Data;
PBYTE Body = (PBYTE)(Data+sizeof(JJ_HEADER));
header->time = time(0);
header->index = m_PacketIndex++;
header->cmd = 0x44C;
header->option = 0x24800;
header->datalength = 8;
*(PDWORD)Body = 0x5045BA76;
*(PDWORD)(Body+4) = 0x4E22;
return XorEncrypt(Data, sizeof(Data));
}
int CJJNetwork::XorEncrypt(BYTE * Data, int Len)
{
if (Len>0x14)
{
PJJ_HEADER header = (PJJ_HEADER)Data;
if (header->datalength>0 && !(header->option&0x40000000))
{
header->option |= 0x40000000;
BYTE * pData = Data+sizeof(JJ_HEADER);
printPackets("pData", pData, Len);
for (DWORD i=0; i<header->datalength; i++)
{
BYTE key = Data[(header->index^i)%4];
pData[i] ^= key;
}
}
}
return 0;
}