gpt4 book ai didi

c++ - 运行 shellcode + vs2010

转载 作者:太空宇宙 更新时间:2023-11-03 10:20:21 25 4
gpt4 key购买 nike

为了 shellcode 测试目的,我刚刚尝试了以下代码片段:-

#include<iostream>

using namespace std;

char sc[] = ""; #i've removed the shellcode
int main() {
int (*func)();
func = (int(*)())sc;
(int)(*func)();
}

我在编译时遇到构建错误:-

------ Build started: Project: shellcoderunner, Configuration: Debug Win32 ------
Build started 10/15/2011 12:51:16 PM.
InitializeBuildStatus:
Touching "Debug\shellcoderunner.unsuccessfulbuild".
ClCompile:
blah.cpp
c:\users\reverser\documents\visual studio 2010\projects\shellcoderunner\shellcoderunner\blah.cpp(7): error C2440: 'type cast' : cannot convert from 'char [149]' to 'int (__cdecl *)(void)'
There is no context in which this conversion is possible

Build FAILED.

Time Elapsed 00:00:01.99
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

有明显我做错的地方吗?

最佳答案

要使用 VS 在 C/C++ 程序中执行 shellcode,最简单的方法是嵌入汇编代码,如下例所示:

char* buffer="blah blah blah";
int main() {
__asm{
lea eax, buffer
call eax
}
}

希望对您有所帮助!

关于c++ - 运行 shellcode + vs2010,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7776451/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com