SYSREVEAL

Peek into NOD32 module file

by on Feb.05, 2010, under ReverseIt

Okey, I have been criticized by Niucool & Bananas as there is none post in this blog from me.
Feeling shamed~~~
So I decided to post something to let your guys know that I am alive.

Do you interesting antivirus engine? Do you wanna know what is it?
Hmmm, I think that I can not give u the answer. It’s a kidding :)

Many people think that eset nod32 is a good antivirus, and … so do I.
Hereby, I intend to play with it and give you a short info about it.

In the nod32 AppData folder(Or other folder? I forgot it!), you may find out some data files. They called “em???_32.dat”.

What’s meaning for this name?
I guess: “e” – Eset, “m” – Module, ??? – it’s just a id number, 32 – means 32 bit(I am not sure).
Before I analyzed it, I think that these files are the virus database file.
But in fact, I am wrong. They are the extend engine module!

Basically, the file format contains 6 major parts. They are:
1. File header:

size = variant (from 0 to the first 0x0A0D0A0D), the signature and checksum included in this section,
we are not interesting in this;

2. File info:

size = 0×100, all info are text string, you can view it directly;

3. Module record header:

size = 0x1C:
offset        comment
0×00        signature = 0x45FA785E
0×04        signature = 0×05
0x0C        decrypt key
0×18        checksum for this section

4. Module control header:

size = 0×108, the function as PE header,
some useful values in this section:

offset    comment
0xD4    entrypoint
0xD8    size of seg with access ER-
0xDC    size of seg with access -R-
0xE0    size of seg with access -RW

(E – Executabe, R – Readabe, W – writable)

5. Module section array:
This is a section array, just like section table in PE structure.
The last one is “NULL” section.

section struct:
size = 0×24
00    section name(“CODE” | “DATA” | “UNPC” | “UNPR” | “RELO” | “NULL”)
04    raw offset for segment (calculate from “File Info” part);
08    checksum of segment data
0C    raw size of segment
10    virtual size of segment
1C    compress flag ??? (1 – compressed, other – no compressed???)
20    checksum of this section

6. Module segment array:
Like segment in PE;

The data in part 4,5 and 6 are crypted. If compressed flags is set, the data is also compressed.
To decompress, we could use zlib inflate() function.
To decrypt (note: only tested on nod32 v3.x and v4.x version, this could be changed!!!):

static unsigned char g_decrypt_table[0x288] = {
	0x27, 0x45, 0xFB, 0x82, 0x66, 0x0F, 0xDC, 0x69, 0x31, 0xA7, 0xDA, 0x00, 0xA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	0xF9, 0x8B, 0xD8, 0x9B, 0xBB, 0xAB, 0x9A, 0xBB, 0x75, 0x4A, 0x54, 0x5A, 0x37, 0x6A, 0x16, 0x7A,
	0xF1, 0x0A, 0xD0, 0x1A, 0xB3, 0x2A, 0x92, 0x3A, 0x2E, 0xFD, 0x0F, 0xED, 0x6C, 0xDD, 0x4D, 0xCD,
	0xAA, 0xBD, 0x8B, 0xAD, 0xE8, 0x9D, 0xC9, 0x8D, 0x26, 0x7C, 0x07, 0x6C, 0x64, 0x5C, 0x45, 0x4C,
	0xA2, 0x3C, 0x83, 0x2C, 0xE0, 0x1C, 0xC1, 0x0C, 0x1F, 0xEF, 0x3E, 0xFF, 0x5D, 0xCF, 0x7C, 0xDF,
	0x9B, 0xAF, 0xBA, 0xBF, 0xD9, 0x8F, 0xF8, 0x9F, 0x17, 0x6E, 0x36, 0x7E, 0x55, 0x4E, 0x74, 0x5E,
	0x93, 0x2E, 0xB2, 0x3E, 0xD1, 0x0E, 0xF0, 0x1E
};

static unsigned char * g_decrypt_table1 = &g_decrypt_table[0x0];
static unsigned char * g_decrypt_table2 = &g_decrypt_table[0xC];
static unsigned char * g_decrypt_table3 = &g_decrypt_table[0x1C];
static unsigned char * g_decrypt_table4 = &g_decrypt_table[0x30];
static unsigned char * g_decrypt_table5 = &g_decrypt_table[0x48];
static unsigned char * g_decrypt_table6 = &g_decrypt_table[0x68];

unsigned int get_mul_high_uint(unsigned int x, unsigned int y)
{
	unsigned int z;

	__asm
	{
		pusha
		mov eax, x
		mov ecx, y
		mul ecx
		mov z, edx
		popa
	}

	return z;
}

void decrypt (unsigned char * buffer, int length, unsigned int xkey)
{
	unsigned int m, n;
	int x, i;
	char c1, c2, c3, c4, c5, c6, c, cc;

	// 4079BA
	n = get_mul_high_uint(xkey, 0xBA2E8BA3);
	n >>= 3;
	c = (char)n * 0x0B;
	c1 = (char)xkey - c;

	// 4079CE
	n = get_mul_high_uint(xkey, 0x4EC4EC4F);
	n >>= 2;
	c = (char)n * 0x0D;
	c2 = (char)xkey - c;

	// 4079E6
	n = get_mul_high_uint(xkey, 0xF0F0F0F1);
	n >>= 4;
	c = (char)n * 0x11;
	c3 = (char)xkey - c;

	// 4079FE
	n = get_mul_high_uint(xkey, 0xB21642C9);
	n >>= 4;
	c = (char)n * 0x17;
	c4 = (char)xkey - c;

	// 407A16
	n = get_mul_high_uint(xkey, 0x8D3DCB09);
	n >>= 4;
	c = (char)n * 0x1D;
	c5 = (char)xkey - c;

	// 407A2E
	m = get_mul_high_uint(xkey, 0x8421085);
	n = xkey - m;
	n >>= 1;
	n += m;
	n >>= 4;
	c = (char)n * 0x1F;
	c6 = (char)xkey - c;

	// 407A46
	if (length<=0)
		return;

	for (i=0; i<length; i++) {
		// 407A51
		c = g_decrypt_table6[c6]
			^ g_decrypt_table5[c5]
			^ g_decrypt_table4[c4]
			^ g_decrypt_table3[c3];

		// 407A84
		x = c2;

		// 407A90
		cc = c ^ g_decrypt_table2[c2] ^ g_decrypt_table1[c1];

		// 407AA4
		c1 ++;

		buffer[i] ^= cc;
		if (c1 >= 0x0B)
			c1 += 0xF5;	// c1 = 0;

		// 407AB6
		c2 ++;

		if (c2>=0x0D)
			c2 += 0xF3;	// c2 = 0

		// 407AC6
		c3 ++;
		if (c3>=0x11)
			c3 += 0xEF;	// c3 = 0

		// 407AD9
		c4 ++;
		if (c4>=0x17)
			c4 += 0xE9;	// c4 = 0

		// 407AEC
		c5 ++;
		if (c5>=0x1D)
			c5 += 0xE3;	// c5 = 0

		// 407AFF
		c6 ++;
		if (c6>=0x1F)
			c6 += 0xE1;	// c6 = 0
	}
}

7 Comments for this entry

  • Bananas

    That’s the spirit!

  • Neil Patmore

    ESET NOD32 is without a doubt my favourite AV product at the moment. I can’t believe how light the footprint is. You wouldn’t even know it was running if the icon wasn’t in the sys tray.

  • ESET NOD32

    ESET is by far the best solution available at present and they are doing some great deals at the moment

  • me09

    hello.I made an extraordinary think for my computer.I found a review of nod 32 in top ten best antiviruses http://www.best-antivirus.co/ and i updated it
    hope it will help you,too

  • top 10 antiviruses

    Found your webblog on AskJeeves, great subject material, but the site looks awkward inside my browser setup, but performs fine in IE. choose figure.

  • top ten antivirus

    howdy, perhaps this post may be a bit off topic but the point is, I have been searching your web site plus it looks truly tasteful..I’m resulting in a new blog and my business is hard-pressed to make it appear great, and supply high class content. I have learned plenty here and I look ahead to more updates and could be returning.

  • get thin

    Absolutely think that you simply claimed. Your selected reason seemed to be on the internet the simplest thing to be familiar with. I explain to you, I absolutely get irritated whilst folks consider worries that they simply don’t know with regards to. You was able to hit the nail upon the top and identified out the whole thing with no complication , people usually takes a signal. Will likely be time for read more. Many thanks

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Blogroll

A few highly recommended websites...