C code解释 [英] C code explanation

查看:139
本文介绍了C code解释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁能帮我解释code,这些线路?

 字符code [] =粘贴你的shell code在这里;INT主(INT ARGC,字符** argv的)
{
   INT(* FUNC)();
   FUNC =(INT(*)())code;
   (INT)(* FUNC)();
}


解决方案

在code,你在这里是如何创建一个函数指针到任意数据片,然后调用它的例子。

在一个很简单的道理,我们分配的字节数组(的char [])成二进制壳code的有效载荷将被粘贴,一般为转义的十六进制值。

这行, INT(* FUNC)(); ,声明了一个函数指针,将返回一个整数。这是典型的因为大多数code会有某种基于整数退出code在EAX返回。

这行, FUNC =(INT(*)())code; 注塑字节数组code是一个函数指针,给它分配以'功能',在previously定义的函数指针。

这行(INT)(* FUNC)(); 实际上调用外壳code,字节数组中传递执行到第一个内存位置

这code实际上是非常有用的。你不会期望找到它用来利用系统;这反而code是用来测试出来,调试和开发过程中与外壳code,否则实验。使用它,你可以在shell code,你正试图测试,然后执行它简单地粘贴。这可以让你保持你的shell code很简单,不包括所有的典型要求一个完整的独立的可执行文件,但仍然允许你进行测试,而不需要你确定一个漏洞被利用。这样,你就可以知道,如果code工作而不被试图利用实际code时出现的各种分心。

Could anybody help me explaining these lines of code?

char code[] = "paste your shellcode here";

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

解决方案

The code that you have here is an example of how to create a function pointer to an arbitrary slice of data and then call it.

In a very simple sense we are allocating an array of bytes (char []) into which the binary shellcode payload is pasted, typically as escaped hex values.

This line, int (*func)();, declares a function pointer that will return an integer. This is typical because most code will have some sort of integer based exit code returned in EAX.

This line, func = (int (*)()) code; casts the byte array code to be a function pointer and assigns it to 'func', the previously defined function pointer.

This line (int)(*func)(); actually calls the shellcode, transferring execution to the first memory location in the byte array.

This code is actually extremely useful. You wouldn't expect to find it used to exploit a system; instead this code is used to test out, debug and otherwise experiment with shellcode during development. Using it you can simply paste in the shellcode that you are trying to test and then execute it. This allows you to keep your shellcode very simple, excluding all of the typical requirements for a full standalone executable, yet still allowing you to test it without requiring that you identify a vulnerability to exploit. In this way you can know if the code works without being distracted by the various that arise when trying to exploit actual code.

这篇关于C code解释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆