读"黑客 - 剥削的艺术"一书; 我跟随编写器,因为他通过溢出堆栈并更改函数的返回地址来更改执行流程.(具体来说,第135-136页)他设法用Perl脚本执行此操作,将返回地址作为命令行参数输入10次:
$ ./auth_overflow2 $(perl -e 'print "\xbf\x84\x04\x08"x10')
Run Code Online (Sandbox Code Playgroud)
0x080484bf
返回地址在哪里.
我正在尝试做同样的事情,但我的返回地址以0x00开头.将\ x08替换为\ x00,空字符将被省略,因此我要输入的地址在内存映射中移位了一个字节.我该如何解决这个问题?
我是一个C菜鸟,我试图制作一个删除特定行的程序.为此,我选择复制源文件的内容,跳过要删除的行.在我的原始代码中,我写道:
while(read_char = fgetc(fp) != '\n') //code to move the cursor position to end of line
{
printf("%c",read_char); //temporary code to see the skipped characters
}
Run Code Online (Sandbox Code Playgroud)
这给了我很多笑脸.
最后,我找到了给出预期输出的代码:
read_char=fgetc(fp);
while(read_char != '\n') //code to move the cursor position to end of line
{
printf("%c",read_char); //temporary code to see the skipped characters
read_char=fgetc(fp);
}
Run Code Online (Sandbox Code Playgroud)
但这两个代码之间的实际差异是什么?