Nake和shellcode模式实现加法


#include "stdio.h"

unsigned char Addbuff[]={0x55 ,0x8B, 0xEC , 0x83, 0xEC, 0x48, 0x57 ,0x56, 0x51, 0xB8, 0xCC, 0xCC, 0xCC, 0xCC,
0xB9, 0x0C, 0x00, 0x00, 0x00, 0x8D, 0x7D, 0xB8, 0xF3, 0xAB, 0x8B ,0x45, 0x08, 0x03, 0x45, 0x0C, 0x59, 0x5E,
0x5F, 0x8B, 0xE5, 0x5D ,0xC3};

int Add(int x,int y)
{
return x+y;
}
_declspec(naked) int Addshellcode(int x,int y)
{
_asm
{

push ebp;
mov ebp,esp;
sub esp,0x48;
push edi;
push esi;
push ecx;
mov eax,0xcccccccc;
mov ecx,0xc;
lea edi,[ebp-0x48];
rep stosd;
mov eax,[ebp+0x8];
Add eax,[ebp+0xc];
pop ecx
pop esi
pop edi
mov esp,ebp
pop ebp;
ret;
}
}

void main()
{
int r;
_asm
{
push 0x5;
push 0x4;
lea eax,Addbuff
call eax;
mov r, eax
add esp,0x8;
}

 

printf("%d",r);
getchar();

}

posted @ 2021-09-24 11:56  admrty  阅读(98)  评论(0)    收藏  举报