首页
社区
课程
招聘
[旧帖] [转帖]C语言拆行shellcode的五种方式 0.00雪花
发表于: 2010-11-3 08:08 1050

[旧帖] [转帖]C语言拆行shellcode的五种方式 0.00雪花

2010-11-3 08:08
1050
//备注:在WindowsXP SP3下测试成功

#include "windows.h"
#include "stdio.h"
  
typedef void (_stdcall *CODE)();

//一段打开Windows计算器(calc.exe)的shellcode   
unsigned char shellcode[] =   
"\xb8\x82\x0a\x8d\x38\xd9\xc6\xd9\x74\x24\xf4\x5a\x29\xc9\xb1\x23"  
"\x31\x42\x12\x83\xea\xfc\x03\xc0\x04\x6f\xcd\x38\xf0\x2b\x2e\xc0"  
"\x01\x3f\x6b\xfc\x8a\x43\x71\x84\x8d\x54\xf2\x3b\x96\x21\x5a\xe3"  
"\xa7\xde\x2c\x68\x93\xab\xae\x80\xed\x6b\x29\xf0\x8a\xac\x3e\x0f"  
"\x52\xe6\xb2\x0e\x96\x1c\x38\x2b\x42\xc7\xc5\x3e\x8f\x8c\x99\xe4"  
"\x4e\x78\x43\x6f\x5c\x35\x07\x30\x41\xc8\xfc\x45\x65\x41\x03\xb2"  
"\x1f\x09\x20\x40\xe3\x83\xe8\x2c\x68\xa3\xd8\x29\xae\x5c\x15\xba"  
"\x6f\x91\xae\xcc\x73\x04\x3b\x44\x84\xbd\x35\x1f\x14\xf1\x46\x1f"  
"\x15\x79\x2e\x23\x4a\x4c\x59\x3b\x22\x27\x5d\x38\x0a\x4c\xce\x56"  
"\xf5\x6b\x0c\xd5\x61\x14\x2f\x93\x7c\x73\x2f\x44\xe3\x1a\xa3\xe9"  
"\xe4";   
  
//第一种方法   
void RunShellCode_1()   
{   

//   void (*code)(void);   
//    code = (void*)shellcode;
      PVOID p=NULL;
      if((p=VirtualAlloc(NULL,sizeof(shellcode),MEM_COMMIT|MEM_RESERVE,PAGE_EXECUTE_READWRITE))==NULL)
  MessageBox(NULL,"申请内存失败","提醒",MB_OK);
      if(!(memcpy(p,shellcode,sizeof(shellcode))))
  MessageBox(NULL,"写内存失败","提醒",MB_OK);
     CODE code=(CODE)p;   
    code();   
}   
  
//第二种方法   
void RunShellCode_2()   
{   
    ( (void (*)(void))&shellcode )();   
}   
  
//第三种方法
void RunShellCode_3()   
{   
    __asm   
    {   
        lea eax,shellcode;   
        jmp eax;   
    }   
}   
  
//第四种方法   
void RunShellCode_4()   
{   
    __asm   
    {   
        mov eax,offset shellcode;   
        jmp eax;   
    }   
}   
  
//第五种方法   
void RunShellCode_5()   
{   
    __asm   
    {   
        mov eax,offset shellcode;   
        _emit 0xFF;   
        _emit 0xE0;   
    }   
}   
   
void main()   
{   
    RunShellCode_1();   
}

[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课

收藏
免费 0
支持
分享
最新回复 (5)
雪    币: 458
活跃值: (421)
能力值: ( LV9,RANK:610 )
在线值:
发帖
回帖
粉丝
2
支持啦   。。。
2010-11-3 09:28
0
雪    币: 2105
活跃值: (424)
能力值: ( LV4,RANK:50 )
在线值:
发帖
回帖
粉丝
3
mei you shen me yi si
2010-11-3 10:05
0
雪    币: 38
活跃值: (52)
能力值: ( LV3,RANK:20 )
在线值:
发帖
回帖
粉丝
4
ding qi
2010-11-3 13:33
0
雪    币: 84
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
5
又学习了!谢谢楼主!
2010-11-3 14:48
0
雪    币: 4
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
6
谢谢了,学习了!!
2010-11-4 17:17
0
游客
登录 | 注册 方可回帖
返回
//