C 获取十六进制 shellcode 的大小

标签 c char

如何获取字符指针的大小

char *data = "\x30\x2e\x30\x2e\x30\x2e\x30\x3a\x30";

使用 strlen(data)sizeof(data) 总是返回 1

最佳答案

strlen 对 C 字符串中的字符进行计数,直到遇到 0。它可能 使用 strlen 获取 shell 代码的长度很棘手,因为 shell 代码 中间可能包含 0 个字节;似乎甚至存在无空 shell 代码 (link) 的概念 - 在这种情况下,我相信您可以使用 strlen。否则你可以尝试:

char data[] = "\x30\x2e\x30\x2e\x30\x2e\x30\x3a\x30"; // you were missing \ in the beginning
printf("%zu", sizeof(data));

给你 10 个字节。

关于C 获取十六进制 shellcode 的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29542031/

相关文章:

c - OpenCV 上的逆向过滤——访问 DFT 值并乘以 DFT 矩阵

c - getline 不将字符串存储在变量中

c - C 中字符比较的段错误

c - 为什么字符串终止不会发生在空字符处

c++ - 如何删除继承的私有(private) char* 属性? (例如 : in a destructor)

时间:2019-03-17 标签:c++segfault: char pointers

可以使用 TensorFlow C API 训练 Keras 模型吗?

c - 使用 fork 和 dup 的简单 http 通用服务器

c - 二维字符数组中的 C 指针问题

c - 具有多个定义的不透明结构