我试图从我发现的恶意软件中理解算法。该算法将 http 请求编码到 C&C。反编译版本取自 IDA。有一些评论是我写的。
问题是:我没有看到恶意软件将结果从 QueryPerformanceCounter() 发送到它的 C&C。那么如果没有这个值,C&C 如何解码这个请求呢?
int __cdecl sub_A2AA0(int a1, unsigned int a2, int a3, _BYTE *a4, int a5)
{
// a5: length of buffer
// a4: buffer to encode
// a3: always 0
// a2: always 4
// a1: addr contains result from QueryPerformanceCounter()
signed int v5; // eax@1
char v6; // si@3
unsigned int v7; // eax@3
signed int v8; // edi@3
char v9; // cl@4
int v10; // edx@4
int v11; // edi@7
int v12; // esi@7
int result; // eax@7
char v14; // cl@8
int v15; // ebp@9
_BYTE *i; // edi@9
char v17; // cl@10
char v18[256]; // [sp+0h] [bp-100h]@2
// buffer with 0 to 255
v5 = 0;
do
{
v18[v5] = v5;
++v5;
}
while ( v5 < 256 );
// exchange content of a random index starting with index 0
v6 = 0;
v7 = 0;
v8 = 0;
do
{
v9 = v18[v8];
v10 = (unsigned __int8)(v6 + v18[v8] + *(_BYTE *)(v7++ + a1)); // generate index
v6 = v10;
if ( v7 >= a2 )
v7 = 0;
v18[v8++] = v18[v10];
v18[v10] = v9;
}
while ( v8 < 256 );
// iterate local buffer again, exchange content of cells, starting with index 0
v11 = a3; // init with 0
LOBYTE(v12) = 0;
for ( result = 0; v11; v18[v12] = v14 )
{
result = (unsigned __int8)(result + 1);
v14 = v18[result];
--v11;
v12 = (unsigned __int8)(v12 + v18[result]);
v18[result] = v18[v12];
}
// mask the request
v15 = a5;
for ( i = a4; v15; --v15 )
{
result = (unsigned __int8)(result + 1);
v17 = v18[result];
v12 = (unsigned __int8)(v12 + v18[result]);
v18[result] = v18[v12];
v18[v12] = v17;
*i++ ^= v18[(unsigned __int8)(v17 + v18[result])]; // simple xor
}
return result;
}