[英]How to convert a hex address from a char buffer to be written to memory
So i got this function here, which is called from the main function: 所以我在这里得到了这个功能,这是从主要功能中调用的:
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;
}
The string *arg
comes out of argv[1]
. 字符串
*arg
来自argv[1]
。
And when i do something like: 当我做类似的事情时:
./overflow1 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa29390408
the stack looks like this: 堆栈看起来像这样:
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
So how do i get: 那么我如何获得:
0x32 0x39 0x33 0x39 0x30 0x34 0x30 0x38
to be: 成为:
29 39 04 08
? 29 39 04 08
?
I do realise that this needs to be converted from actual hex values to alphanumeric values, for example 08
, but every string tool on the web gives me no result, because 08
is not a ascii/alphanumeric value. 我确实意识到需要将其从实际的十六进制值转换为字母数字值,例如
08
,但是网络上的每个字符串工具都没有给出任何结果,因为08
并非ASCII /字母数字值。
If you want to send arbitrary bytes to a command as arguments, you'll have to escape them in your shell. 如果要向命令发送任意字节作为参数,则必须在shell中转义它们。 In bash, for example, you can do:
例如,在bash中,您可以执行以下操作:
echo $'a\x09b\x33c'
And it will show: 它会显示:
a b3c
because bash interprets \\xHH (two hex digits) inside the $'' construct as single-byte hex values. 因为bash将$''结构中的\\ xHH(两个十六进制数字)解释为单字节十六进制值。 0x09 is a tab, 0x33 is the digit 3.
0x09是制表符,0x33是数字3。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.