如何获取字符指针的大小
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/