C 如何将十六进制地址从字符缓冲区转换为写入内存

C 如何将十六进制地址从字符缓冲区转换为写入内存,c,string,assembly,hex,buffer,C,String,Assembly,Hex,Buffer,我在这里得到了这个函数,它是从主函数调用的: void overflow(char *arg) { char buf[1369]; strcpy (buf, arg); printf ("Thank you for contacting customer service. You are so important to us that we wrote a program to serve you.\n"); printf ("Please hold for

我在这里得到了这个函数,它是从主函数调用的:

void overflow(char *arg)
{
    char buf[1369];

    strcpy (buf, arg);

    printf ("Thank you for contacting customer service. You are so important to us that we wrote a program to serve you.\n");
    printf ("Please hold for %u minutes while I drop your call\n", (int)strlen(buf));

    return;
} 
字符串*arg来自argv[1]

当我做一些类似的事情时:


./overflow1 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa29390408
堆栈如下所示:


0xffffce80: 0x07    0x00    0x00    0x61    0x61    0x61    0x61    0x61
0xffffce88: 0x61    0x61    0x61    0x61    0x61    0x61    0x61    0x61
0xffffce90: 0x61    0x61    0x61    0x61    0x61    0x61    0x61    0x61
0xffffce98: 0x61    0x61    0x61    0x61    0x61    0x61    0x61    0x61
0xffffcea0: 0x61    0x61    0x61    0x61    0x61    0x61    0x61    0x61
0xffffcea8: 0x61    0x61    0x61    0x61    0x61    0x61    0x61    0x61
0xffffceb0: 0x61    0x61    0x61    0x61    0x61    0x61    0x61    0x61
0xffffceb8: 0x61    0x61    0x61    0x61    0x61    0x61    0x61    0x61
0xffffcec0: 0x61    0x61    0x32    0x39    0x33    0x39    0x30    0x34
0xffffcec8: 0x30    0x38
那么,我如何获得:

0x32 0x39 0x33 0x39 0x30 0x34 0x30 0x38

将是:

29 39 04 08 ?


我确实意识到这需要从实际的十六进制值转换为字母数字值,例如08,但是web上的每个字符串工具都没有给我结果,因为08不是ascii/字母数字值。

如果您想将任意字节作为参数发送到命令,您必须在shell中转义它们。例如,在bash中,可以执行以下操作:

echo $'a\x09b\x33c'
它将显示:

a       b3c

因为bash将$construct中的两个十六进制数字\xHH解释为单字节十六进制值。0x09是一个标签,0x33是数字3。

这里可能有点混乱,但这不是我想要做的。问题是我需要内存插槽显示0x29,而不是0x32 0x39,这似乎是作为2和9写入内存,这是四个字节,但我试图将0x29作为一个字节写入您需要发送ASCII字符值0x29或十进制29?到输入流。int maiint argc,char**argv{customerservice argv[1];printf我们自然无法完成您的呼叫。再见!\n;返回0;}是的0x29作为字符存在于ascii字母表中,但根据:在此工具中键入08不会给出任何结果,表示08不作为字母数字字符存在。因此,我不知道如何才能做到这一点。不,这只是c,assemblyargv[0]只是程序的名称,看起来,argv[1]包含作为参数给出的所有内容。因此,如果我键入./overflow1 aaaaaa,它将用0x61 0x61 0x61 0x61 0x61 0x61 0x61填充内存。唯一的问题似乎是查找0x08和0x04的字母数字值,但这些值似乎不存在。由于strlen返回的值始终大于等于0,并且由于格式标识符为%u unsigned int,因此看起来是:“intstrlenbuf;”应该是:“unsignedstrlenbuf;”\x08本应是\x8无法相信这是多么简单,但感谢您的回答,我会记住这一点。