вот так выглядит алгоритм шифрования абисса:
Код:
// код C++
#pragma pack(push,2)
struct packetbuf
{
unsigned short length;
char data[USHRT_MAX+1-2];
};
#pragma pack(pop)
class XorcryptManipulator
{
public:
XorcryptManipulator(){}
void Initialize(int key_lo,int key_hi);
opacketstream& operator() ( opacketstream& pout );
ipacketstream& operator() ( ipacketstream& pin );
private:
__int64 key_in; //key for input stream
__int64 key_out; //key for output stream
};
opacketstream& bot::XorcryptManipulator::operator()( opacketstream& pout )
{
packetbuf& buf=pout.buffer();
union
{
__int64 key;
char bytes[8];
} k2;
k2.key=key_out;
char k;
buf.data[0] ^= k2.bytes[0];
for (int i=1;i<buf.length;++i,buf.data[i-1]^=k)
k=k2.bytes[i&7] ^ buf.data[i-1];
key_out += buf.length;
return pout;
}
ipacketstream& bot::XorcryptManipulator::operator()( ipacketstream& pin )
{
packetbuf& buf=pin.buffer();
union
{
__int64 key;
char bytes[8];
} k2;
k2.key=key_in;
char k=buf.data[0];
buf.data[0] ^= k2.bytes[0];
for(int i=1;i<buf.length;++i)
{
char t=buf.data[i];
buf.data[i]^=k^k2.bytes[i&7];
k=t;
}
key_in += buf.length;
return pin;
}
void bot::XorcryptManipulator::Initialize( int key_lo,int key_hi )
{
union
{
__int64 key;
struct
{
int lo;
int hi;
};
} k;
k.lo=key_lo;
k.hi=key_hi;
key_in=k.key;
key_out=k.key;
}