从汇编代码提取Shellcode的简单实现

#include <stdio.h>

unsigned char *asm_code()
{
__asm
{
   lea eax,__code
   jmp __ret
}

//这里放shellcode的汇编代码

//---------------------------------------------------------------------------------------------------------------------
__asm
{
__code:
xor     ebx, ebx                         ; test.00405030
push    ebx
push    4B435546h
mov     eax, esp
push    ebx
push    eax
push    eax
push    ebx
mov     eax, 77E18098h
call    eax
mov     eax, 77E6E01Ah
push    ebx
call    eax
}

//---------------------------------------------------------------------------------------------------------------------


//函数结语
__asm int 3
__asm { __ret: }
}

void main()
{
unsigned char temp;
int i = 1;
unsigned char *asm_p = asm_code();
FILE *fd = fopen("code.txt","w");
fprintf(fd,"unsigned char shellcode = \"");
while((temp = *asm_p) != 0xcc)
{
   fprintf(fd,");
   asm_p ++;
   if(i % 8 == 0) fprintf(fd,"\"\n\"");
   i ++;
}
fprintf(fd,"\";");
fclose(fd);
}

/*

生成的code.txt:

unsigned char shellcode = "\x33\xdb\x53\x68\x46\x55\x43\x4b"
"\x8b\xc4\x53\x50\x50\x53\xb8\x98"
"\x80\xe1\x77\xff\xd0\xb8\x1a\xe0"
"\xe6\x77\x53\xff\xd0";

*/

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值